From: Michael Dale Date: Thu, 12 Nov 2009 17:19:05 +0000 (+0000) Subject: * some minor refactoring and comment clean up X-Git-Tag: 1.31.0-rc.0~38841 X-Git-Url: https://git.cyclocoop.org/admin/?a=commitdiff_plain;h=7eaff1e0016cae5181161071443dc90b60847983;p=lhc%2Fweb%2Fwiklou.git * some minor refactoring and comment clean up --- diff --git a/js2/mwEmbed/jsScriptLoader.php b/js2/mwEmbed/jsScriptLoader.php index bc3ed7aae8..9dbc754cc0 100644 --- a/js2/mwEmbed/jsScriptLoader.php +++ b/js2/mwEmbed/jsScriptLoader.php @@ -58,7 +58,7 @@ class jsScriptLoader { $this->sFileCache->getCacheFileName(); // Setup script loader header info - // @@todo we might want to put these into the $mw var per class request set + // @@todo we might want to put these into the mw var per class request set // and or include a callback to avoid pulling in old browsers that don't support // the onLoad attribute for script elements. $this->jsout .= 'var mwSlScript = "' . $_SERVER['SCRIPT_NAME'] . '";' . "\n"; diff --git a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js index e5ad36ea2f..6442b5cf84 100644 --- a/js2/mwEmbed/libAddMedia/remoteSearchDriver.js +++ b/js2/mwEmbed/libAddMedia/remoteSearchDriver.js @@ -259,6 +259,10 @@ remoteSearchDriver.prototype = { //@@todo for cleaner config we should set _this.opt to the provided options) $j.extend( _this, default_remote_search_options, options); + //Quick fix for cases where people put ['all'] instead of 'all' for enabled_cps + if( _this.enabled_cps.length == 1 && _this.enabled_cps[0] == 'all') + _this.enabled_cps = 'all'; + //modify the content provider config based on options: for(var i in this.content_providers){ if( _this.enabled_cps == 'all' && !this.disp_item ){ @@ -266,7 +270,7 @@ remoteSearchDriver.prototype = { //end the for loop (no need to idorate if enabled_cps == 'all' break; }else{ - if( $j.inArray(i, _this.enabled_cps) != -1 ){ + if( $j.inArray( i, _this.enabled_cps ) != -1 ){ //if no default display set to first enabled cp: if( !this.disp_item ) this.disp_item = i; @@ -687,7 +691,7 @@ remoteSearchDriver.prototype = { }, runSearch: function( restPage ){ js_log("f:runSearch::" + this.disp_item); - //draw_direct_flag + var draw_direct_flag = true; //check if its the special upload tab case: @@ -711,7 +715,7 @@ remoteSearchDriver.prototype = { draw_direct_flag = false; } if( !draw_direct_flag ){ - //see if we should reset the pageing + //see if we should reset the paging if( restPage ){ cp.sObj.offset = cp.offset = 0; } @@ -719,22 +723,22 @@ remoteSearchDriver.prototype = { //set the content to loading while we do the search: $j('#tab-' + this.disp_item).html( mv_get_loading_img() ); - //make sure the search library is loaded and issue the search request + // Make sure the search library is loaded and issue the search request this.getLibSearchResults( cp ); } }, - //issue a api request & cache the result - //this check can be avoided by setting the this.import_url_mode = 'api' | 'form' | instead of 'autodetect' or 'none' + // Issue a api request & cache the result + // this check can be avoided by setting the this.import_url_mode = 'api' | 'form' | instead of 'autodetect' or 'none' checkForCopyURLSupport:function ( callback ){ var _this = this; js_log('checkForCopyURLSupport:: '); - //see if we already have the import mode: + // See if we already have the import mode: if( this.import_url_mode != 'autodetect'){ js_log('import mode: ' + _this.import_url_mode); callback(); } - //if we don't have the local wiki api defined we can't auto-detect use "link" + // If we don't have the local wiki api defined we can't auto-detect use "link" if( ! _this.upload_api_target ){ js_log('import mode: remote link (no import_wiki_api_url)'); _this.import_url_mode = 'remote_link'; @@ -742,8 +746,11 @@ remoteSearchDriver.prototype = { } if( this.import_url_mode == 'autodetect' ){ do_api_req( { - 'data': { 'action':'paraminfo', 'modules':'upload' }, - 'url': _this.upload_api_target + 'url': _this.upload_api_target, + 'data': { + 'action':'paraminfo', + 'modules':'upload' + } }, function(data){ //jump right into api checks: for( var i in data.paraminfo.modules[0].parameters ){ @@ -812,7 +819,7 @@ remoteSearchDriver.prototype = { return false; } _this.loadSearchLib(cp, function(){ - //do search + // Do the search cp.sObj.getSearchResults(); _this.checkResultsDone(); }); diff --git a/js2/mwEmbed/libClipEdit/mvClipEdit.js b/js2/mwEmbed/libClipEdit/mvClipEdit.js index d3cd5ac13d..0a3fe88644 100644 --- a/js2/mwEmbed/libClipEdit/mvClipEdit.js +++ b/js2/mwEmbed/libClipEdit/mvClipEdit.js @@ -153,11 +153,12 @@ mvClipEdit.prototype = { //if media type is template we have to query to get its URI to get its parameters if(_this.media_type == 'template' && !_this.rObj.tVars){ mv_set_loading('#sub_cliplib_ic'); - var reqObj ={ 'action':'query', - 'prop':'revisions', - 'titles': _this.rObj.uri, - 'rvprop':'content' - }; + var reqObj ={ + 'action':'query', + 'prop':'revisions', + 'titles': _this.rObj.uri, + 'rvprop':'content' + }; //get the interface uri from the plObject var api_url = _this.p_seqObj.plObj.interface_url; //first check @@ -175,32 +176,9 @@ mvClipEdit.prototype = { var template_rev = page['revisions'][0]['*']; } } - - //do a regular ex to get the ~likely~ template values - //(of course this sucks) - //but maybe this will make its way into the api sometime soon to support wysiwyg type editors - //idealy it would expose a good deal of info about the template params - js_log('matching against: ' + template_rev); - var tempVars = template_rev.match(/\{\{\{([^\}]*)\}\}\}/gi); - //clean up results: - _this.rObj.tVars = new Array(); - for(var i=0; i < tempVars.length; i++){ - var tvar = tempVars[i].replace('{{{','').replace('}}}',''); - //strip anything after a | - if(tvar.indexOf('|') != -1){ - tvar = tvar.substr(0, tvar.indexOf('|')); - } - //check for duplicates: - var do_add=true; - for(var j=0; j < _this.rObj.tVars.length; j++){ - js_log('checking: ' + _this.rObj.tVars[j] + ' against:' + tvar); - if( _this.rObj.tVars[j] == tvar) - do_add=false; - } - //add the template vars to the output obj - if(do_add) - _this.rObj.tVars.push( tvar ); - } + var pObj = mw.parser.pNew( template_rev ); + _this.rObj.tVars = pObj.getTemplateVars(); + //run the editor now that we have updated the tVars: _this.doEditOpts(target); } ); diff --git a/js2/mwEmbed/libEmbedVideo/embedVideo.js b/js2/mwEmbed/libEmbedVideo/embedVideo.js index 69ae853f44..f9bc4071a8 100644 --- a/js2/mwEmbed/libEmbedVideo/embedVideo.js +++ b/js2/mwEmbed/libEmbedVideo/embedVideo.js @@ -2260,7 +2260,7 @@ embedVideo.prototype = { var eid = (this.pc)?this.pc.pp.id:this.id; //update status: $j('#' + eid + ' .time-disp').html(value); - } + }, /** * Helper Functions for selected source */ @@ -2273,7 +2273,7 @@ embedVideo.prototype = { supportsURLTimeEncoding: function(){ //do head request if on the same domain return this.media_element.selected_source.URLTimeEncoding; - }, + } } diff --git a/js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js b/js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js index 7964254602..9540bbe114 100644 --- a/js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js @@ -1,5 +1,6 @@ /** * metavid: mv_flashEmbed builds off of flowplayer api (included first in this file) + * THIS WILL BE DEPRECIATED SOON */ /** diff --git a/js2/mwEmbed/libEmbedVideo/htmlEmbed.js b/js2/mwEmbed/libEmbedVideo/htmlEmbed.js index cc654d650d..a5927bdc9d 100644 --- a/js2/mwEmbed/libEmbedVideo/htmlEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/htmlEmbed.js @@ -34,6 +34,7 @@ var htmlEmbed ={ this.monitor(); }, stop:function(){ + this.currentTime = 0; this.pause(); //window.clearInterval( this.monitorTimerId ); }, diff --git a/js2/mwEmbed/libTimedText/mvTimeTextEdit.js b/js2/mwEmbed/libTimedText/mvTimeTextEdit.js index 25853b163c..c266997d97 100644 --- a/js2/mwEmbed/libTimedText/mvTimeTextEdit.js +++ b/js2/mwEmbed/libTimedText/mvTimeTextEdit.js @@ -1,5 +1,5 @@ /* - * JS2-style edit.js + * JS2-style mvTimedTextEdit.js */ // Setup configuration vars (if not set already) diff --git a/js2/mwEmbed/mv_embed.js b/js2/mwEmbed/mv_embed.js index 1a24e94bc0..d800d10161 100644 --- a/js2/mwEmbed/mv_embed.js +++ b/js2/mwEmbed/mv_embed.js @@ -730,7 +730,33 @@ if( !mv_embed_path ) { this.pOut = recurse_magic_swap( this.pNode ); }, - + /** + * getTemplateVars special function to grab template paramaters + * from template text + * + * @returns {Array} template vars names + */ + getTemplateVars:function(){ + //do a regular ex to get the ~likely~ template values + //(of course this sucks) + //but maybe this will make its way into the api sometime soon to support wysiwyg type editors + //ideally it would expose a good deal of info about the template params + js_log('matching against: ' + this.wikiText); + var tempVars = this.wikiText.match(/\{\{\{([^\}]*)\}\}\}/gi); + //clean up results: + var tVars = new Array(); + for(var i=0; i < tempVars.length; i++){ + var tvar = tempVars[i].replace('{{{','').replace('}}}',''); + // Strip anything after a | + if(tvar.indexOf('|') != -1){ + tvar = tvar.substr(0, tvar.indexOf('|')); + } + // Add if not already there + if( $j.inArray(tvar, tVars) == -1) + tVars.push( tvar ); + } + return tVars; + }, /* * parsed template api ~loosely based off of ~POM~ * http://www.mediawiki.org/wiki/Extension:Page_Object_Model @@ -839,7 +865,7 @@ function mv_set_loading(target, load_id){ } /** -* mvJsLoader class handles initialisation and js file loads +* mvJsLoader class handles initialization and js file loads */ var mvJsLoader = { libreq : {},