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.
Passed
Push — master ( ba10d9...348b84 )
by Sebastian
03:16
created

javascript/domReady.js   A

Complexity

Total Complexity 18
Complexity/F 1.64

Size

Lines of Code 148
Function Count 11

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
eloc 56
nc 2
dl 0
loc 148
rs 10
c 1
b 0
f 0
wmc 18
mnd 2
bc 23
fnc 11
bpm 2.0909
cpm 1.6363
noi 0

7 Functions

Rating   Name   Duplication   Size   Complexity  
A domReady.js ➔ call 0 11 2
A domReady.js ➔ domReady 0 3 1
A domReady.js ➔ init 0 40 2
A domReady.on 0 11 2
A domReady.params 0 4 1
A domReady.error 0 4 1
A domReady.js ➔ run 0 13 2
1
/**
2
 * domReady
3
 *
4
 * @fileOverview
5
 *    Cross browser object to attach functions that will be called
6
 *    immediatly when the DOM is ready.
7
 *    Released under MIT license.
8
 * @version 3.0.0
9
 * @author Victor Villaverde Laan
10
 * @license MIT  * @link http://www.freelancephp.net/domready-javascript-object-cross-browser/
11
 * @link https://github.com/freelancephp/DOMReady
12
 */
13
(function (window) {
14
15
    'use strict';
16
17
    var document = window.document;
18
    var fns = [];
19
    var args = [];
20
    var isReady = false;
21
    var errorHandler = null;
22
23
    /**
24
     * Call a ready handler
25
     * @private
26
     * @param {function} fn
27
     */
28
    var call = function (fn) {
29
        try {
30
            // call function
31
            fn.apply(this, args);
32
        } catch (e) {
33
            // error occured while executing function
34
            if (errorHandler !== null) {
35
                errorHandler.call(this, e);
36
            }
37
        }
38
    };
39
40
    /**
41
     * Call all ready handlers
42
     * @private
43
     */
44
    var run = function () {
45
        var x;
46
47
        isReady = true;
48
49
        // call all registered functions
50
        for (x = 0; x < fns.length; x = x + 1) {
51
            call(fns[x]);
52
        }
53
54
        // clear handlers
55
        fns = [];
56
    };
57
58
    /**
59
     * Initialize
60
     * @private
61
     */
62
    var init = function () {
63
        if (window.addEventListener) {
64
            // for all browsers except IE
65
            document.addEventListener('DOMContentLoaded', function () {
66
                run();
67
            }, false);
68
        } else {
69
            // for IE
70
            // code taken from http://javascript.nwbox.com/IEContentLoaded/
71
            var poll = function () {
72
                // check IE's proprietary DOM members
73
                if (!document.uniqueID && document.expando) {
74
                    return;
75
                }
76
77
                // you can create any tagName, even customTag like <document :ready />
78
                var tempNode = document.createElement('document:ready');
79
80
                try {
81
                    // see if it throws errors until after ondocumentready
82
                    tempNode.doScroll('left');
83
84
                    // call run
85
                    run();
86
                } catch (e) {
87
                    window.setTimeout(poll, 10);
88
                }
89
            };
90
91
            // trying to always fire before onload
92
            document.onreadystatechange = function () {
93
                if (document.readyState === 'complete') {
94
                    document.onreadystatechange = null;
95
                    run();
96
                }
97
            };
98
99
            poll();
100
        }
101
    };
102
103
    /**
104
     * @namespace domReady
105
     *
106
     * @public
107
     * @param {function} fn
108
     * @return {domReady}
109
     */
110
    var domReady = function (fn) {
111
        return domReady.on(fn);
112
    };
113
114
    /**
115
     * Add code or function to execute when the DOM is ready
116
     * @public
117
     * @param {function} fn
118
     * @return {domReady}
119
     */
120
    domReady.on = function (fn) {
121
        // call imediately when DOM is already ready
122
        if (isReady) {
123
            call(fn);
124
        } else {
125
            // add to the list
126
            fns[fns.length] = fn;
127
        }
128
129
        return this;
130
    };
131
132
    /**
133
     * Set params that will be passed to every ready handler
134
     * @public
135
     * @param {Array.<*>} params
136
     * @return {domReady}
137
     */
138
    domReady.params = function (params) {
139
        args = params;
140
        return this;
141
    };
142
143
    /**
144
     * Set error callback
145
     * @public
146
     * @param {function([Error|string])} fn
147
     * @return {domReady}
148
     */
149
    domReady.error = function (fn) {
150
        errorHandler = fn;
151
        return this;
152
    };
153
154
    // initialize
155
    init();
156
157
    // make global
158
    window.domReady = domReady;
159
160
})(window);
161