Passed
Push — develop ( 18945a...910cfa )
by Daniel
01:04 queued 10s
created

src/javascript/enhancements/cssEnhancements.js   A

Complexity

Total Complexity 19
Complexity/F 1.46

Size

Lines of Code 61
Function Count 13

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 36
dl 0
loc 61
rs 10
c 0
b 0
f 0
wmc 19
mnd 6
bc 6
fnc 13
bpm 0.4615
cpm 1.4615
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
F cssEnhancements.js ➔ init 0 57 19
1
import { getGlobalConfiguration, SETTINGS_websiteHideUnusedTabs, SETTINGS_websiteOptimizeListAppearance } from '../configuration/configuration';
2
import * as core from '../utils/aniwatchCore';
3
import * as helper from '../utils/helpers';
4
5
export function init() {
6
    getGlobalConfiguration().getProperty(SETTINGS_websiteHideUnusedTabs, value => {
7
        // if disabled, add class to avoid our css optimizations
8
        if (!value) {
9
            let disableFunc = node => {
10
                if (helper.isHtmlElement(node)) {
11
                    let disableNode = node => {
12
                        node.classList.add('awp-hide-unused-disabled')
13
                    }
14
15
                    if (node.tagName === 'MD-TAB-ITEM') {
16
                        disableNode(node);
17
                    }
18
                    else {
19
                        node.querySelectorAll('md-tab-item').forEach(node => disableNode(node));
20
                    }
21
                }
22
            };
23
24
            core.registerScript(node => {
25
                disableFunc(node);
26
            }, ".*");
27
28
            core.runAfterLoad(() => {
29
                disableFunc(document.body);
30
            }, ".*");
31
        }
32
    });
33
34
    getGlobalConfiguration().getProperty(SETTINGS_websiteOptimizeListAppearance, value => {
35
        // if disabled, add class to avoid our css optimizations
36
        if (!value) {
37
            let disableFunc = node => {
38
                if (helper.isHtmlElement(node)) {
39
                    let disableNode = node => {
40
                        node.classList.add('awp-list-disabled')
41
                    }
42
43
                    if (node.tagName === 'MD-LIST-ITEM') {
44
                        disableNode(node);
45
                    }
46
                    else {
47
                        node.querySelectorAll('md-list-item').forEach(node => disableNode(node));
48
                    }
49
                }
50
            }
51
52
            core.registerScript(node => {
53
                disableFunc(node);
54
            }, ".*");
55
56
            core.runAfterLoad(() => {
57
                disableFunc(document.body);
58
            }, ".*");
59
        }
60
    });
61
}