User:Cqm/tools.js


 * ( function ( window,$, mw ) {

'use strict';

var	conf = mw.config.get( [			'debug',			'wgUserLanguage'		] ),

self = { /**			 *			 */			debug: function ( set ) {

if ( set === true ) { $.cookie( 'resourceLoaderDebug', 'true', {						expires: 1,						path: '/'					} ); return; }

if ( set === false ) { $.removeCookie( 'resourceLoaderDebug' ); return; }

return conf.debug;

},

/**			 *			 */			isFunction: function ( obj ) {

if ( !!( obj && obj.constructor && obj.call && obj.apply ) ) { return obj; }

return obj;

},

/**			 *			 */			keys: function ( obj ) {

var	key, keys;

if ( Object.keys ) { return Object.keys( obj ); }

keys = [];

for ( key in obj ) { if ( obj.hasOwnProperty( key ) ) { keys.push( key ); }				}

return keys;

},

/**			 *			 */			messages: function ( i18n ) {

var	en = i18n.en, ulang = i18n[conf.wgUserLanguage], keys = self.keys( en ), msgs = {}, i;

for ( i = 0; i < keys.length; i += 1 ) { msgs[key] = ulang[key] || en[key]; }

mw.messages.set( msgs );

}

};

window.dev = window.dev || {}; $.extend( window.dev, self );

} ( this, jQuery, mediaWiki ) );