GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Resources/public/js/flash.js   A
last analyzed

Complexity

Total Complexity 20
Complexity/F 2.86

Size

Lines of Code 82
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 0
nc 2
dl 0
loc 82
rs 10
c 3
b 0
f 0
wmc 20
mnd 2
bc 12
fnc 7
bpm 1.7142
cpm 2.8571
noi 5

4 Functions

Rating   Name   Duplication   Size   Complexity  
A $.extend.clearMessage 0 10 1
D $.extend.message 0 34 9
A $(document).pjax:error 0 5 2
A $(document).pjax:beforeReplace 0 13 3
1
(function ($, app) {
2
    'use strict';
3
4
    $.extend(app, {
5
        PJAX_FLASH_CONTAINER: '.notification-container',
6
        PJAX_FLASH: 'pjax-flashes',
7
        PJAX_FLASH_SELECTOR: '[data-pjax-flashes]',
8
9
        MESSAGE_SUCCESS: 0,
10
        MESSAGE_ERROR: 1,
11
        MESSAGE_WARNING: 2,
12
        MESSAGE_NOTICE: 3,
13
14
        message: function (text, status) {
15
            this.clearMessage();
16
            if (!status) {
17
                status = this.MESSAGE_SUCCESS;
18
            }
19
20
            var msgbox = $('<div></div>').appendTo(app.PJAX_FLASH_CONTAINER);
21
            msgbox.addClass('alert');
22
            msgbox.hide();
23
            msgbox.text(text);
24
            switch (status) {
0 ignored issues
show
Coding Style introduced by
As per coding-style, switch statements should have a default case.
Loading history...
25
                case this.MESSAGE_SUCCESS :
26
                case 'success' :
27
                    msgbox.addClass('alert-success');
28
                    break;
29
                case this.MESSAGE_NOTICE :
30
                case 'notice' :
31
                    msgbox.addClass('alert-info');
32
                    break;
33
                case this.MESSAGE_WARNING :
34
                    msgbox.addClass('alert-warning');
35
                    msgbox.html('<i class="icon-warning-sign"></i> ' + msgbox.text());
36
                    break;
37
                case this.MESSAGE_ERROR :
38
                case 'error' :
39
                    msgbox.addClass('alert-danger');
40
                    msgbox.html('<i class="icon-erroralt"></i> ' + msgbox.text());
41
                    break;
42
            }
43
44
            msgbox.data("time", new Date());
45
            msgbox.fadeIn(500);
46
47
        },
48
49
        clearMessage: function () {
50
            $(app.PJAX_FLASH_CONTAINER + ' > div').each(function () {
51
                var time = $(this).data("time");
52
                if (!time || (new Date() - time >= 5 * 1000)) {
53
                    $(this).fadeOut(1000, function () {
54
                        $(this).html("");
55
                    });
56
                }
57
            });
58
        }
59
    });
60
61
    $(document)
62
        .on('pjax:send', app.clearMessage)
63
        .on('pjax:error', function (event, xhr, textStatus, error, options) {
0 ignored issues
show
Unused Code introduced by
The parameter options 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...
Unused Code introduced by
The parameter error 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...
64
            if ('abort' !== textStatus) {
65
                app.message('Error', app.MESSAGE_ERROR);
66
            }
67
        })
68
        .on('pjax:beforeReplace', function (event, contents, options) {
0 ignored issues
show
Unused Code introduced by
The parameter options 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...
69
            var tmp = $('<div></div>');
70
            tmp.html(contents);
71
            var flashes = $(app.PJAX_FLASH_SELECTOR, tmp);
72
            if (flashes) {
73
                var flashData = flashes.data(app.PJAX_FLASH);
74
                if (flashData) {
75
                    $(app.PJAX_FLASH_CONTAINER).html(flashData);
76
                }
77
                flashes.removeData(app.PJAX_FLASH);
78
                flashes.removeAttr('data-' + app.PJAX_FLASH);
79
            }
80
        });
81
82
})(jQuery, application);
0 ignored issues
show
Bug introduced by
The variable application seems to be never declared. If this is a global, consider adding a /** global: application */ 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...
83