The initial version is fairly straightforward (but it is far from ready for deployment at this stage). The basic overview of usage would be:
1. The main module would be put into MediaWiki:Gadget-jsprefs.js (however, it should not be added to MediaWiki:Gadgets-definition, so possibly a less ambiguous name should be chosen).
2. Any script that will utilize the variable system should load that script via document.write (importScript() will not work) , as well as define some variables (prefixed with "scriptname-", eg:
if (window.jsPrefsSettable) { jsPrefsSettable[jsPrefsSettable.length] = { 'name': 'navpopups-enablesomeoption', 'desc': 'enable foobarbaz', 'type': 'boolean', 'defval': true}; }
3. The script should then check the state of the options via eg: getjsPref('navpopups-enablesomeoption')
. This first test tells if the option is defined. If defined, a second test comparing the actual contents is then done. Note that getjsPref() works with a literal cookie name, *or* with an attribute of the jsPrefs object. So for example this same option could be hard-coded via jsPrefs['navpopups-enablesomeoption'] = true;
in the user/skin.js as an alterative (for users with multiple browsers or workstations).
4. If a user loads that script, they will see a a link in their toolbox for configuring various JS options. From there they can enable/disable options via cookie (or change string or number values, such as a default edit summary or block reason for batch jobs), and helpful instructions (eventually) on how to set the variable in user/skin.js
if(!window.jsPrefs) var jsPrefs = []; if(!window.jsPrefsSettable) var jsPrefsSettable = [];
The test.wikipedia has two bare-bones gadgets in MediaWiki:Gadgets-definition, which utilize this initial version. You can create a user, go to prefernces, and enable test 1 (an alert test, bit annoying) or test 2 (a [google] button adder), and then fiddle with your "Script preferences" in the toolbox).
Worth pursuing any further? --Splarka (rant) 04:59, 29 December 2007 (UTC)