r60099 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60098‎ | r60099 | r60100 >
Date:23:17, 15 December 2009
Author:dale
Status:deferred
Tags:
Comment:
* fixed preview in add-media-wizard
* more robust on-load handling for dynamic insert of mwEmbed.js script
* enhanced mw.getJSON to automatically use "post" for API requests that only work with POST
* add getUserConfig, setUserConfig & setupUserConfig as an stub api to local user preferences loaded via cookie.
* native video duration readings are more accurate now days, use native duration where possible.
* minor timed text cleanup
Modified paths:
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libClipEdit/mvClipEdit.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/nativeEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libTimedText/mw.timedText.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/tests/testApiProxy.html (modified) (history)
  • /branches/js2-work/phase3/js2/remoteMwEmbed.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js
@@ -151,10 +151,13 @@
152152 }
153153
154154 remoteSearchDriver.prototype = {
 155+
155156 // Result cleared flag
156157 results_cleared: false,
157 - // Caret possition of target text area ( lazy initialised )
 158+
 159+ // Caret position of target text area ( lazy initialised )
158160 caretPos: null,
 161+
159162 // Text area value ( lazy initialised )
160163 textboxValue: null,
161164
@@ -1721,13 +1724,14 @@
17221725
17231726 /**
17241727 * Internal function called by showResourceEditor() to show an image editor
1725 - * @param {Object} resource Show Image Editor for this resource
 1728+ * @param {Object} resource Resource for Image Editor display
17261729 */
17271730 showImageEditor: function( resource ) {
17281731 var _this = this;
17291732 var options = _this.getClipEditOptions( resource );
 1733+
17301734 // Display the mvClipEdit obj once we are done loading:
1731 - mw.load( ['mvClipEdit'], function() {
 1735+ mw.load( 'mvClipEdit', function() {
17321736 // Run the image clip tools
17331737 _this.clipEdit = new mvClipEdit( options );
17341738 } );
@@ -2150,7 +2154,7 @@
21512155 * @param {Function} callback Function to be called once api import call is done
21522156 */
21532157 doApiImport: function( resource, callback ) {
2154 - var _this = this;
 2158+ var _this = this;
21552159 mw.log( ":doApiImport:" );
21562160 $j.addLoaderDialog( gM( 'mwe-importing_asset' ) );
21572161
@@ -2224,7 +2228,10 @@
22252229
22262230 // If status is missing show import UI
22272231 if ( status === 'missing' ) {
2228 - _this.showImportUI( resource, callback );
 2232+ _this.showImportUI( resource, function(){
 2233+ // Once the image is imported re-issue the showPreview request:
 2234+ _this.showPreview( resource );
 2235+ } );
22292236 return;
22302237 }
22312238
@@ -2251,6 +2258,7 @@
22522259 .click( function() {
22532260 _this.insertResource( resource );
22542261 } );
 2262+
22552263 // Update cancel button
22562264 $j( buttonPaneSelector )
22572265 .append( '<a href="#" class="preview_close">Do More Modification</a>' )
@@ -2269,8 +2277,8 @@
22702278 _this.target_title,
22712279 function( phtml ) {
22722280 $j( '#rsd_preview_display' ).html( phtml );
2273 - // update the display of video tag items (if any)
2274 - mwdomReady( true );
 2281+ // Update the display of video tag items (if any)
 2282+ $j( mw.getConfig( 'rewritePlayerTags' ) ).embedPlayer();
22752283 }
22762284 );
22772285 } );
@@ -2331,15 +2339,12 @@
23322340 * @param {String} title Context title of the content to be parsed
23332341 * @param {Function} callback Function called with api parser output
23342342 */
2335 - parse: function( wikitext, title, callback ) {
2336 - do_api_req(
 2343+ parse: function( wikitext, title, callback ) {
 2344+ mw.getJSON( this.local_wiki_api_url,
23372345 {
2338 - 'data': {
2339 - 'action': 'parse',
2340 - 'title' : title,
2341 - 'text': wikitext
2342 - },
2343 - 'url': this.local_wiki_api_url
 2346+ 'action': 'parse',
 2347+ 'title' : title,
 2348+ 'text': wikitext
23442349 }, function( data ) {
23452350 callback( data.parse.text['*'] );
23462351 }
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js
@@ -402,8 +402,8 @@
403403
404404 // Reset the done with action flag
405405 _this.action_done = false;
406 -
407 - //do the api request
 406+
 407+ // Do the api request:
408408 mw.getJSON(_this.api_url, request, function( data ) {
409409 _this.processApiResult( data );
410410 });
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js
@@ -14,6 +14,9 @@
1515 // If the k-skin video player should attribute kaltura
1616 mw.setConfig( 'k_attribution', true );
1717
 18+// The global player list per page
 19+mw.player_list = new Array();
 20+
1821 mw.addMessages( {
1922 "mwe-loading_plugin" : "loading plugin ...",
2023 "mwe-select_playback" : "Set playback preference",
@@ -271,34 +274,10 @@
272275
273276 // Pointer to Selector:
274277 var j_selector = this.selector;
275 -
276 - // Process selected elements:
277 - // ie8 does not play well with the jQuery video,audio,playlist selector use native:
278 - if ( $.browser.msie && $j.browser.version >= 8 ) {
279 - var ie_compatible_selector = '';
280 - var jtags = j_selector.split( ',' );
281 - var coma = '';
282 - for ( var i = 0; i < jtags.length; i++ ) {
283 - if ( jtags[i] === 'video' ||
284 - jtags[i] === 'audio' ||
285 - jtags[i] === 'playlist' ) {
286 - // Use native ElementsByTagName selector
287 - $( document.getElementsByTagName( jtags[i] ) ).each( function() {
288 - mw.playerManager.addElement( this, attributes);
289 - } );
290 - }else{
291 - ie_compatible_selector += coma + jtags[i]
292 - coma = ',';
293 - }
294 - }
295 - //Set the selector to IE compatible set and continue processing
296 - j_selector = ie_compatible_selector;
297 - }
298278
299 - // Run the selector
300 - $j( j_selector ).each( function() {
301 - mw.playerManager.addElement( this, attributes);
302 - } );
 279+ $j( mw.getPlayerTagElements( j_selector ) ).each( function(na, playerElement){
 280+ mw.playerManager.addElement( playerElement, attributes);
 281+ } );
303282
304283 // Once we are done adding new players start to check if players are ready:
305284 mw.playerManager.waitPlayersReadyCallback();
@@ -1676,7 +1655,7 @@
16771656 }
16781657 }
16791658 };
1680 - } ); // end do_api_req
 1659+ } ); // end $j.getJSON
16811660 };
16821661 },
16831662
@@ -3193,7 +3172,7 @@
31943173 */
31953174 setFormatPreference : function ( mime_format ) {
31963175 this.preference['format_preference'] = mime_format;
3197 - this.savePreferences();
 3176+ mw.setUserConfig( 'playerPref', this.preference);
31983177 },
31993178
32003179 /**
@@ -3208,8 +3187,9 @@
32093188 if ( this.players[i].id == player_id ) {
32103189 selected_player = this.players[i];
32113190 mw.log( 'choosing ' + player_id + ' for ' + mime_type );
3212 - this.preference[mime_type] = player_id;
3213 - this.savePreferences();
 3191+ this.preference[ mime_type ] = player_id;
 3192+
 3193+ mw.setUserConfig( 'playerPref', this.preference);
32143194 break;
32153195 }
32163196 }
@@ -3231,30 +3211,8 @@
32323212 loadPreferences : function ( ) {
32333213 this.preference = new Object();
32343214 // see if we have a cookie set to a clientSupported type:
3235 - var cookieVal = $j.cookie( 'ogg_player_exp' );
3236 - if ( cookieVal ) {
3237 - var pairs = cookieVal.split( '&' );
3238 - for ( var i = 0; i < pairs.length; i++ )
3239 - {
3240 - var name_value = pairs[i].split( '=' );
3241 - this.preference[name_value[0]] = name_value[1];
3242 - // mw.log('load preference for ' + name_value[0] + ' is ' + name_value[1]);
3243 - }
3244 - }
3245 - },
3246 -
3247 - /**
3248 - * Saves the user preference settings to a cookie
3249 - */
3250 - savePreferences : function() {
3251 - var cookieVal = '';
3252 - for ( var i in this.preference )
3253 - cookieVal += i + '=' + this.preference[i] + '&';
3254 -
3255 - cookieVal = cookieVal.substr( 0, cookieVal.length -1 );
3256 - var week = 7 * 86400 * 1000;
3257 - $j.cookie( 'ogg_player_exp', cookieVal, { 'expires':week } );
3258 - }
 3215+ mw.setUserConfig( 'playerPref' );
 3216+ }
32593217 };
32603218
32613219 /**
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/nativeEmbed.js
@@ -396,10 +396,9 @@
397397 */
398398 onloadedmetadata: function() {
399399 this.getPlayerElement();
400 - mw.log( 'f:onloadedmetadata metadata ready Update duration:' + this.playerElement.duration);
 400+ mw.log( 'f:onloadedmetadata metadata ready Update duration:' + this.playerElement.duration + ' old dur: ' + this.getDuration() );
401401 // update duration if not set (for now trust the getDuration more than this.playerElement.duration
402 - if ( this.getDuration() == 0 && ! isNaN( this.playerElement.duration ) ) {
403 - mw.log( 'updaed duration via native video duration: ' + this.playerElement.duration )
 402+ if ( ! isNaN( this.playerElement.duration ) ) {
404403 this.duration = this.playerElement.duration;
405404 }
406405
Index: branches/js2-work/phase3/js2/mwEmbed/tests/testApiProxy.html
@@ -41,7 +41,7 @@
4242 'action':'query',
4343 'meta':'userinfo'
4444 }
45 - //we use normal do_api_req with keywork 'proxy' for the url
 45+ // Do proxy request
4646 mw.proxy.doRequest( rObj,
4747 function( data ){
4848 //now we get the data back for that domain
Index: branches/js2-work/phase3/js2/mwEmbed/libClipEdit/mvClipEdit.js
@@ -1,6 +1,7 @@
22 /*
3 - mvClipEdit hanndles the edit interfaces for images and video
 3+* mvClipEdit handles the edit interfaces for images and video
44 */
 5+
56 // set gMsg object:
67 mw.addMessages( {
78 "mwe-crop" : "Crop image",
@@ -32,7 +33,7 @@
3334 } );
3435
3536 /**
36 -* The default clipedit values
 37+* The default clipEdit values
3738 */
3839 var default_clipedit_values = {
3940
Index: branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js
@@ -37,8 +37,7 @@
3838 'skin_name' : 'mvpcf',
3939
4040 // Default jquery ui skin name
41 - 'jui_skin' : 'redmond',
42 -
 41+ 'jui_skin' : 'redmond',
4342
4443 /**
4544 * If jQuery / mwEmbed should always be loaded.
@@ -56,19 +55,20 @@
5756 * NOTE: Future architecture will probably do away with this flag and refactor it into
5857 * a smaller "remotePageMwEmbed.js" script similar to ../remoteMwEmbed.js
5958 */
60 - 'alwaysSetupMwEmbed' : false,
 59+ 'runSetupMwEmbed' : false,
6160
6261 // The mediaWiki path of mvEmbed
6362 'mediaWiki_mwEmbedPath' : 'js2/mwEmbed/',
6463
 64+ // Api actions that must be submited in a POST, and need an api proxy for cross domain calls
 65+ 'apiPostActions': [ 'login', 'purge', 'rollback', 'delete', 'undelete',
 66+ 'protect', 'block', 'unblock', 'move', 'edit', 'upload', 'emailuser',
 67+ 'import', 'userrights' ],
 68+
6569 //If we are in debug mode ( results in fresh debugg javascript includes )
6670 'debug' : false
67 -}
 71+};
6872
69 -
70 -// @@todo move these into mw
71 -var global_req_cb = new Array(); // The global request callback array
72 -
7373 /**
7474 * The global mw object:
7575 *
@@ -93,20 +93,21 @@
9494 */
9595 $.skin_list = new Array();
9696 $.init_done = false;
97 - $.cb_count = 0;
98 - $.player_list = new Array(), // The global player list per page
99 - $.req_cb = new Array() // The global request callback array
 97+ $.cb_count = 0;
10098
10199 /**
102100 * Configuration System:
103101 *
104 - * Simple system of inherit defauts, with getter setter functions:
 102+ * Simple system of inherit defaults, with getter setter functions:
105103 */
106104
107105 // Local scope configuration var:
108 - mwConfig = { };
 106+ var mwConfig = { };
109107
110 - for(var i in mwDefaultConf){
 108+ //Local scope mwUserConfig var. Stores user configuration
 109+ var mwUserConfig = { };
 110+
 111+ for( var i in mwDefaultConf ){
111112 if( typeof mwConfig[ i ] == 'undefined' )
112113 mwConfig[ i ] = mwDefaultConf[ i ];
113114 }
@@ -119,7 +120,7 @@
120121 */
121122 $.setConfig = function ( name, value ){
122123 mwConfig[ name ] = value;
123 - }
 124+ }
124125
125126 /**
126127 * Getter for configuration values
@@ -129,13 +130,77 @@
130131 * returns "false" if key not found
131132 */
132133 $.getConfig = function ( name ){
133 - if(mwConfig[ name ] )
 134+ if( mwConfig[ name ] )
134135 return mwConfig[ name ];
135136 return false;
136137 }
137138
 139+ /**
 140+ * Loads the mwUserConfig from a cookie.
 141+ *
 142+ * Modules that want to use "User Config" should call
 143+ * this setup function in their moduleLoader code.
 144+ *
 145+ * For performance interfaces should load '$j.cookie' & 'JSON'
 146+ * in their grouped load request
 147+ *
 148+ * By abstracting user preference we could eventually integrate
 149+ * a persistent per-account preference system on the server.
 150+ *
 151+ * @parma {Function} callback Function to be called once userPrefrences are loaded
 152+ */
 153+ var setupUserConfigFlag = false;
 154+ $.setupUserConfig = function( callback ){
 155+ if( setupUserConfigFlag ){
 156+ if( callback )
 157+ callback();
 158+ }
 159+ // Do Setup user config:
 160+ mw.load( [ '$j.cookie', 'JSON' ], function(){
 161+ if( $j.cookie( 'mwUserConfig' ) ){
 162+ mwUserConfig = JSON.parse( $j.cookie( 'mwUserConfig' ) );
 163+ }
 164+ if( callback )
 165+ callback();
 166+ setupUserConfigFlag = true;
 167+ });
 168+ }
138169
139170 /**
 171+ * Save a user configuration var to a cookie & local global variable
 172+ * Loads the cookie plugin if not already loaded
 173+ *
 174+ * @param {String} name Name of user configuration value
 175+ * @param {String} value Value of configuration name
 176+ */
 177+
 178+
 179+ $.setUserConfig = function ( name, value, cookieOptions ){
 180+ // Update local value
 181+ mwUserConfig[ name ] = value;
 182+
 183+ // Update the cookie ( '$j.cookie' & 'JSON' should already be loaded )
 184+ mw.load( [ '$j.cookie', 'JSON' ], function(){
 185+ $j.cookie( 'mwUserConfig', JSON.stringify( mwUserConfig ) );
 186+ });
 187+ }
 188+
 189+ /**
 190+ * Save a user configuration var to a cookie & local global variable
 191+ * Loads the cookie plugin if not already loaded
 192+ *
 193+ * @param {String} name Name of user configuration value
 194+ * @return
 195+ * value of the configuration name
 196+ * false if the configuration name could not be found
 197+ */
 198+ $.getUserConfig = function ( name ){
 199+ if( mwUserConfig[ name ] )
 200+ return mwUserConfig
 201+ return false;
 202+ }
 203+
 204+ /**
140205 * Language classes mw.lang
141206 *
142207 * Localized Language support attempts to mirror some of the functionality of Language.php in MediaWiki
@@ -1031,7 +1096,7 @@
10321097 var classDone = false;
10331098
10341099 // Check if the class is ready: ( not all browers support onLoad script attribute )
1035 - // In the case of a "class" we can pull the javascript state untill its ready
 1100+ // In the case of a "class" we can pull the javascript state until its ready
10361101 setTimeout( function(){
10371102 $.waitForObject( className, function( className ){
10381103 if( callback )
@@ -1042,9 +1107,13 @@
10431108
10441109 // Issue the request to load the class (include class name in result callback:
10451110 $.getScript( scriptRequest, function( ) {
1046 - if( callback )
1047 - callback( className );
1048 - callback = null;
 1111+ if(! $.isset( className )){
 1112+ mw.log( 'ClassName not set in time ( Use waitForObject )' );
 1113+ }else{
 1114+ if( callback )
 1115+ callback( className );
 1116+ callback = null;
 1117+ }
10491118 } );
10501119 //mw.log( 'done with running getScript request ' );
10511120 },
@@ -1142,12 +1211,13 @@
11431212 * callback parameter is not needed we setup the callback automatically
11441213 * url param 'action'=>'query' is assumed ( if not set to something else in the "data" param
11451214 * format is set to "json" automatically
 1215+ * automatically issues request over "POST" if action={postActions}
11461216 *
11471217 * @param {Mixed} url or data request
11481218 * @param {Mixed} data or callback
11491219 * @param {Mixed} callbcak
11501220 *
1151 - */
 1221+ */
11521222 $.getJSON = function( arg1, arg2, arg3 ){
11531223
11541224 // Set up the url
@@ -1168,14 +1238,8 @@
11691239 if( !url ){
11701240 mw.log( 'Error: no api url for api request' );
11711241 return false;
1172 - }
 1242+ }
11731243
1174 - // Add the callback to the url if unset
1175 - if( url.indexOf( 'callback=' ) == -1 || data[ 'callback' ] == -1 ){
1176 - // jQuery specific: ( second ? is replaced with the callback )
1177 - url += ( url.indexOf('?') == -1 ) ? '?callback=?' : '&callback=?';
1178 - }
1179 -
11801244 // Add default action if unset:
11811245 if( !data['action'] )
11821246 data['action'] = 'query';
@@ -1184,21 +1248,35 @@
11851249 if( !data['format'] )
11861250 data['format'] = 'json';
11871251
1188 - mw.log("run getJSON: " + url + ' data: ' + data);
1189 - // Pass off the jQuery getJSON request:
1190 - $j.getJSON( url, data, callback );
 1252+ mw.log("run getJSON: " + url + ' data: ' + data['action'] + ' apiPost: ' +mw.getConfig( 'apiPostActions' ) );
 1253+
 1254+ if( $j.inArray( data['action'], mw.getConfig( 'apiPostActions' ) ) != -1 ){
 1255+ if( ! $.isLocalDomain( url ) ){
 1256+ mw.log( "Error:: should setup proxy here" );
 1257+ }
 1258+ $j.post( url, data, callback, 'json');
 1259+ }else{
 1260+ //If cross domain setup a callback:
 1261+ if( ! $.isLocalDomain( url ) ){
 1262+ if( url.indexOf( 'callback=' ) == -1 || data[ 'callback' ] == -1 ){
 1263+ // jQuery specific: ( second ? is replaced with the callback )
 1264+ url += ( url.indexOf('?') == -1 ) ? '?callback=?' : '&callback=?';
 1265+ }
 1266+ }
 1267+ // Pass off the jQuery getJSON request:
 1268+ $j.getJSON( url, data, callback );
 1269+ }
11911270 }
11921271
11931272 /**
1194 - * Metavid spefic roe request helper function
 1273+ * Metavid specific roe request helper function
11951274 *
11961275 * NOTE: depreciated, will be removed once updates are pushed out to metavid.org
11971276 *
11981277 * @param roe_url to be updated
11991278 */
12001279 $.getMvJsonUrl = function( roe_url , callback){
1201 - if ( mw.parseUri( document.URL ).host == mw.parseUri( roe_url ).host ||
1202 - roe_url.indexOf( '://' ) == -1 ){
 1280+ if ( $.isLocalDomain( roe_url ) ){
12031281 $j.get( roe_url, callback );
12041282 } else {
12051283 roe_url = mw.replaceUrlParams(roe_url, {
@@ -1211,6 +1289,19 @@
12121290 }
12131291
12141292 /**
 1293+ * Checks if the url is a request for the local domain
 1294+ * relative paths are "local" domain
 1295+ * @param {String} url Url for local domain
 1296+ */
 1297+ $.isLocalDomain = function( url ) {
 1298+ if( mw.parseUri( document.URL ).host == mw.parseUri( url ).host ||
 1299+ url.indexOf( '://' ) == -1 ){
 1300+ return true;
 1301+ }
 1302+ return false;
 1303+ }
 1304+
 1305+ /**
12151306 * Simple api helper to grab an edit token
12161307 *
12171308 * @param title The wiki page title you want to edit
@@ -1383,14 +1474,23 @@
13841475 *
13851476 * @param {Function} callback Function to run once DOM and jQuery are ready
13861477 */
1387 - $.addOnloadHook = function( callback ){
 1478+ $.addOnloadHook = function( callback ){
 1479+ mw.log('addOnloadHook:: ' );
13881480 if( mwReadyFlag === false ){
13891481
13901482 // Add the callbcak to the onLoad function stack
13911483 mwOnLoadFuncitons.push ( callback );
13921484
1393 - // Run the setup call ( won't run if already called earlier)
1394 - $.setupMwEmbed();
 1485+ // Set the mwSetup flag. So that onLoad functions can
 1486+ // be called once mwEmbed interfaces are setup.
 1487+ if( !mwDomReadyFlag ){
 1488+ mw.log( 'set config flag' );
 1489+ mw.setConfig( 'runSetupMwEmbed', true );
 1490+ }else{
 1491+ mw.log( 'run setup directly' );
 1492+ //DOM is already ready run setup directly:
 1493+ $.setupMwEmbed();
 1494+ }
13951495
13961496 return ;
13971497 }
@@ -1460,14 +1560,15 @@
14611561 // Rewrite the rewritePlayerTags with the
14621562 $j( $.getConfig( 'rewritePlayerTags' ) ).embedPlayer()
14631563 // Run mw hooks:
 1564+ mw.log("SetupDone ( player ) run hooks:" ) ;
14641565 mw.runLoadHooks();
14651566 } );
1466 - }else{
 1567+ }else{
 1568+ mw.log("SetupDone run hooks ( no rewrite players found ):" ) ;
14671569 // Set ready state and run the callback
14681570 mw.runLoadHooks();
14691571 }
1470 - } );
1471 - mw.log('ran loader' );
 1572+ } );
14721573 }
14731574
14741575 // Flag to register the domReady has been called
@@ -1485,7 +1586,7 @@
14861587 mwDomReadyFlag = true;
14871588
14881589 // Check for the force setup flag:
1489 - if ( $.getConfig( 'alwaysSetupMwEmbed' ) ){
 1590+ if ( $.getConfig( 'runSetupMwEmbed' ) ){
14901591 $.setupMwEmbed();
14911592 return ;
14921593 }
@@ -1506,8 +1607,8 @@
15071608 /**
15081609 * Check the current DOM for any tags in "rewritePlayerTags"
15091610 */
1510 - $.documentHasPlayerTags = function(){
1511 - var tagElm = $.getPlayerTagElements( true );
 1611+ $.documentHasPlayerTags = function(){
 1612+ var tagElm = $.getPlayerTagElements( $.getConfig( 'rewritePlayerTags' ), true );
15121613 if( tagElm && tagElm.length )
15131614 return true;
15141615 return false;
@@ -1516,26 +1617,62 @@
15171618 /**
15181619 * Get page elements that match the rewritePlayerTags config
15191620 *
1520 - * @param {Boolean} getOne Flag to retive only one tag ( faster for simple has tag checks )
 1621+ * @@NOTE we should probably exclud "video" that have already be rewritten
 1622+ *
 1623+ * @param {Boolean} getOne Flag to retrieve only one tag ( faster for simple has tag checks )
15211624 */
1522 - $.getPlayerTagElements = function( getOne ){
1523 - var tagString = $.getConfig( 'rewritePlayerTags' );
1524 - if( ! tagString || tagString == '' )
 1625+ $.getPlayerTagElements = function( selector, getOneFlag ){
 1626+
 1627+ if( ! selector ){
 1628+ selector = $.getConfig( 'rewritePlayerTags' );
 1629+ }
 1630+
 1631+ if( ! selector ){
15251632 return false;
 1633+ }
 1634+ var tagsInDOM = [ ];
 1635+ // Check for tags:
 1636+ // IE8 does not play well with the jQuery video,audio,playlist selector use native:
 1637+ // NOTE: we should re-confirm this bug in-case IE pushes out an update
 1638+ if ( $j.browser.msie && $j.browser.version >= 8 ) {
 1639+ var ie_compatible_selector = '';
 1640+ var jtags = selector.split( ',' );
 1641+ var coma = '';
 1642+ for ( var i = 0; i < jtags.length; i++ ) {
 1643+ if ( jtags[i] === 'video' ||
 1644+ jtags[i] === 'audio' ||
 1645+ jtags[i] === 'playlist' ) {
 1646+ // Use native ElementsByTagName selector
 1647+ $( document.getElementsByTagName( jtags[i] ) ).each( function() {
 1648+ tagsInDOM.push( this );
 1649+ if( getOneFlag )
 1650+ return false;
 1651+ } );
 1652+
 1653+ //If only returning the first found element return:
 1654+ if( tagsInDOM.length != 0 && getOneFlag )
 1655+ return tagsInDOM[0]
 1656+ }else{
 1657+ ie_compatible_selector += coma + jtags[i]
 1658+ coma = ',';
 1659+ }
 1660+ }
 1661+ //Set the selector to IE compatible set and continue processing
 1662+ selector = ie_compatible_selector;
 1663+ }
 1664+ // Run the selector
 1665+ $j( selector ).each( function() {
 1666+ tagsInDOM.push( this );
 1667+ if( getOneFlag )
 1668+ return false;
 1669+ } );
 1670+
 1671+ //If only returning the first found element return:
 1672+ if( tagsInDOM.length != 0 && getOneFlag )
 1673+ return tagsInDOM
15261674
1527 - // Tags should be separated by ","
1528 - var tags = tagString.split(',');
1529 - var tagsInDOM = [ ];
1530 - // Check for tags:
1531 - for( var i in tags ){
1532 - var tagElements = document.getElementsByTagName( tags[ i ] );
1533 - for(var j = 0; j < tagElements.length; j++ ){
1534 - tagsInDOM.push( tagElements[ j ] );
1535 - if( getOne )
1536 - return tagsInDOM;
1537 - }
1538 - }
1539 - return tagsInDOM;
 1675+ // Return all the player tags:
 1676+ return tagsInDOM;
15401677 }
15411678
15421679 /**
@@ -2159,7 +2296,8 @@
21602297 '$j.ui',
21612298 'embedPlayer',
21622299 'ctrlBuilder',
2163 - '$j.cookie'
 2300+ '$j.cookie',
 2301+ 'JSON'
21642302 ],
21652303 [
21662304 '$j.ui.slider'
@@ -2224,17 +2362,20 @@
22252363
22262364 // Load the video libs:
22272365 mw.load( dependencyRequest, function() {
2228 -
2229 - // Detect supported players:
2230 - embedTypes.init();
 2366+ //Setup userConfig
 2367+ mw.setupUserConfig( function(){
 2368+ // Detect supported players:
 2369+ embedTypes.init();
 2370+
 2371+ // Remove no video html elements:
 2372+ $j( '.videonojs' ).remove();
 2373+ //mw.log(" run callback: " + callback );
 2374+
 2375+ // Run the callback with name of the module
 2376+ if( callback )
 2377+ callback( 'player' );
22312378
2232 - // Remove no video html elements:
2233 - $j( '.videonojs' ).remove();
2234 - //mw.log(" run callback: " + callback );
2235 -
2236 - // Run the callback with name of the module
2237 - if( callback )
2238 - callback( 'player' );
 2379+ } ); // setupUserConfig
22392380 } );
22402381
22412382 } ); // done with embedPlayer loader.js
@@ -2265,7 +2406,9 @@
22662407 /**
22672408 * Set DOM-ready call
22682409 * Does not use jQuery( document ).ready( ) because
2269 -* mwEmbed could have been included without jQuery.
 2410+* mwEmbed could have been included without jQuery.
 2411+*
 2412+* mw.domReady function has checks to only be run once
22702413 */
22712414 // For Mozilla / modern browsers
22722415 if ( document.addEventListener ) {
@@ -2286,7 +2429,18 @@
22872430 }
22882431 mw.domReady();
22892432 }
 2433+// If inserted into an already loaded document:
 2434+if( document.readyState == 'complete'){
 2435+ mw.domReady();
 2436+}
 2437+//And just to be sure ( for dynamic inserts ) ... check if "body" tag exists after 25ms
 2438+setTimeout( function(){
 2439+ if( document.getElementsByTagName('body')[0] ){
 2440+ mw.domReady();
 2441+ }
 2442+}, 25 );
22902443
 2444+
22912445 /*
22922446 * Store all the mwEmbed jQuery-specific bindings
22932447 * ( to be run after jQuery is available ).
Index: branches/js2-work/phase3/js2/mwEmbed/libTimedText/mw.timedText.js
@@ -6,11 +6,14 @@
77 * timed text loading request
88 * timed text edit requests
99 * timed text search & seek interface ( version 2 )
 10+ *
 11+ * @author: Michael Dale
1012 *
1113 * Some code borrowed from: http://www.annodex.net/~silvia/itext/elephant_no_skin_v2.html
1214 * ( Licenced under: MPL 1.1/GPL 2.0/LGPL 2.1 )
1315 * Contributor(s):
1416 * Silvia Pfeiffer <silvia@siliva-pfeiffer.de>
 17+ *
1518 */
1619
1720 mw.addMessages( {
@@ -106,8 +109,7 @@
107110
108111 /**
109112 * @constructor
110 - * @param {Object} embedPlayer Host player for timedText interfaces
111 - *
 113+ * @param {Object} embedPlayer Host player for timedText interfaces
112114 */
113115 init: function( embedPlayer, options ){
114116 var _this = this;
@@ -120,7 +122,7 @@
121123 embedPlayer.addHook( 'monitor', function(){
122124 _this.monitor();
123125 } )
124 - // @@TODO: Load cookie / page prefrences
 126+ // @@TODO: Load cookie / page preferences
125127
126128 // Load textSources
127129 _this.loadTextSources( function(){
@@ -137,12 +139,17 @@
138140 /**
139141 * Monitor video time and update timed text filed[s]
140142 */
141 - monitor: function(){
142 - mw.log(' timedText monitor ');
 143+ monitor: function( embedPlayer ){
 144+ //setup local refrence to currentTime:
 145+ var currentTime = embedPlayer.currentTime;
 146+
 147+ for( var i in enabledSource) {
 148+
 149+ }
143150 },
144151
145152 /**
146 - * Loads all the avaliable text sources from the inline embed
 153+ * Loads all the available text sources from the inline embed
147154 * or from a timedTextProvider
148155 */
149156 loadTextSources: function( callback ){
@@ -210,7 +217,7 @@
211218 },
212219
213220 /**
214 - * Selection of a meun item
 221+ * Selection of a menu item
215222 *
216223 * @param {Element} item Item selected
217224 */
@@ -395,10 +402,12 @@
396403 this[i] = source[i];
397404 }
398405 },
 406+
399407 /**
400408 * Function to load and parse the source text
401409 */
402410 load: function(){
 411+ var _this = this;
403412 // Set parser handler:
404413 switch( this.getMIMEType() ){
405414 case 'text/x-srt':
@@ -420,7 +429,7 @@
421430 // mw.log("Error can't load non-json src via jsonp:" + this.getSrc() )
422431 // return ;
423432 //}
424 - $j.get( this.getSrc(), function(){
 433+ $j.get( this.getSrc(), function( data ){
425434 // Parse and load captions:
426435 _this.captions = handler( data );
427436 // Update the loaded state:
Index: branches/js2-work/phase3/js2/remoteMwEmbed.js
@@ -5,7 +5,7 @@
66
77 var urlparts = getRemoteEmbedPath();
88 var mwEmbedHostPath = urlparts[0];
9 -var mwRemoteVersion = '1.1c';
 9+var mwRemoteVersion = '1.1d';
1010 var mwUseScriptLoader = true;
1111
1212 // Setup up request Params:
@@ -27,6 +27,9 @@
2828 }
2929 } );
3030
 31+/**
 32+* Page specific rewrites for mediaWiki
 33+*/
3134 function doPageSpecificRewrite() {
3235 // Add media wizard
3336 if ( wgAction == 'edit' || wgAction == 'submit' ) {
@@ -104,7 +107,7 @@
105108 }
106109 /*
107110 * This will be depreciated when we update to OggHandler
108 -* @param {Object} vidIdList List of video ids to proccess
 111+* @param {Object} vidIdList List of video ids to process
109112 */
110113 function rewrite_for_OggHandler( vidIdList ) {
111114 function procVidId( vidId ) {
@@ -183,7 +186,7 @@
184187
185188 }
186189 };
187 - // process each item in the vidIdList (with setTimeout to avoid locking)
 190+ // Process each item in the vidIdList (with setTimeout to avoid locking)
188191 procVidId( vidIdList.pop() );
189192 }
190193 function getRemoteEmbedPath() {
@@ -220,6 +223,7 @@
221224 }
222225 return rurl;
223226 }
 227+
224228 /**
225229 * Load the mwEmbed library:
226230 *
@@ -254,21 +258,22 @@
255259 rurl += '&' + mwGetReqArgs();
256260 importScriptURI( rurl );
257261 } else {
258 - // Ingore classSet (will be loaded onDemand )
 262+ // Ignore classSet (will be loaded onDemand )
259263 importScriptURI( mwEmbedHostPath + '/mwEmbed/mwEmbed.js?' + mwGetReqArgs() );
260264 }
261265 }
262266 waitMwEmbedReady( callback );
263267 }
 268+
264269 /**
265 -* waits for mwEmbed to be ready
 270+* Waits for mwEmbed to be ready
266271 */
267272 function waitMwEmbedReady( callback ) {
268273 if( ! mwCheckObjectPath( 'mw.version' ) ){
269274 setTimeout( function() {
270275 waitMwEmbedReady( callback );
271276 }, 25 );
272 - } else {
 277+ } else {
273278 // Make sure mwEmbed is "setup" by using the addOnLoadHook:
274279 mw.addOnloadHook( function(){
275280 callback();
@@ -277,6 +282,7 @@
278283 }
279284 /**
280285 * Checks an object path to see if its defined
 286+* @param {String} libVar The objectPath to be checked
281287 */
282288 function mwCheckObjectPath ( libVar ) {
283289 if ( !libVar )

Status & tagging log