Completed
Push — master ( b76d2e...071101 )
by Askupa
02:04
created

assets/js/src/core.js   A

Complexity

Total Complexity 8
Complexity/F 1.33

Size

Lines of Code 38
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

2 Functions

Rating   Name   Duplication   Size   Complexity  
B exports.settings.init 0 29 1
A $(document).ready 0 3 1
1
var $ = window.jQuery;
2
3
exports.settings = {
4
    haveBeenModified: false,
5
    init: function() {
6
        
7
        Amarkal.settings.fields.init();
0 ignored issues
show
Bug introduced by
The variable Amarkal seems to be never declared. If this is a global, consider adding a /** global: Amarkal */ 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...
8
        Amarkal.settings.search.init();
9
        Amarkal.settings.sections.init();
10
11
        $('.amarkal-ui-component').on('amarkal.change',function(e, component){
12
            Amarkal.settings.notifier.notice("Settings have changed, click \"Save\" to apply them.");
0 ignored issues
show
Bug introduced by
The variable Amarkal seems to be never declared. If this is a global, consider adding a /** global: Amarkal */ 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...
13
            Amarkal.settings.sections.flag('notice', component.props.section);
14
            Amarkal.settings.fields.flag('notice', component.props.name);
15
            Amarkal.settings.haveBeenModified = true;
16
        }).on('amarkal.hide', function(){
17
            Amarkal.settings.fields.hide($(this).parents('.amarkal-settings-field'));
0 ignored issues
show
Bug introduced by
The variable Amarkal seems to be never declared. If this is a global, consider adding a /** global: Amarkal */ 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...
18
        }).on('amarkal.show', function(){
19
            if($(this).parents('.amarkal-settings-field').attr('data-section') === Amarkal.settings.sections.activeSection) {
0 ignored issues
show
Bug introduced by
The variable Amarkal seems to be never declared. If this is a global, consider adding a /** global: Amarkal */ 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...
20
                Amarkal.settings.fields.show($(this).parents('.amarkal-settings-field'));
21
            }
22
        });
23
24
        // This is called after the onChange/hide/show event listeners are added since some events
25
        // are triggered when the form is instantiated
26
        $('#amarkal-settings-form').amarkalUIForm();
27
28
        $(window).on('beforeunload',function(){
29
            if(Amarkal.settings.haveBeenModified) {
0 ignored issues
show
Bug introduced by
The variable Amarkal seems to be never declared. If this is a global, consider adding a /** global: Amarkal */ 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...
Complexity Best Practice introduced by
There is no return statement if Amarkal.settings.haveBeenModified is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
30
                return 'Are you sure you want to leave this page?';
31
            }
32
        });
33
    }
34
};
35
36
$(document).ready(function(){
37
    Amarkal.settings.init();
0 ignored issues
show
Bug introduced by
The variable Amarkal seems to be never declared. If this is a global, consider adding a /** global: Amarkal */ 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...
38
});
39