r64923 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64922‎ | r64923 | r64924 >
Date:05:30, 11 April 2010
Author:dale
Status:deferred
Tags:
Comment:
* updates for new oggHandler output that is missing offset info :(
* apiProxy fix to ensure object when string recived from json POST
* bumped version
Modified paths:
  • /branches/js2-work/phase3/js/apiProxyPage.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js (modified) (history)
  • /branches/js2-work/phase3/js/uploadPage.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.UploadHandler.js
@@ -170,7 +170,7 @@
171171 this.orig_onsubmit = this.form.onsubmit;
172172 }
173173
174 - if( this.selectFileCb ){
 174+ if( this.selectFileCb ) {
175175 this.bindSelectFileCb();
176176 }
177177
@@ -186,9 +186,11 @@
187187 */
188188 bindSelectFileCb: function(){
189189 var _this = this;
 190+
190191 // Grab the select file input from the form
191192 var $target = $j( this.form ).find( "input[type='file']" );
192193 $target.change( function() {
 194+
193195 var path = $j( this ).val();
194196 // Find trailing part
195197 var slash = path.lastIndexOf( '/' );
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.ApiProxy.js
@@ -290,8 +290,9 @@
291291 } catch ( e ) {
292292 mw.log( "Error could not parse hashResult" );
293293 }
 294+
294295 // Check for the contextKey
295 - if( ! resultObject.contextKey ) {
 296+ if ( ! resultObject.contextKey ) {
296297 mw.log( "Error missing context key in nested callback" );
297298 return false;
298299 }
@@ -363,7 +364,7 @@
364365 * @param {Object} contextVars Initial contextVars
365366 */
366367 function createContext ( contextVars ) {
367 - // Create a ~ sufficently ~ unique context key
 368+ // Create a ~ sufficiently ~ unique context key
368369 var contextKey = new Date().getTime() * Math.random();
369370 proxyContext [ contextKey ] = contextVars;
370371
@@ -427,8 +428,8 @@
428429 * @param {URL} apiUrl The url of the api server
429430 */
430431 // Include gadget js ( in case the user has not enabled the gadget on that domain )
431 - var gadgetWithJS = '?withJS=MediaWiki:MwEmbed.js';
432 - //var gadgetWithJS = '';
 432+ //var gadgetWithJS = '?withJS=MediaWiki:MwEmbed.js';
 433+ var gadgetWithJS = '';
433434 function getServerFrame( context ) {
434435 if( ! context || ! context.apiUrl ){
435436 mw.log( "Error no context api url " );
@@ -646,6 +647,10 @@
647648 $j.post( wgScriptPath + '/api' + wgScriptExtension,
648649 clientRequest.request,
649650 function( data ) {
 651+ // Make sure data is in JSON data format ( not a string )
 652+ if( typeof data != 'object' ){
 653+ data = JSON.parse( data );
 654+ }
650655 mw.log(" server api request got data: " + JSON.stringify( data ) );
651656 // Send the result data to the client
652657 sendClientMsg( data );
@@ -872,7 +877,7 @@
873878 var clientRequest = getClientRequest();
874879
875880 // Get a local reference to the client request
876 - var clientFrame = getClientRequest()['clientFrame'];
 881+ var clientFrame = clientRequest[ 'clientFrame' ];
877882
878883 // Double check that the client is an approved domain before outputting the iframe
879884 if( ! isAllowedClientFrame ( clientFrame ) ) {
@@ -932,7 +937,7 @@
933938
934939 // Check for frame name:
935940 if( ! options[ 'name' ] ) {
936 - options[ 'name' ] = 'mwApiProxyFrame_' + $j('iframe').length;
 941+ options[ 'name' ] = 'mwApiProxyFrame_' + $j( 'iframe' ).length;
937942 }
938943
939944 // Add the frame name / id:
@@ -970,7 +975,7 @@
971976 }
972977 var targetName = ( typeof options[ 'target' ] == 'string') ? options[ 'target' ] : $j( options[ 'target' ]).length ;
973978
974 - mw.log( "Append iframe:" + options[ 'src' ] + ' to: ' + targetName + " \n WITH REQUEST: " + JSON.stringify( options.request ) );
 979+ mw.log( "Append iframe:" + options[ 'src' ] + ' to: ' + targetName + " \n with data: " + JSON.stringify( options.request ) );
975980
976981 // Append to target
977982 $j( options[ 'target' ] ).append( s );
Index: branches/js2-work/phase3/js/mwEmbed/remotes/mediaWiki.js
@@ -4,7 +4,7 @@
55 */
66 var urlparts = getRemoteEmbedPath();
77 var mwEmbedHostPath = urlparts[0];
8 -var mwRemoteVersion = 'r118';
 8+var mwRemoteVersion = 'r119';
99 var mwUseScriptLoader = true;
1010
1111 // Log the mwRemote version ( will determine what version of js we get )
@@ -145,7 +145,7 @@
146146 if ( vidIdList.length > 0 ) {
147147 // Reverse order the array so videos at the "top" get swapped first:
148148 vidIdList = vidIdList.reverse();
149 - mwLoadPlayer(function(){
 149+ mwLoadPlayer( function(){
150150 //Load the "EmbedPlayer" module:
151151 // All the actual code was requested in our single script-loader call
152152 // but the "load" request applies the setup.
@@ -210,7 +210,7 @@
211211 return ;
212212 }
213213
214 -
 214+
215215 tag_type = 'video';
216216
217217 // Check type:
@@ -243,14 +243,12 @@
244244 apiTitleKey = unescape( apiTitleKey[ apiTitleKey.length - 1 ] );
245245
246246 var re = new RegExp( /length(":?\s*)*([^,]*)/ );
247 - var dv = re.exec( rewriteHTML )[2];
248 - if ( dv ) {
249 - duration_attr = 'durationHint="' + dv + '" ';
250 - }
 247+ var dv = parseFloat( re.exec( rewriteHTML )[2] );
 248+ duration_attr = ( dv )? 'durationHint="' + dv + '" ': '';
251249
252250 var re = new RegExp( /offset(":?\s*)*([^,&]*)/ );
253 - offset = re.exec( rewriteHTML )[2];
254 - var offset_attr = offset ? 'startOffset="' + offset + '"' : '';
 251+ offset = re.exec( rewriteHTML );
 252+ var offset_attr = ( offset && offset[2] )? 'startOffset="' + offset[2] + '" ' : '';
255253
256254 // Check if file is from commons and therefore should explictly set apiProvider to commons:
257255 var apiProviderAttr = ( src.indexOf( 'wikipedia\/commons' ) != -1 )?'apiProvider="commons" ': '';
Index: branches/js2-work/phase3/js/apiProxyPage.js
@@ -28,11 +28,11 @@
2929 mw.setConfig( 'apiProxyConfig', mwApiProxyConfig);
3030
3131 // Do a setTimeout to 0 to call after other zero delay async events
32 - // ( once everyone is doing buildout withthin mwsetup priror to .ready this won't be needed. )
 32+ // ( once everyone is doing buildout within mwsetup prior to .ready this won't be needed. )
3333 mw.log( 'load ApiProxy' );
34 - mw.load( 'ApiProxy', function(){
 34+ mw.load( 'ApiProxy', function() {
3535 //Clear out the page content ( not needed for iframe proxy )
3636 $j( 'body' ).html( '' );
3737 mw.ApiProxy.server();
38 - });
 38+ } );
3939 } );
Index: branches/js2-work/phase3/js/uploadPage.js
@@ -33,6 +33,11 @@
3434
3535 // Set the select file callback:
3636 'selectFileCb': function( fileName ) {
 37+ // Check if we are on upload to new version page and don't update target
 38+ // ( bug 23069 )
 39+ if( mw.parseUri( document.URL ).queryKey['wpDestFile'] ){
 40+ return false;
 41+ }
3742 $j( '#wpDestFile' ).val( fileName );
3843 }
3944 } );

Status & tagging log