Completed
Pull Request — master (#19)
by Flo
04:12
created

public/assets/js/engine.js   A

Complexity

Total Complexity 7
Complexity/F 1.17

Size

Lines of Code 49
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 7
dl 0
loc 49
rs 10
c 1
b 0
f 1
cc 0
nc 1
mnd 1
bc 7
fnc 6
bpm 1.1666
cpm 1.1666
noi 2

2 Functions

Rating   Name   Duplication   Size   Complexity  
A ns.init 0 14 1
A _eventHandler.onStackClick 0 15 1
1
(function() {
2
    'use strict';
3
4
    // The namespace
5
    /** @namespace faulancer.core.debugoutput */
6
    var ns = faulancer.namespace('core.debugoutput');
0 ignored issues
show
Bug introduced by
The variable faulancer seems to be never declared. If this is a global, consider adding a /** global: faulancer */ 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...
Unused Code introduced by
The assignment to variable ns seems to be never used. Consider removing it.
Loading history...
7
8
    var _eventHandler = {
9
10
        onStackClick: function() {
11
12
            document.querySelectorAll('.stack').forEach(function(item) {
13
                item.style.display = 'none';
14
            });
15
16
            document.querySelectorAll('.previousStack').forEach(function(item) {
17
                item.classList.remove('selected');
18
            });
19
20
            this.classList.add('selected');
21
22
            document.getElementById(this.dataset.stackIdentifier).style.display = 'block';
23
24
        }
25
26
    };
27
28
    // Public scope
29
    ns = {
30
31
        init: function() {
32
33
            var stacks = document.querySelectorAll('.previousStack');
34
35
            stacks.forEach(function(item, i) {
36
37
                if (i !== 0) {
38
                    item.classList.remove('selected');
39
                }
40
41
                item.addEventListener('click', _eventHandler.onStackClick);
42
            });
43
44
        }
45
46
    };
47
48
    window.addEventListener('load', ns.init());
49
})();
50