User talk:Gerbrant/fw.js
Appearance
- Gerbrant.fw
- Since this is the actual module loader, it cannot be loaded using the id above.
- Usage:
document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Gerbrant/fw.js&action=raw&ctype=text/javascript&dontcountme=s"><\u002fscript>');
- A template {{User:Gerbrant/fwNotice}} is available; it displays:
Installation
[edit]This script will only work in conjunction with Gerbrant.fw (documentation). If you're already using it, just add
"module id"
to the start of the list of modules to load, otherwise paste the following in yourmonobook.js
: Gerbrant = {fw: {load: ["module id"
]}}
mw.loader.load("http://en.wikipedia.org/w/index.php?title=User:Gerbrant/fw.js&action=raw&ctype=text/javascript");
- The first parameter will replace module id above, the optional second parameter will replace everything before "in conjunction".
Exports
[edit]- module(moduleName, moduleObject)
- Called by a module that exports stuff. moduleName is the full id of a module, moduleObject is the object that contains all the exported stuff.
module("user.someModule", new function() { ... };
– or, when a module is dependent on another module –
... loadModule("user.otherModule", function() { ... module("user.someModule", obj); }; ...
- loadModule(moduleName, callback)
- Loads the module identified by moduleName. If the module contains a module-call, the callback will be called when the module is ready to be used.
- Syntax: myCallbackFunction(moduleObject, moduleName)
- Note that both arguments supplied to the callback are just a convenience and not really necessary.
- loadModules([moduleName, ...], callback)
- Load multiple modules.
- version
- The version of this module as a string.
- revision
- The revision number – will be incremented every time something changes.
Settings
[edit]- load
- An array of full id's (names) of modules to load when this script is included. Modules loaded this way are guaranteed to have the functions exported by this module available.
Gerbrant = {fw: {load: [ "user.someScript", ... ]}}