2014

the whole world is peaceful.

Debuglet

function(scripts, callback, errorback) {
    if (typeof errorback != 'function')
        errorback = function(url) { alert('jsloader load error: ' + url) };

    var cssRegexp = /.css$/;
    var load = function(url) {
        if (cssRegexp.test(url)) {
            var link = document.createElement('link');
            link.href = url;
            link.type = 'text/css';
            link.rel = 'stylesheet';
            (document.getElementsByTagName('head')[0] || document.body).appendChild(link);
            if (scripts.length) {
                load(scripts.shift());
            } else {
                callback();
            }
        } else {
            var script = document.createElement('script');
            script.type = 'text/javascript';
            script.charset = 'utf-8';
            var current_callback;
            if (scripts.length) {
                var u = scripts.shift();
                current_callback = function() { load(u) }
            } else {
                current_callback = callback;
            }
            if (window.ActiveXObject) { // IE
                script.onreadystatechange = function() {
                    if (script.readyState == 'complete' || script.readyState == 'loaded') {
                        current_callback();
                    }
                }
            } else {
                script.onload = current_callback;
                script.onerror = function() { errorback(url) };
            }
            script.src = url;
            document.body.appendChild(script);
        }
    }

    load(scripts.shift());
}

powered by hatena blog.
the nikki system for lifelogging junkies.

all posts © their original owners.
writing is reusable solely under the BY Creative Commons License.