r59942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59941‎ | r59942 | r59943 >
Date:00:56, 11 December 2009
Author:dale
Status:deferred
Tags:
Comment:
* updated roe_url grabbing / rewriting ( still need to be tested )
Modified paths:
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvPlayList.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libTimedText/mvTextInterface.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js
@@ -1266,7 +1266,7 @@
12671267 if ( this.roe && this.media_element.sources.length == 0 ) {
12681268 mw.log( 'checkPlayerSources: loading external data' );
12691269 this.loading_external_data = true;
1270 - do_request( this.roe, function( data ){
 1270+ mw.getMvJsonUrl( this.roe, function( data ){
12711271 // Continue
12721272 _this.media_element.addROE( data );
12731273 mw.log( 'added_roe::' + _this.media_element.sources.length );
@@ -1658,8 +1658,7 @@
16591659 )
16601660 // now load roe if run the showNextPrevLinks
16611661 if ( this.roe && this.media_element.addedROEData == false ) {
1662 - do_request( this.roe, function( data )
1663 - {
 1662+ mw.getMvJsonUrl( this.roe, function( data ){
16641663 _this.media_element.addROE( data );
16651664 _this.getNextPrevLinks();
16661665 } );
@@ -1718,7 +1717,7 @@
17191718 mw.log( 'anno data found in cache: ' + request_key );
17201719 this.showNextPrevLinks();
17211720 } else {
1722 - do_request( new_anno_track_url, function( cmml_data ) {
 1721+ mw.getMvJsonUrl( new_anno_track_url, function( cmml_data ) {
17231722 mw.log( 'raw response: ' + cmml_data );
17241723 if ( typeof cmml_data == 'string' ) {
17251724 var parser = new DOMParser();
@@ -2154,7 +2153,7 @@
21552154 if ( ! this.linkback && this.roe && this.media_element.addedROEData == false ) {
21562155 var _this = this;
21572156 this.displayHTML( gM( 'mwe-loading_txt' ) );
2158 - do_request( this.roe, function( data ) {
 2157+ mw.getMvJsonUrl( this.roe, function( data ) {
21592158 _this.media_element.addROE( data );
21602159 _this.doLinkBack();
21612160 } );
@@ -2422,7 +2421,7 @@
24232422 if ( this.roe && this.media_element.addedROEData == false ) {
24242423 var _this = this;
24252424 $target.html( gM( 'loading_txt' ) );
2426 - do_request( this.roe, function( data ) {
 2425+ mw.getMvJsonUrl( this.roe, function( data ) {
24272426 _this.media_element.addROE( data );
24282427 $target.html( getShowVideoDownload() );
24292428 } );
Index: branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvPlayList.js
@@ -302,7 +302,7 @@
303303 var pl_parent = this;
304304 this.makeURLAbsolute();
305305 if ( this.src != null ) {
306 - do_request( this.src, function( data ) {
 306+ mw.getMvJsonUrl( this.src, function( data ) {
307307 pl_parent.data = data;
308308 pl_parent.getSourceType();
309309 } );
Index: branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js
@@ -1130,17 +1130,29 @@
11311131 mw.log("run getJSON: " + url + ' data: ' + data);
11321132 // Pass off the jQuery getJSON request:
11331133 $j.getJSON( url, data, callback );
1134 - }
1135 -
1136 -
 1134+ }
 1135+
11371136 /**
 1137+ * Metavid spefic helper funtion will be factored out eventually.
 1138+ * @param roe_url to be updated
 1139+ */
 1140+ $.getMvJsonUrl = function( roe_url , callback){
 1141+ if ( mw.parseUri( document.URL ).host == mw.parseUri( roe_url ).host ||
 1142+ roe_url.indexOf( '://' ) == -1 ){
 1143+ $j.get( roe_url, callback );
 1144+ } else {
 1145+ $j.getJSON( roe_url + '&feed_format=json&cb=?&cb_inx=1', callback );
 1146+ }
 1147+
 1148+ }
 1149+ /**
11381150 * Simple api helper to grab an edit token
11391151 *
11401152 * @param title The wiki page title you want to edit
11411153 * @param {String} [api_url] The target API URL
11421154 * @param {callback} callback Function to pass the token to
11431155 */
1144 - mw.getToken( title, api_url, callback ) {
 1156+ $.getToken = function( title, api_url, callback ) {
11451157 if( typeof api_url == 'function' )
11461158 callback = api_url;
11471159 if( typeof title == 'function')
@@ -2499,65 +2511,11 @@
25002512 }
25012513 } )( jQuery );
25022514 }
2503 -/*
2504 -* Utility functions:
 2515+
 2516+/**
 2517+* Utility functions that override globals
25052518 */
25062519
2507 -// Do a metavid callback request:
2508 -// NOTE: this contains metavid specific local vs remote api remapping will be removed shortly
2509 -// this should be depreciated and we should use "$j.get" or an api call
2510 -// (we should not mix the two request types)
2511 -function do_request( req_url, callback ) {
2512 - mw.log( 'do_request::req_url:' + mw.parseUri( document.URL ) + ' != ' + mw.parseUri( req_url ).host );
2513 - // If we are doing a request to the same domain or relative link, do a normal GET
2514 - if ( mw.parseUri( document.URL ).host == mw.parseUri( req_url ).host ||
2515 - req_url.indexOf( '://' ) == -1 ){ // if its a relative url go directly as well
2516 - // Do a direct request
2517 - $j.ajax( {
2518 - type: "GET",
2519 - url: req_url,
2520 - async: false,
2521 - success: function( data ) {
2522 - callback( data );
2523 - }
2524 - } );
2525 - } else {
2526 - // Get data via DOM injection with callback
2527 - global_req_cb.push( callback );
2528 - // Prepend json_ to feed_format if not already requesting json format (metavid specific)
2529 - if ( req_url.indexOf( "feed_format=" ) != -1 && req_url.indexOf( "feed_format=json" ) == -1 )
2530 - req_url = req_url.replace( /feed_format=/, 'feed_format=json_' );
2531 - $j.getScript( req_url + '&cb=mv_jsdata_cb&cb_inx=' + ( global_req_cb.length -1 ) );
2532 - }
2533 -}
2534 -
2535 -function mv_jsdata_cb( response ) {
2536 - mw.log( 'f:mv_jsdata_cb:' + response['cb_inx'] );
2537 - // Run the callback from the global request callback object
2538 - if ( !global_req_cb[response['cb_inx']] ) {
2539 - mw.log( 'missing req cb index' );
2540 - return false;
2541 - }
2542 - if ( !response['pay_load'] ) {
2543 - mw.log( "missing pay load" );
2544 - return false;
2545 - }
2546 - switch( response['content-type'] ) {
2547 - case 'text/plain':
2548 - break;
2549 - case 'text/xml':
2550 - if ( typeof response['pay_load'] == 'string' ) {
2551 - response['pay_load'] = mw.parseXML( response['pay_load'] );
2552 - }
2553 - break
2554 - default:
2555 - mw.log( 'bad response type' + response['content-type'] );
2556 - return false;
2557 - break;
2558 - }
2559 - global_req_cb[response['cb_inx']]( response['pay_load'] );
2560 -}
2561 -
25622520 if ( typeof DOMParser == "undefined" ) {
25632521 DOMParser = function () { }
25642522 DOMParser.prototype.parseFromString = function ( str, contentType ) {
@@ -2577,7 +2535,4 @@
25782536 }
25792537 }
25802538 }
2581 -/*
2582 -* Utility functions
2583 -*/
25842539
Index: branches/js2-work/phase3/js2/mwEmbed/libTimedText/mvTextInterface.js
@@ -40,8 +40,7 @@
4141 if ( !this.pe.media_element.addedROEData ) {
4242 $j( '#mv_txt_load_' + _this.pe.id ).show(); // show the loading icon
4343 if ( _this.pe.roe ) {
44 - do_request( _this.pe.roe, function( data )
45 - {
 44+ mw.getMvJsonUrl( _this.pe.roe, function( data ){
4645 _this.pe.media_element.addROE( data );
4746 _this.getParseTimedText_rowReady();
4847 } );
@@ -568,7 +567,7 @@
569568 // check for urls without time keys:
570569 if ( typeof pcurl.queryKey['t'] == 'undefined' ) {
571570 // in which case just get the full time req:
572 - do_request( this.getSRC(), function( data ) {
 571+ mw.getMvJsonUrl( this.getSRC(), function( data ) {
573572 _this.doParse( data );
574573 _this.loaded = true;
575574 callback();
@@ -592,7 +591,7 @@
593592 url += 't=' + mw.seconds2npt( req_time[0] ) + '/' + mw.seconds2npt( req_time[1] ) + '&';
594593 }
595594 } );
596 - do_request( url, function( data ) {
 595+ mw.getMvJsonUrl( url, function( data ) {
597596 mw.log( "load track clip count:" + data.getElementsByTagName( 'clip' ).length );
598597 _this.doParse( data );
599598 _this.loaded = true;
@@ -625,7 +624,7 @@
626625 var _this = this;
627626 mw.log( 'textSRT: loading : ' + _this.getSRC() );
628627 if ( _this.getSRC() ) {
629 - do_request( _this.getSRC() , function( data ) {
 628+ mw.getMvJsonUrl( _this.getSRC() , function( data ) {
630629 _this.doParse( data );
631630 _this.loaded = true;
632631 callback();

Status & tagging log