From 7d7145f82a5c7244175d355ca94b5948151e16c3 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sun, 11 Oct 2009 19:39:18 +0000 Subject: [PATCH] Remove trailing whitespace from some JS2 files. These are just the worst offenders --- js2/editPage.js | 14 +- js2/mwEmbed/mv_embed.js | 438 +++++++++++++++---------------- js2/mwEmbed/skins/ctrlBuilder.js | 238 ++++++++--------- js2/remoteMwEmbed.js | 34 +-- 4 files changed, 362 insertions(+), 362 deletions(-) diff --git a/js2/editPage.js b/js2/editPage.js index 364f9b2106..290589d1a5 100644 --- a/js2/editPage.js +++ b/js2/editPage.js @@ -1,9 +1,9 @@ /* * JS2-style replacement for MediaWiki edit.js - * (right now it just supports the toolbar) + * (right now it just supports the toolbar) */ -// Setup configuration vars (if not set already) +// Setup configuration vars (if not set already) if( !mwAddMediaConfig ) var mwAddMediaConfig = {}; @@ -15,28 +15,28 @@ var defaultAddMediaConfig = { 'default_query': wgTitle, 'target_title': wgPageName, // Here we can setup the content provider overrides - 'enabled_cps':['wiki_commons'], + 'enabled_cps':['wiki_commons'], // The local wiki API URL: 'local_wiki_api_url': wgServer + wgScriptPath + '/api.php' }; - + js2AddOnloadHook( function() { var amwConf = $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig ); // kind of tricky, it would be nice to use run on ready "loader" call here if( typeof $j.wikiEditor != 'undefined' ) { - setTimeout( function() { + setTimeout( function() { $j( '.wikiEditor-ui [rel=file]' ).unbind().addMediaWiz( amwConf ); }, 100 ); } - //add to the old-toolbar all the time: + //add to the old-toolbar all the time: if( $j('#btn-add-media-wiz').length == 0 ){ $j( '#toolbar' ).append( '' ); $j( '#btn-add-media-wiz' ).addMediaWiz( amwConf ); - } + } }); diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index fd2af28ecc..41242e42eb 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -19,12 +19,12 @@ var MV_DO_INIT=true; if( MV_EMBED_VERSION ){ MV_DO_INIT=false; } -// Used to grab fresh copies of scripts. +// Used to grab fresh copies of scripts. var MV_EMBED_VERSION = '1.0r20'; /* * Configuration variables should be set by extending mwConfigOptions - * here is the default config: + * here is the default config: */ var mwDefaultConfig = { 'skin_name': 'mvpcf', @@ -70,10 +70,10 @@ parseUri.options = { // For use when mv_embed with script-loader is in the root MediaWiki path var mediaWiki_mvEmbed_path = 'js2/mwEmbed/'; -var _global = this; // Global obj (depreciate use window) +var _global = this; // Global obj (depreciate use window) /* -* setup the empty global $mw object +* setup the empty global $mw object * will ensure all our functions are properly namespaced */ if(!window['$mw']){ @@ -94,35 +94,35 @@ if( !mv_embed_path ) { * wrap the global $mw object here: * * Any global functions/classes that are not jQuery plugins should make -* there way into the $mw namespace +* there way into the $mw namespace */ (function( $ ) { /* * Language classes $mw.lang - * + * * Localized Language support attempts to mirror the functionality of Language.php in MediaWiki * It contains methods for loading and transforming msg text - * + * */ $.lang = {}; /** * Setup the lang object */ var gMsg = {}; - var gRuleSet = {}; - + var gRuleSet = {}; + /** * loadGM function - * Loads a set of json messages into the lng object. + * Loads a set of json messages into the lng object. * - * @param json msgSet The set of msgs to be loaded + * @param json msgSet The set of msgs to be loaded */ $.lang.loadGM = function( msgSet ){ for( var i in msgSet ) { gMsg[ i ] = msgSet[i]; } }, - + /** * loadRS function * Loads a ruleset by given template key ie PLURAL : { //ruleSetObj } @@ -134,55 +134,55 @@ if( !mv_embed_path ) { gRuleSet[ i ] = ruleSet[ i ]; } } - + /** * Returns a transformed msg string * * it take a msg key and array of replacement values of form - * $1, $2 and does relevant msgkey transformation returning - * the user msg. + * $1, $2 and does relevant msgkey transformation returning + * the user msg. * * @param string key The msg key as set by loadGm * @param [mixed] args An array of replacement strings - * @return string + * @return string */ - $.lang.gM = function( key , args ) { + $.lang.gM = function( key , args ) { if(! gMsg[ key ]) return '<' + key + '>';// Missing key placeholder - + //swap in the arg values - var ms = $.lang.gMsgSwap( key, args) ; - + var ms = $.lang.gMsgSwap( key, args) ; + //a quick check to see if we need to send the msg via the 'parser' //(we can add more detailed check once we support more wiki syntax) if(ms.indexOf('{{')==-1){ return ms; //return ms; } - - //make sure we have the lagMagic setup: + + //make sure we have the lagMagic setup: $.lang.magicSetup(); - //send the msg key through the parser + //send the msg key through the parser pObj = $.parser.pNew( ms ); //return the transformed msg - return pObj.getHTML(); + return pObj.getHTML(); } /** * gMsgSwap - * + * * @param string key The msg key as set by loadGm * @param [mixed] args An array or string to be replaced - * @return string + * @return string */ $.lang.gMsgSwap = function( key , args ){ if(! gMsg[ key ]) return '<' + key + '>';// Missing key placeholder //get the messege string: var ms = gMsg[ key ]; - - //replace values + + //replace values if( typeof args == 'object' || typeof args == 'array' ) { - for( var v in args ) { + for( var v in args ) { // Message test replace arguments start at 1 instead of zero: var rep = new RegExp('\\$'+ ( parseInt(v) + 1 ), 'g'); ms = ms.replace( rep, args[v] ); @@ -192,70 +192,70 @@ if( !mv_embed_path ) { } return ms; } - + /** * gMsgNoTrans - * + * * @returns string The msg key without transforming it */ $.lang.gMsgNoTrans = function( key ){ if( gMsg[ key ] ) return gMsg[ key ] - + // Missing key placeholder return '<' + key + '>'; } /** - * Add Supported Magic Words to parser + * Add Supported Magic Words to parser */ //set the setupflag to false: - $.lang.doneSetup=false; + $.lang.doneSetup=false; $.lang.magicSetup = function(){ if(!$.lang.doneSetup){ $.parser.addMagic ( { 'PLURAL' : $.lang.procPLURAL }) - + $.lang.doneSetup = true; } - + } /** * Process the PLURAL special language template key: */ $.lang.procPLURAL = function( tObj ){ - //setup shortcuts + //setup shortcuts // (gRuleSet is loaded from script-loader to contains local ruleset) - var rs = gRuleSet['PLURAL']; - + var rs = gRuleSet['PLURAL']; + /* * Plural matchRuleTest */ function matchRuleTest(cRule, val){ js_log("matchRuleTest:: " + typeof cRule + ' ' + cRule + ' == ' + val ); - + function checkValue(compare, val){ if(typeof compare == 'string'){ - range = compare.split('-'); + range = compare.split('-'); if( range.length >= 1 ){ if( val >= range[0] && val <= range[1] ) - return true; + return true; } } //else do a direct compare if(compare == val){ - return true; + return true; } return false; - } + } //check for simple cRule type: - if( typeof cRule == 'number'){ - return ( parseInt( val ) == parseInt( cRule) ); + if( typeof cRule == 'number'){ + return ( parseInt( val ) == parseInt( cRule) ); }else if( typeof cRule == 'object' ){ - var cmatch = {}; + var cmatch = {}; //if a list we need to match all for rule match for(var i in cRule){ - var cr = cRule[i]; + var cr = cRule[i]; //set cr type var crType = ''; for( var j in cr ){ @@ -264,9 +264,9 @@ if( !mv_embed_path ) { } switch(crType){ case 'mod': - if( cr ['is'] ){ + if( cr ['is'] ){ if( checkValue( val % cr['mod'], cr ['is'] ) ) - cmatch[i] = true; + cmatch[i] = true; }else if( cr['not']){ if( ! checkValue( val % cr['mod'], cr ['not'] ) ) cmatch[i] = true; @@ -274,46 +274,46 @@ if( !mv_embed_path ) { break; } } - //check all the matches (taking into consideration "or" order) - for(var i in cRule){ + //check all the matches (taking into consideration "or" order) + for(var i in cRule){ if( ! cmatch[i] ) - return false; + return false; } return true; - + } } /** * Maps a given rule Index to template params: - * + * * if index is out of range return last param - * @param - */ - function getTempParamFromRuleInx(tObj, ruleInx ){ + * @param + */ + function getTempParamFromRuleInx(tObj, ruleInx ){ //js_log('getTempParamFromRuleInx: ruleInx: ' + ruleInx + ' tempParamLength ' + tObj.param.length ); if( ruleInx >= tObj.param.length ) return tObj.param[ tObj.param.length -1 ]; //else return the requested index: return tObj.param[ ruleInx ]; - } + } var rCount=0 - //run the actual rule lookup: + //run the actual rule lookup: for(var ruleInx in rs){ - cRule = rs[ruleInx]; + cRule = rs[ruleInx]; if( matchRuleTest( cRule, tObj.arg ) ){ - js_log("matched rule: " + ruleInx ); - return getTempParamFromRuleInx(tObj, rCount ); + js_log("matched rule: " + ruleInx ); + return getTempParamFromRuleInx(tObj, rCount ); } rCount ++; - } + } js_log('no match found for: ' + tObj.arg + ' using last/other : ' + tObj.param [ tObj.param.length -1 ] ); - //return the last /"other" template param - return tObj.param [ tObj.param.length -1 ]; - } - + //return the last /"other" template param + return tObj.param [ tObj.param.length -1 ]; + } + /** * gMsgLoadRemote loads remote msg strings - * + * * @param mixed msgSet the set of msg to load remotely * @param function callback the callback to issue once string is ready */ @@ -327,7 +327,7 @@ if( !mv_embed_path ) { ammessages += msgSet; } if( ammessages == '' ) { - js_log( 'gMsgLoadRemote: no message set requested' ); + js_log( 'gMsgLoadRemote: no message set requested' ); return false; } do_api_req({ @@ -382,95 +382,95 @@ if( !mv_embed_path ) { //@@todo we need a formatNum and we need to request some special packaged info to deal with that case. return gM( msg , size ); }; - - + + /** * MediaWiki wikitext "Parser" * - * This is not feature complete but we need a way to get at template properties - * - * + * This is not feature complete but we need a way to get at template properties + * + * * @param wikiText the wikitext to be parsed - * @return parserObj returns a parser object that has methods for getting at - * things you would want - */ + * @return parserObj returns a parser object that has methods for getting at + * things you would want + */ $.parser = {}; var pMagicSet = {}; /** - * parser addMagic - * + * parser addMagic + * * lets you add a set of magic keys and associated callback funcions - * callback: @param ( Object Template ) + * callback: @param ( Object Template ) * callback: @return the transformed template output - * + * * @param object magicSet key:callback */ $.parser.addMagic = function( magicSet ){ for(var i in magicSet) pMagicSet[ i ] = magicSet[i]; } - + //actual parse call (returns parser object) $.parser.pNew = function( wikiText, opt ){ var parseObj = function( wikiText, opt){ return this.init( wikiText, opt ) - } + } parseObj.prototype = { //the wikiText "DOM"... stores the parsed wikiText structure //wtDOM : {}, (not yet supported ) - - pOut : '', //the parser output string container + + pOut : '', //the parser output string container init :function( wikiText ){ - this.wikiText = wikiText; + this.wikiText = wikiText; }, updateText : function( wikiText ){ this.wikiText = wikiText; - //invalidate the output (will force a reparse) - this.pOut = ''; + //invalidate the output (will force a reparse) + this.pOut = ''; }, - parse : function(){ + parse : function(){ this.pObj = {}; this.pObj.tmpl = new Array(); - - //refrences for swap key + + //refrences for swap key this.pObj.tmpl_text = new Array(); - this.pObj.tmpl_key = new Array(); - this.pObj.tmpl_ns = '' ; // wikiText with place-holder - + this.pObj.tmpl_key = new Array(); + this.pObj.tmpl_ns = '' ; // wikiText with place-holder + //get templates losly based on Magnus_Manske/tmpl.js code: var tcnt = 0 ; - var ts = '' ; + var ts = '' ; var curt = 0 ; - var schar = 0; - - + var schar = 0; + + //build out nested template holders: var depth = 0; - var tKey = 0; - var ns = ''; - + var tKey = 0; + var ns = ''; + /* * quickly recursive / parse out templates with top down recurse decent - */ - + */ + // ~ probably a better algorithm out there / should mirror php parser flow ~ - // ... but I am having fun with recursion so here it is... - function rdpp ( txt ){ + // ... but I am having fun with recursion so here it is... + function rdpp ( txt ){ var node = {}; //if we should output node text - var ont = true; - //inspect each char - for(var a=0; a < txt.length; a++){ + var ont = true; + //inspect each char + for(var a=0; a < txt.length; a++){ if( txt[a] == '{' && txt[a+1] == '{' ){ a=a+2; - node['p'] = node; + node['p'] = node; if(!node['c']) node['c'] = new Array(); - - node['c'].push( rdpp( txt.substr( a ) ) ); - ont=true; + + node['c'].push( rdpp( txt.substr( a ) ) ); + ont=true; }else if( txt[a] == '}' && txt[a+1] == '}'){ - if( !node['p'] ){ + if( !node['p'] ){ return node; } node = node['p']; @@ -484,37 +484,37 @@ if( !mv_embed_path ) { node['t']+=txt[a]; } return node; - } + } /** * parse template text as template name and named params */ function parseTmplTxt( ts ){ var tObj = {}; - //Get template name: + //Get template name: tname = ts.split('\|').shift() ; - tname = tname.split('\{').shift() ; - tname = tname.replace( /^\s+|\s+$/g, "" ); //trim - - //check for arguments: - if( tname.split(':').length == 1 ){ + tname = tname.split('\{').shift() ; + tname = tname.replace( /^\s+|\s+$/g, "" ); //trim + + //check for arguments: + if( tname.split(':').length == 1 ){ tObj["name"] = tname; }else{ tObj["name"] = tname.split(':').shift(); tObj["arg"] = tname.split(':').pop(); } - - js_log("TNAME::" + tObj["arg"] + ' from:: ' + ts); - + + js_log("TNAME::" + tObj["arg"] + ' from:: ' + ts); + var pSet = ts.split('\|'); - pSet.splice(0,1); - if( pSet.length ){ + pSet.splice(0,1); + if( pSet.length ){ tObj.param = new Array(); for(var pInx in pSet){ var tStr = pSet[ pInx ]; for(var b=0 ; b < tStr.length ; b++){ if(tStr[b] == '=' && b>0 && bhtml-ish output without re-parsing anything + * Then in output time you just go DOM->html-ish output without re-parsing anything */ getHTML : function(){ //wikiText updates should invalidate pOut if( this.pOut == ''){ this.parse(); } - return this.pOut; + return this.pOut; } }; //return the parserObj return new parseObj( wikiText, opt) ; - } - + } + })(window.$mw); -//setup legacy global shortcuts: +//setup legacy global shortcuts: var loadGM = $mw.lang.loadGM; var loadRS = $mw.lang.loadRS; var gM = $mw.lang.gM; -//if some no-js2 script defined and loaded gMsg in global space: +//if some no-js2 script defined and loaded gMsg in global space: if( _global['gMsg'] ){ loadGM( _global['gMsg'] ); } @@ -838,11 +838,11 @@ var mvJsLoader = { coma = ','; } } - //Build the url to the scriptServer striping its request paramaters: + //Build the url to the scriptServer striping its request paramaters: var puri = parseUri( getMvEmbedURL() ); if( ( getMvEmbedURL().indexOf('://') != -1 ) && puri.host != parseUri( document.URL ).host ) - { + { var scriptPath = puri.protocol + '://' + puri.authority + puri.path; }else{ var scriptPath = puri.path; @@ -870,10 +870,10 @@ var mvJsLoader = { this.callbacks.push( callback ); } if( this.checkLoading() ) { - //@@todo we should check the