r75188 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75187‎ | r75188 | r75189 >
Date:12:34, 22 October 2010
Author:hartman
Status:deferred
Tags:
Comment:
Don't use escape for object generation. Switch to map + $j.param()
Modified paths:
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -2498,45 +2498,49 @@
24992499 */
25002500 getShareEmbedObject: function(){
25012501 var iframeUrl = mw.getMwEmbedPath() + 'mwEmbedFrame.php?';
 2502+ var params = {};
25022503
25032504 if ( this.roe ) {
2504 - iframeUrl += 'roe=' + escape( this.roe ) + '&';
2505 - } else if( this.apiTitleKey ) {
2506 - iframeUrl += 'apiTitleKey=' + escape( this.apiTitleKey ) + '&';
 2505+ params.roe = this.roe;
 2506+ } else if( this.apiTitleKey ) {
 2507+ params.apiTitleKey = this.apiTitleKey;
25072508 if ( this.apiProvider ) {
25082509 // Commons always uses the commons api provider ( special hack should refactor )
25092510 if( mw.parseUri( document.URL ).host == 'commons.wikimedia.org'){
25102511 this.apiProvider = 'commons';
25112512 }
2512 - iframeUrl += 'apiProvider=' + escape( this.apiProvider ) + '&';
 2513+ params.apiProvider = this.apiProvider;
25132514 }
25142515 } else {
25152516 // Output all the video sources:
25162517 for( var i=0; i < this.mediaElement.sources.length; i++ ){
25172518 var source = this.mediaElement.sources[i];
25182519 if( source.src ) {
2519 - iframeUrl += 'src[]=' + escape( mw.absoluteUrl( source.src ) ) + '&';
 2520+ params['src[]'] = mw.absoluteUrl( source.src );
25202521 }
25212522 }
25222523 // Output the poster attr
25232524 if( this.poster ){
2524 - iframeUrl += 'poster=' + escape( this.poster ) + '&';
 2525+ params.poster = this.poster;
25252526 }
25262527 }
25272528
25282529 // Set the skin if set to something other than default
25292530 if( this.skinName ){
2530 - iframeUrl += 'skin=' + escape( this.skinName ) + '&';
 2531+ params.skin = this.skinName;
25312532 }
25322533
25332534 if( this.duration ) {
2534 - iframeUrl +='durationHint=' + escape( parseFloat( this.duration ) ) + '&';
 2535+ params.durationHint = parseFloat( this.duration );
25352536 }
25362537 // Set width / height of iframe embed ( child iframe / object can't read parent frame size )
2537 - if( this.width || this.height ){
2538 - iframeUrl += ( this.width )? 'width=' + parseInt( this.width ) + '&' : '';
2539 - iframeUrl += ( this.height )? 'height=' +parseInt( this.height ) + '&' : '';
 2538+ if( this.width ){
 2539+ params.width = parseInt( this.width );
25402540 }
 2541+ if( this.height ){
 2542+ params.height = parseInt( this.height );
 2543+ }
 2544+ iframeUrl += $.param( params );
25412545
25422546 // Set up embedFrame src path
25432547 var embedCode = '&lt;object data=&quot;' + mw.escapeQuotesHTML( iframeUrl ) + '&quot; ';

Status & tagging log