r49741 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49740‎ | r49741 | r49742 >
Date:23:52, 22 April 2009
Author:dale
Status:deferred
Tags:
Comment:
trimStr update to jQuery version
chunk upload fixes
Modified paths:
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mvFirefogg.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/baseRemoteSearch.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/metavidSearch.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedVideo/mv_vlcEmbed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -47,10 +47,6 @@
4848 /*parseUri class parses URIs:*/
4949 var parseUri=function(d){var o=parseUri.options,value=o.parser[o.strictMode?"strict":"loose"].exec(d);for(var i=0,uri={};i<14;i++){uri[o.key[i]]=value[i]||""}uri[o.q.name]={};uri[o.key[12]].replace(o.q.parser,function(a,b,c){if(b)uri[o.q.name][b]=c});return uri};parseUri.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};
5050
51 -var trimStr = function(v){
52 - return v.replace(/^\s+|\s+$/g, '');
53 -}
54 -
5551 //get mv_embed location if it has not been set
5652 if( !mv_embed_path ){
5753 var mv_embed_path = getMvEmbedPath();
@@ -806,7 +802,7 @@
807803 var vid_html = '<video id="vid_' + i +'" '+
808804 'src="' + src + '" poster="' + poster + '" style="width:' + pwidth +
809805 'px;height:' + pheight + 'px;"></video>';
810 - js_log("video html: " + vid_html);
 806+ //js_log("video html: " + vid_html);
811807 if( src && poster)
812808 $j('#'+vidId).html( vid_html );
813809 //rewrite that video id:
@@ -1130,7 +1126,7 @@
11311127 //force format to json (if not already set)
11321128 options.data['format'] = 'json';
11331129
1134 - js_log('do api req: ' + options.url + options.data);
 1130+ js_log('do api req: ' + options.url +' data' + JSON.stringify( options.data ) );
11351131 //build request string:
11361132 if( parseUri( document.URL ).host == parseUri( options.url ).host ){
11371133 //local request do api request directly
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedVideo/mv_vlcEmbed.js
@@ -103,7 +103,9 @@
104104 */
105105 monitor: function(){
106106 this.getVLC();
107 - if(this.vlc.log){
 107+ if(!this.vlc)
 108+ return ;
 109+ if( this.vlc.log ){
108110 //js_log( 'state:' + this.vlc.input.state);
109111 //js_log('time: ' + this.vlc.input.time);
110112 //js_log('pos: ' + this.vlc.input.position);
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/baseRemoteSearch.js
@@ -94,17 +94,17 @@
9595 if( node!=null && attr_name == null ){
9696 if( node.childNodes[0] != null){
9797 //trim and strip html:
98 - tag_val = trimStr( node.firstChild.nodeValue ).replace(/(<([^>]+)>)/ig,"");
 98+ tag_val = $j.trim( node.firstChild.nodeValue ).replace(/(<([^>]+)>)/ig,"");
9999 }
100100 }
101101 if( node!=null && attr_name != null){
102102 if(typeof attr_name == 'string'){
103 - tag_val = trimStr( $j(node).attr( attr_name ) );
 103+ tag_val = $j.trim( $j(node).attr( attr_name ) );
104104 }else{
105105 var attr_vals = {};
106106 for(var j in attr_name){
107107 if( $j(node).attr( attr_name[j]).length != 0)
108 - attr_vals[ attr_name[j] ] = trimStr( $j(node).attr( attr_name[j]) ).replace(/(<([^>]+)>)/ig,"");
 108+ attr_vals[ attr_name[j] ] = $j.trim( $j(node).attr( attr_name[j]) ).replace(/(<([^>]+)>)/ig,"");
109109 }
110110 tag_val = attr_vals ;
111111 }
@@ -151,7 +151,7 @@
152152 getInlineDescWiki:function( rObj ){
153153 //return striped html & trim white space
154154 if(rObj.desc)
155 - return trimStr( rObj.desc.replace(/(<([^>]+)>)/ig,"") );
 155+ return $j.trim( rObj.desc.replace(/(<([^>]+)>)/ig,"") );
156156 //no desc avaliable:
157157 return '';
158158 },
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/searchLibs/metavidSearch.js
@@ -89,7 +89,7 @@
9090 o += '* part of longer [' + rObj.parent_clip + ' video clip]'+ "\n";
9191
9292 if( rObj.person && rObj.person['url'] && rObj.person['label'] )
93 - o += '* also see speeches by [' + trimStr( rObj.person.url ) + ' ' + rObj.person['label'] + ']'+ "\n";
 93+ o += '* also see speeches by [' + $j.trim( rObj.person.url ) + ' ' + rObj.person['label'] + ']'+ "\n";
9494
9595 //check for bill:
9696 if( rObj.bill && rObj.bill['label'] && rObj.bill['url'])
@@ -101,16 +101,16 @@
102102 var o = this.parent_getInlineDescWiki( rObj );
103103 //add in person if found
104104 if( rObj.person && rObj.person['label'] ){
105 - o = trimStr( o.replace(rObj.person['label'], '') );
 105+ o = $j.trim( o.replace(rObj.person['label'], '') );
106106 //trim leading :
107107 if(o.substr(0,1)==':')
108 - o = trimStr( o.substr(1) );
 108+ o = o.substr(1);
109109 //add quotes and person at the end:
110110 var d = this.getDateFromLink( rObj.link );
111111 o ='"' + o + '" [[' + rObj.person['label'] + ']] on ' + d.toDateString();
112112 }
113113 //could do ref or direct link:
114 - o += ' \'\'[' + trimStr(rObj.link) + ' source clip]\'\' ';
 114+ o += ' \'\'[' + $j.trim( rObj.link ) + ' source clip]\'\' ';
115115
116116 //var o= '"' + o + '" by [[' + rObj.person['label'] + ']] '+
117117 // '<ref>[' + rObj.link + ' Metavid Source Page] for ' + rObj.title +'</ref>';
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mvFirefogg.js
@@ -1,7 +1,12 @@
22 /* adds firefogg support.
33 * autodetects: new upload api or old http POST.
44 */
5 -
 5+
 6+loadGM( {
 7+ "mv_upload_done" : "Your upload <i>should be<\/i> accessible <a href=\"$1\">here<\/a>",
 8+ "mv_upload_completed" : "Upload Completed"
 9+});
 10+
611 var default_firefogg_options = {
712 'upload_done_action':'redirect',
813 'enabled':false,
@@ -296,11 +301,24 @@
297302 },
298303 doUploadStatus:function() {
299304 var _this = this;
 305+ _this.oldResponseText = '';
300306 //setup a local function for timed callback:
301 - var uploadStatus = function(){
302 - var status = _this.fogg.status();
303 - //js_log(' up stats: ' + status + ' p:' + _this.fogg.progress() + ' state: '+ _this.fogg.state + ' result page:' + _this.fogg.responseText);
304 -
 307+ var uploadStatus = function(){
 308+ //get the response text:
 309+ var response_text = _this.fogg.responseText;
 310+ if( !response_text){
 311+ try{
 312+ var pstatus = JSON.parse( _this.fogg.uploadstatus() );
 313+ response_text = pstatus["responseText"];
 314+ }catch(e){
 315+ js_log("could not parse uploadstatus / could not get responseText");
 316+ }
 317+ }
 318+
 319+ if( _this.oldResponseText != response_text){
 320+ js_log('new result text:' + response_text);
 321+ _this.oldResponseText = response_text;
 322+ }
305323 //update progress bar
306324 _this.fogg_update_progress( _this.fogg.progress() );
307325
@@ -312,24 +330,20 @@
313331 else if( _this.fogg.state == 'upload done' || _this.fogg.state == 'done' ) {
314332 js_log( 'firefogg:upload done: ');
315333 //if in "post" upload mode read the html response (should be depricated):
316 - if( _this.upload_mode == 'post' ) {
317 - var response_text ='';
318 - try{
319 - var pstatus = JSON.parse( _this.fogg.uploadstatus() );
320 - response_text = pstatus["responseText"];
321 - }catch(e){
322 - js_log("could not parse uploadstatus / could not get responseText");
323 - }
 334+ if( _this.upload_mode == 'post' ) {
324335 //js_log( 'done upload response is: ' + cat["responseText"] );
325336 _this.procPageResponse( response_text );
326337
327338 }else if( _this.upload_mode == 'chunks'){
328 - //should have an json result:
329 - js_error('chunks upload not yet supported');
330 - //var foo = _this;
331 - //var cat = _JSON.parse( _this.fogg.uploadstatus() );
332 - //debugger;
333 -
 339+ if( _this.fogg.resultUrl ){
 340+ //should have an json result:
 341+ $j( '#dlbox-centered' ).html( '<h3>' + gM('mv_upload_completed') + '</h3>' +
 342+ gM( 'mv_upload_done', _this.fogg.resultUrl) );
 343+ }else{
 344+ //done state with error? ..not really possible given how firefogg works
 345+ js_log(" upload done, in chunks mode, but no resultUrl!");
 346+ }
 347+ alert("upload done");
334348 }
335349 }else{
336350 //upload error:
@@ -343,16 +357,15 @@
344358 procPageResponse:function( result_page ){
345359 js_log('f:procPageResponse');
346360 var sstring = 'var wgTitle = "' + this.formData['wpDestFile'].replace('_',' ');
347 - var error_txt = 'Your upload <i>should be</i> accessible <a href="' +
348 - wgArticlePath.replace(/\$1/, 'File:' + this.formData['wpDestFile'] ) + '">'+
349 - 'here</a> \n';
 361+ var result_txt = gM('mv_upload_done',
 362+ wgArticlePath.replace(/\$1/, 'File:' + this.formData['wpDestFile'] ) );
350363 //set the error text in case we dont' get far along in processing the response
351 - $j( '#dlbox-centered' ).html( '<h3>Upload Completed:</h3>' + error_txt );
 364+ $j( '#dlbox-centered' ).html( gM('mv_upload_completed') + result_txt );
352365
353366 if( result_page && result_page.toLowerCase().indexOf( sstring.toLowerCase() ) != -1){
354367 js_log( 'upload done got redirect found: ' + sstring + ' r:' + _this.upload_done_action );
355368 if( _this.upload_done_action == 'redirect' ){
356 - $j( '#dlbox-centered' ).html( '<h3>Upload Completed:</h3>' + error_txt + '<br>' + form_txt);
 369+ $j( '#dlbox-centered' ).html( '<h3>Upload Completed:</h3>' + result_txt + '<br>' + form_txt);
357370 window.location = wgArticlePath.replace( /\$1/, 'File:' + formData['wpDestFile'] );
358371 }else{
359372 //check if the add_done_action is a callback:
@@ -369,13 +382,13 @@
370383 var res = grabWikiFormError( result_page );
371384
372385 if(res.error_txt)
373 - error_txt = res.error_txt;
 386+ result_txt = res.error_txt;
374387
375388 if(res.form_txt)
376389 form_txt = res.form_txt;
377390 }
378 - js_log( 'error text is: ' + error_txt );
379 - $j( '#dlbox-centered' ).html( '<h3>Upload Completed:</h3>' + error_txt + '<br>' + form_txt);
 391+ js_log( 'error text is: ' + result_txt );
 392+ $j( '#dlbox-centered' ).html( '<h3>' + gM('mv_upload_completed') + '</h3>' + result_txt + '<br>' + form_txt);
380393 }
381394 }
382395 }
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/remoteSearchDriver.js
@@ -1010,7 +1010,7 @@
10111011 var wt = '{{Information '+"\n"+
10121012 '|Description= ' + rObj.pSobj.getImportResourceDescWiki( rObj );
10131013 //output person and bill info if
1014 - wt+='|Source=' + '[' + trimStr( rObj.link ) + ' Original Source]'+ "\n";
 1014+ wt+='|Source=' + '[' + $j.trim( rObj.link ) + ' Original Source]'+ "\n";
10151015
10161016 if( rObj.author )
10171017 wt+='|Author=' + rObj.author +"\n";

Status & tagging log