Utilisateur:Dereckson/JSconfig.js
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.
Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;
Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5./**
* JSconfig
*
* If you are a gadget author, you may use
* [[MediaWiki:Gadget-SettingsManager.js]] or jquery.jStorage or mediawiki.cookie
* and [[MediaWiki:Gadget-SettingsUI.js]] to provide an easy interface.
*
*
* Global configuration options to enable/disable and configure
* specific script features from [[MediaWiki:Common.js]] and [[MediaWiki:Monobook.js]]
* <s>This framework adds config options (saved as cookies) to [[Special:Preferences]]</s>
* (Site script does not run at [[Special:Preferences]] any more so this functionality has been removed)
*
* For a more permanent change you can override the default settings in your
* [[Special:Mypage/monobook.js]]
* for Example: JSconfig.keys[loadAutoInformationTemplate] = false;
*
* Maintainer: [[User:Dschwen]]
*/
window.JSconfig = {
prefix: 'jsconfig_',
keys: {},
meta: {},
// Register a new configuration item
// * name : String, internal name
// * default_value : String or Boolean (type determines configuration widget)
// * description : String, text appearing next to the widget in the preferences, or an hash-object
// containing translations of the description indexed by the language code
//
// Access keys through JSconfig.keys[name]
registerKey: function (name, default_value, description, prefpage) {
if (JSconfig.keys[name] === undefined) {
JSconfig.keys[name] = default_value;
} else {
// all cookies are read as strings,
// convert to the type of the default value
switch (typeof default_value) {
case 'boolean':
JSconfig.keys[name] = (JSconfig.keys[name] === 'true');
break;
case 'number':
JSconfig.keys[name] = JSconfig.keys[name] / 1;
break;
}
}
JSconfig.meta[name] = {
'description': description[mw.config.get( 'wgUserLanguage' )] || description.en || (typeof description === 'string' && description) || '<i>en</i> translation missing',
'page': prefpage || 0,
'default_value': default_value
};
},
readCookies: function () {
var cookies = document.cookie.split('; ');
var p = JSconfig.prefix.length;
var i;
for (var key = 0; cookies && key < cookies.length; key++) {
if (cookies[key].substring(0, p) === JSconfig.prefix) {
i = cookies[key].indexOf('=');
//alert( cookies[key] + ',' + key + ',' + cookies[key].substring(p,i) );
JSconfig.keys[cookies[key].substring(p, i)] = cookies[key].substring(i + 1);
}
}
},
writeCookies: function () {
var expdate = new Date();
expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * 24 * 3650); // expires in 3560 days
for (var key in JSconfig.keys) {
document.cookie = JSconfig.prefix + key + '=' + JSconfig.keys[key] + '; path=/; expires=' + expdate.toUTCString();
}
}
};
JSconfig.readCookies();