User:Asker-Asker/fw.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:Asker-Asker/fw. |
new function()
{
var pathPrefix = "/w/index.php?title=User:";
var pathPostfix = ".js&action=raw&ctype=text/javascript&dontcountme=s";
var interPrefix1 = "http://";
var interPrefix2 = ".wikipedia.org/w/index.php?title=User:";
var ownClassName = "Gerbrant.fw";
var globalScope = window;
var frameworkFunctionsGlobal = true;
// -----------------------------------------------------------------------
this.version = "1.0.1";
this.revision = 1;
var loadingModules = {};
var loadedModules = {};
var thisModule = globalScope;
var bootModules = null;
var ids = ownClassName.split(".");
for(i in ids)
{
id = ids[i];
if(!defined(thisModule[id]))
{
thisModule = null;
break;
}
thisModule = thisModule[id];
}
if(thisModule)
{
if(defined(thisModule.loadModule)) return;
if(defined(thisModule.load))
bootModules = thisModule.load;
}
loadingModules[ownClassName] = [];
function warning(message)
{
alert("Framework warning message:\n\n" + message);
}
function defined(a)
{
return a != undefined;
}
function modulePath(moduleName)
{
return moduleName.replace(/\./g, "/") + pathPostfix;
}
this.loadModule = function(moduleName, callback)
{
var p = moduleName.indexOf(":"), inter;
if(p == -1)
p = pathPrefix;
else
{
inter = moduleName.slice(0, p);
moduleName = moduleName.slice(p + 1);
p = interPrefix1 + inter + interPrefix2;
}
var module = loadedModules[moduleName];
if(defined(module))
{
if(defined(callback)) callback(module);
return;
}
module = loadingModules[moduleName];
if(defined(module))
{
if(defined(callback)) module.push(callback);
return;
}
if(defined(callback)) callback = [callback];
else callback = [];
loadingModules[moduleName] = callback;
document.write("<script src='" + p + modulePath(moduleName) + "'></scr\
ipt>");
}
this.module = function(moduleName, module)
{
var i, ids, id, mid, scope = globalScope;
if(defined(loadedModules[moduleName]))
warning("Module " + moduleName + " is loaded more than once.");
else
{
loadedModules[moduleName] = module;
ids = moduleName.split(".");
mid = ids.pop();
for(i in ids)
{
id = ids[i];
if(!defined(scope[id]))
scope[id] = {};
scope = scope[id];
}
id = scope[mid];
if(defined(id))
for(i in module) id[i] = module[i];
else
scope[mid] = module;
}
var callbacks = loadingModules[moduleName];
delete loadingModules[moduleName];
if(defined(callbacks))
for(i in callbacks)
if(typeof callbacks[i] == "function")
callbacks[i](module, moduleName);
else
warning("One of the callbacks registered for " +
moduleName + " is not a function:\n" + callbacks[i]);
else
warning("Module " + moduleName + " finished loading without request.");
}
this.loadModules = function(moduleNames, callback)
{
var n = moduleNames.length, moduleList = {}, f;
if(defined(callback))
f = function(module, moduleName)
{
moduleList[moduleName] = module;
if(--n == 0) callback(moduleList);
};
for(i in moduleNames) loadModule(moduleNames[i], f);
}
if(frameworkFunctionsGlobal)
{
module = this.module;
loadModule = this.loadModule;
loadModules = this.loadModules;
}
this.module(ownClassName, this);
if(defined(bootModules)) this.loadModules(bootModules);
};