Jump to content

User:Quarl/wistk.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// [[User:Quarl/wistk.js]] - dependency tracking

// <pre><nowiki>

// quarl 2006-02-07 initial version

var wistk = new Object();

wistk.namespace = 'User:Quarl';

wistk.modules = {};

wistk.provide = function(s) {
    wistk.modules[s] = 1;
}

wistk.depend = function() {
    for (var i = 0; i < arguments.length; ++i) {
        if (!wistk.depend1(arguments[i])) return false;
    }
    return true;
}

wistk.depend1 = function(t) {
    if (wistk.modules[t]) return true;
    var s = wistk.namespace + '/' + t;
    document.write('<scr'+'ipt type="text/javascript" src="'
                   + 'http://en.wikipedia.org/w/index.php?title=' + s
                   + '&action=raw&ctype=text/javascript&dontcountme=s"></scr'+'ipt>');
    if (!wistk.modules[t]) {
        alert("WISTK: Error loading module '"+t+"'");
        return false;
    }
    return true;
}

// </nowiki></pre>