Completed
Push — master ( c8749b...21bf41 )
by Dongxin
32s
created

scripts/renovate.js   A

Complexity

Total Complexity 5
Complexity/F 5

Size

Lines of Code 16
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
cc 0
c 3
b 0
f 2
nc 1
dl 0
loc 16
rs 10
wmc 5
mnd 3
bc 5
fnc 1
bpm 5
cpm 5
noi 3
1
// Copyright © 2017 TangDongxin
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining
4
// a copy of this software and associated documentation files (the "Software"),
5
// to deal in the Software without restriction, including without limitation
6
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
7
// and/or sell copies of the Software, and to permit persons to whom the
8
// Software is furnished to do so, subject to the following conditions:
9
//
10
// The above copyright notice and this permission notice shall be included
11
// in all copies or substantial portions of the Software.
12
//
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
15
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
19
// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21
// ===========================================
22
// JSON RENOVATER
23
// ===========================================
24
25
26
function onRenovate(result) {
0 ignored issues
show
Unused Code introduced by
The parameter result is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
27
    if (dontBeatify) {
0 ignored issues
show
Best Practice introduced by
If you intend to check if the variable dontBeatify is declared in the current environment, consider using typeof dontBeatify === "undefined" instead. This is safe if the variable is not actually declared.
Loading history...
28
        return;
29
    }
30
    var items = document.getElementsByClassName('S' + RAND);
0 ignored issues
show
Bug introduced by
The variable RAND seems to be never declared. If this is a global, consider adding a /** global: RAND */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
31
    for (var i = 0; i < items.length; i++) {
32
        if (isJSON(items[i].innerHTML)) {
33
            items[i].setAttribute("content", '<str style="color:#888;"> [→ str ←]  </str><json style="color:#888;"> [← json →]  </json>' + items[i].innerHTML);
34
            items[i].setAttribute("json", items[i].innerHTML);
35
            items[i].innerHTML = '<str style="color:#888;"> [← str →]  </str><json style="color:#888;"> [← json →]  </json>' + items[i].innerHTML.substring(0, 10) + ' ··· ' + items[i].innerHTML.substr(-10, 10);
36
        } else if (items[i].innerHTML.length > 300) {
37
            items[i].setAttribute("content", '<str style="color:#888;"> [→ str ←]  </str>' + items[i].innerHTML);
38
            items[i].innerHTML = '<str style="color:#888;"> [← str →]  </str>' + items[i].innerHTML.substring(0, 10) + ' ··· ' + items[i].innerHTML.substr(-10, 10);
39
        }
40
    }
41
}
42