templates/pnotify/alert.js   A
last analyzed

Complexity

Total Complexity 8
Complexity/F 1.14

Size

Lines of Code 40
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 28
c 0
b 0
f 0
dl 0
loc 40
rs 10
wmc 8
mnd 1
bc 1
fnc 7
bpm 0.1428
cpm 1.1428
noi 11
1
jaxon.dialogs.pnotify = {
0 ignored issues
show
Bug introduced by
The variable jaxon seems to be never declared. If this is a global, consider adding a /** global: jaxon */ 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...
2
    alert: function(data) {
3
        notice = new PNotify(data);
0 ignored issues
show
Bug introduced by
The variable notice seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.notice.
Loading history...
Bug introduced by
The variable PNotify seems to be never declared. If this is a global, consider adding a /** global: PNotify */ 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...
4
        notice.get().click(function(){notice.remove();});
5
    },
6
    success: function(content, title) {
7
        jaxon.dialogs.pnotify.alert({text: content, title: title, type: 'success'});
0 ignored issues
show
Bug introduced by
The variable jaxon seems to be never declared. If this is a global, consider adding a /** global: jaxon */ 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
    },
9
    info: function(content, title) {
10
        jaxon.dialogs.pnotify.alert({text: content, title: title, type: 'info'});
0 ignored issues
show
Bug introduced by
The variable jaxon seems to be never declared. If this is a global, consider adding a /** global: jaxon */ 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...
11
    },
12
    warning: function(content, title) {
13
        jaxon.dialogs.pnotify.alert({text: content, title: title, type: 'notice'});
0 ignored issues
show
Bug introduced by
The variable jaxon seems to be never declared. If this is a global, consider adding a /** global: jaxon */ 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...
14
    },
15
    error: function(content, title) {
16
        jaxon.dialogs.pnotify.alert({text: content, title: title, type: 'error'});
0 ignored issues
show
Bug introduced by
The variable jaxon seems to be never declared. If this is a global, consider adding a /** global: jaxon */ 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...
17
    },
18
    confirm: function(question, title, yesCallback, noCallback) {
19
        PNotify.prototype.options.confirm.buttons[0].text = "<?php echo $this->yes ?>";
0 ignored issues
show
Bug introduced by
The variable PNotify seems to be never declared. If this is a global, consider adding a /** global: PNotify */ 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
        PNotify.prototype.options.confirm.buttons[1].text = "<?php echo $this->no ?>";
21
        notice = new PNotify({
0 ignored issues
show
Bug introduced by
The variable notice seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.notice.
Loading history...
22
            title: title,
23
            text: question,
24
            hide: false,
25
            confirm:{
26
                confirm: true
27
            },
28
            buttons:{
29
                closer: false,
30
                sticker: false,
31
                labels: {
32
33
                }
34
            }
35
        });
36
        notice.get().on("pnotify.confirm", yesCallback);
37
        if(noCallback != undefined)
0 ignored issues
show
Best Practice introduced by
Comparing noCallback to undefined using the != operator is not safe. Consider using !== instead.
Loading history...
38
            notice.get().on("pnotify.cancel", noCallback);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
39
    }
40
};
41