r58956 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58955‎ | r58956 | r58957 >
Date:17:19, 12 November 2009
Author:dale
Status:deferred
Tags:
Comment:
* some minor refactoring and comment clean up
Modified paths:
  • /trunk/phase3/js2/mwEmbed/jsScriptLoader.php (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libClipEdit/mvClipEdit.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libEmbedVideo/embedVideo.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libEmbedVideo/htmlEmbed.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libTimedText/mvTimeTextEdit.js (modified) (history)
  • /trunk/phase3/js2/mwEmbed/mv_embed.js (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js
@@ -259,6 +259,10 @@
260260 //@@todo for cleaner config we should set _this.opt to the provided options)
261261 $j.extend( _this, default_remote_search_options, options);
262262
 263+ //Quick fix for cases where people put ['all'] instead of 'all' for enabled_cps
 264+ if( _this.enabled_cps.length == 1 && _this.enabled_cps[0] == 'all')
 265+ _this.enabled_cps = 'all';
 266+
263267 //modify the content provider config based on options:
264268 for(var i in this.content_providers){
265269 if( _this.enabled_cps == 'all' && !this.disp_item ){
@@ -266,7 +270,7 @@
267271 //end the for loop (no need to idorate if enabled_cps == 'all'
268272 break;
269273 }else{
270 - if( $j.inArray(i, _this.enabled_cps) != -1 ){
 274+ if( $j.inArray( i, _this.enabled_cps ) != -1 ){
271275 //if no default display set to first enabled cp:
272276 if( !this.disp_item )
273277 this.disp_item = i;
@@ -687,7 +691,7 @@
688692 },
689693 runSearch: function( restPage ){
690694 js_log("f:runSearch::" + this.disp_item);
691 - //draw_direct_flag
 695+
692696 var draw_direct_flag = true;
693697
694698 //check if its the special upload tab case:
@@ -711,7 +715,7 @@
712716 draw_direct_flag = false;
713717 }
714718 if( !draw_direct_flag ){
715 - //see if we should reset the pageing
 719+ //see if we should reset the paging
716720 if( restPage ){
717721 cp.sObj.offset = cp.offset = 0;
718722 }
@@ -719,22 +723,22 @@
720724 //set the content to loading while we do the search:
721725 $j('#tab-' + this.disp_item).html( mv_get_loading_img() );
722726
723 - //make sure the search library is loaded and issue the search request
 727+ // Make sure the search library is loaded and issue the search request
724728 this.getLibSearchResults( cp );
725729 }
726730 },
727 - //issue a api request & cache the result
728 - //this check can be avoided by setting the this.import_url_mode = 'api' | 'form' | instead of 'autodetect' or 'none'
 731+ // Issue a api request & cache the result
 732+ // this check can be avoided by setting the this.import_url_mode = 'api' | 'form' | instead of 'autodetect' or 'none'
729733 checkForCopyURLSupport:function ( callback ){
730734 var _this = this;
731735 js_log('checkForCopyURLSupport:: ');
732736
733 - //see if we already have the import mode:
 737+ // See if we already have the import mode:
734738 if( this.import_url_mode != 'autodetect'){
735739 js_log('import mode: ' + _this.import_url_mode);
736740 callback();
737741 }
738 - //if we don't have the local wiki api defined we can't auto-detect use "link"
 742+ // If we don't have the local wiki api defined we can't auto-detect use "link"
739743 if( ! _this.upload_api_target ){
740744 js_log('import mode: remote link (no import_wiki_api_url)');
741745 _this.import_url_mode = 'remote_link';
@@ -742,8 +746,11 @@
743747 }
744748 if( this.import_url_mode == 'autodetect' ){
745749 do_api_req( {
746 - 'data': { 'action':'paraminfo', 'modules':'upload' },
747 - 'url': _this.upload_api_target
 750+ 'url': _this.upload_api_target,
 751+ 'data': {
 752+ 'action':'paraminfo',
 753+ 'modules':'upload'
 754+ }
748755 }, function(data){
749756 //jump right into api checks:
750757 for( var i in data.paraminfo.modules[0].parameters ){
@@ -812,7 +819,7 @@
813820 return false;
814821 }
815822 _this.loadSearchLib(cp, function(){
816 - //do search
 823+ // Do the search
817824 cp.sObj.getSearchResults();
818825 _this.checkResultsDone();
819826 });
Index: trunk/phase3/js2/mwEmbed/libClipEdit/mvClipEdit.js
@@ -153,11 +153,12 @@
154154 //if media type is template we have to query to get its URI to get its parameters
155155 if(_this.media_type == 'template' && !_this.rObj.tVars){
156156 mv_set_loading('#sub_cliplib_ic');
157 - var reqObj ={ 'action':'query',
158 - 'prop':'revisions',
159 - 'titles': _this.rObj.uri,
160 - 'rvprop':'content'
161 - };
 157+ var reqObj ={
 158+ 'action':'query',
 159+ 'prop':'revisions',
 160+ 'titles': _this.rObj.uri,
 161+ 'rvprop':'content'
 162+ };
162163 //get the interface uri from the plObject
163164 var api_url = _this.p_seqObj.plObj.interface_url;
164165 //first check
@@ -175,32 +176,9 @@
176177 var template_rev = page['revisions'][0]['*'];
177178 }
178179 }
179 -
180 - //do a regular ex to get the ~likely~ template values
181 - //(of course this sucks)
182 - //but maybe this will make its way into the api sometime soon to support wysiwyg type editors
183 - //idealy it would expose a good deal of info about the template params
184 - js_log('matching against: ' + template_rev);
185 - var tempVars = template_rev.match(/\{\{\{([^\}]*)\}\}\}/gi);
186 - //clean up results:
187 - _this.rObj.tVars = new Array();
188 - for(var i=0; i < tempVars.length; i++){
189 - var tvar = tempVars[i].replace('{{{','').replace('}}}','');
190 - //strip anything after a |
191 - if(tvar.indexOf('|') != -1){
192 - tvar = tvar.substr(0, tvar.indexOf('|'));
193 - }
194 - //check for duplicates:
195 - var do_add=true;
196 - for(var j=0; j < _this.rObj.tVars.length; j++){
197 - js_log('checking: ' + _this.rObj.tVars[j] + ' against:' + tvar);
198 - if( _this.rObj.tVars[j] == tvar)
199 - do_add=false;
200 - }
201 - //add the template vars to the output obj
202 - if(do_add)
203 - _this.rObj.tVars.push( tvar );
204 - }
 180+ var pObj = mw.parser.pNew( template_rev );
 181+ _this.rObj.tVars = pObj.getTemplateVars();
 182+ //run the editor now that we have updated the tVars:
205183 _this.doEditOpts(target);
206184 }
207185 );
Index: trunk/phase3/js2/mwEmbed/mv_embed.js
@@ -730,7 +730,33 @@
731731 this.pOut = recurse_magic_swap( this.pNode );
732732
733733 },
734 -
 734+ /**
 735+ * getTemplateVars special function to grab template paramaters
 736+ * from template text
 737+ *
 738+ * @returns {Array} template vars names
 739+ */
 740+ getTemplateVars:function(){
 741+ //do a regular ex to get the ~likely~ template values
 742+ //(of course this sucks)
 743+ //but maybe this will make its way into the api sometime soon to support wysiwyg type editors
 744+ //ideally it would expose a good deal of info about the template params
 745+ js_log('matching against: ' + this.wikiText);
 746+ var tempVars = this.wikiText.match(/\{\{\{([^\}]*)\}\}\}/gi);
 747+ //clean up results:
 748+ var tVars = new Array();
 749+ for(var i=0; i < tempVars.length; i++){
 750+ var tvar = tempVars[i].replace('{{{','').replace('}}}','');
 751+ // Strip anything after a |
 752+ if(tvar.indexOf('|') != -1){
 753+ tvar = tvar.substr(0, tvar.indexOf('|'));
 754+ }
 755+ // Add if not already there
 756+ if( $j.inArray(tvar, tVars) == -1)
 757+ tVars.push( tvar );
 758+ }
 759+ return tVars;
 760+ },
735761 /*
736762 * parsed template api ~loosely based off of ~POM~
737763 * http://www.mediawiki.org/wiki/Extension:Page_Object_Model
@@ -839,7 +865,7 @@
840866 }
841867
842868 /**
843 -* mvJsLoader class handles initialisation and js file loads
 869+* mvJsLoader class handles initialization and js file loads
844870 */
845871 var mvJsLoader = {
846872 libreq : {},
Index: trunk/phase3/js2/mwEmbed/libEmbedVideo/flowplayerEmbed.js
@@ -1,5 +1,6 @@
22 /**
33 * metavid: mv_flashEmbed builds off of flowplayer api (included first in this file)
 4+ * THIS WILL BE DEPRECIATED SOON
45 */
56
67 /**
Index: trunk/phase3/js2/mwEmbed/libEmbedVideo/htmlEmbed.js
@@ -34,6 +34,7 @@
3535 this.monitor();
3636 },
3737 stop:function(){
 38+ this.currentTime = 0;
3839 this.pause();
3940 //window.clearInterval( this.monitorTimerId );
4041 },
Index: trunk/phase3/js2/mwEmbed/libEmbedVideo/embedVideo.js
@@ -2260,7 +2260,7 @@
22612261 var eid = (this.pc)?this.pc.pp.id:this.id;
22622262 //update status:
22632263 $j('#' + eid + ' .time-disp').html(value);
2264 - }
 2264+ },
22652265 /**
22662266 * Helper Functions for selected source
22672267 */
@@ -2273,7 +2273,7 @@
22742274 supportsURLTimeEncoding: function(){
22752275 //do head request if on the same domain
22762276 return this.media_element.selected_source.URLTimeEncoding;
2277 - },
 2277+ }
22782278 }
22792279
22802280
Index: trunk/phase3/js2/mwEmbed/jsScriptLoader.php
@@ -58,7 +58,7 @@
5959 $this->sFileCache->getCacheFileName();
6060
6161 // Setup script loader header info
62 - // @@todo we might want to put these into the $mw var per class request set
 62+ // @@todo we might want to put these into the mw var per class request set
6363 // and or include a callback to avoid pulling in old browsers that don't support
6464 // the onLoad attribute for script elements.
6565 $this->jsout .= 'var mwSlScript = "' . $_SERVER['SCRIPT_NAME'] . '";' . "\n";
Index: trunk/phase3/js2/mwEmbed/libTimedText/mvTimeTextEdit.js
@@ -1,5 +1,5 @@
22 /*
3 - * JS2-style edit.js
 3+ * JS2-style mvTimedTextEdit.js
44 */
55
66 // Setup configuration vars (if not set already)

Status & tagging log