PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/ajax/scripts/signal.js

http://showslow.googlecode.com/
JavaScript | 43 lines | 33 code | 2 blank | 8 comment | 17 complexity | cb4b26852f1b5736440c1d3c5364cb2d MD5 | raw file
 1/*==================================================
 2 *  This file is used to detect that all outstanding
 3 *  javascript files have been loaded. You can put
 4 *  a function reference into SimileAjax_onLoad
 5 *  to have it executed once all javascript files
 6 *  have loaded.
 7 *==================================================
 8 */
 9(function() {
10    var substring = SimileAjax.urlPrefix + "scripts/signal.js";
11    var heads = document.documentElement.getElementsByTagName("head");
12    for (var h = 0; h < heads.length; h++) {
13        var node = heads[h].firstChild;
14        while (node != null) {
15            if (node.nodeType == 1 && node.tagName.toLowerCase() == "script") {
16                var url = node.src;
17                var i = url.indexOf(substring);
18                if (i >= 0) {
19                    heads[h].removeChild(node); // remove it so we won't hit it again
20
21                    var count = parseInt(url.substr(url.indexOf(substring) + substring.length + 1));
22                    SimileAjax.loadingScriptsCount -= count;
23                    if (SimileAjax.loadingScriptsCount == 0) {
24                        var f = null;
25                        if (typeof SimileAjax_onLoad == "string") {
26                            f = eval(SimileAjax_onLoad);
27                            SimileAjax_onLoad = null;
28                        } else if (typeof SimileAjax_onLoad == "function") {
29                            f = SimileAjax_onLoad;
30                            SimileAjax_onLoad = null;
31                        }
32                        
33                        if (f != null) {
34                            f();
35                        }
36                    }
37                    return;
38                }
39            }
40            node = node.nextSibling;
41        }
42    }
43})();