r59857 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59856‎ | r59857 | r59858 >
Date:22:49, 8 December 2009
Author:dale
Status:deferred
Tags:
Comment:
* apiProxy refactor & code comment updates ( tested )
* other code comment updates
Modified paths:
  • /branches/js2-work/phase3/js2/apiProxyPage.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libMwApi/NestedCallbackIframe.html (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/libMwApi/mw.proxy.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js2/mwEmbed/skins/ctrlBuilder.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
@@ -2025,8 +2025,10 @@
20262026 },
20272027
20282028 /**
2029 - * Sets up the proxy for the remote inserts
2030 - */
 2029+ * Sets up the proxy for the remote inserts
 2030+ *
 2031+ * @param {Function} callbcak Function to call once proxy is setup.
 2032+ */
20312033 setupProxy: function( callback ) {
20322034 var _this = this;
20332035
@@ -2150,7 +2152,7 @@
21512153 * get an edit Token
21522154 * depends on upload_api_target being initialized
21532155 *
2154 - * @param {Function} callback Function to be called once the token is avaliable
 2156+ * @param {Function} callback Function to be called once the token is available
21552157 */
21562158 getEditToken: function( callback ) {
21572159 var _this = this;
@@ -2252,7 +2254,7 @@
22532255 * builds the wikitext represnetation and
22542256 * issues an api call to gennerate a preview
22552257 *
2256 - * @param {Object} resource
 2258+ * @param {Object} resource Resource to get preview text for.
22572259 */
22582260 getPreviewText: function( resource ) {
22592261 var _this = this;
@@ -2451,8 +2453,11 @@
24522454 _this.setDisplayMode( 'list' );
24532455 } );
24542456 },
 2457+
24552458 /**
2456 - * Shows pagging for a given traget for a given currentProvider
 2459+ * Shows pagging for a given target for a given currentProvider
 2460+ *
 2461+ * @param {String} target jQuery Selector for pagging Header output
24572462 */
24582463 showPagingHeader: function( target ) {
24592464 var _this = this;
@@ -2502,12 +2507,13 @@
25032508 } );
25042509 },
25052510
2506 - /*
2507 - * Select a given search provider
 2511+ /**
 2512+ * Select a given search provider
 2513+ * @param {String} provider_id Provider id to select and display
25082514 */
2509 - selectTab: function( provider ) {
2510 - js_log( 'select tab: ' + provider );
2511 - this.currentProvider = provider;
 2515+ selectTab: function( provider_id ) {
 2516+ js_log( 'select tab: ' + provider_id );
 2517+ this.currentProvider = provider_id;
25122518 if ( this.currentProvider == 'upload' ) {
25132519 this.showUploadTab();
25142520 } else {
@@ -2518,7 +2524,7 @@
25192525
25202526 /*
25212527 * Sets the dispaly mode
2522 - * @param {String} either "box" or "list"
 2528+ * @param {String} mode Either "box" or "list"
25232529 */
25242530 setDisplayMode: function( mode ) {
25252531 js_log( 'setDisplayMode:' + mode );
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js
@@ -2580,10 +2580,10 @@
25812581 /**
25822582 * Getter for Stoped state
25832583 * @return {Boolean}
2584 - * true if playing
2585 - * false if not playing
 2584+ * true if stopped
 2585+ * false if playing
25862586 */
2587 - isStoped : function() {
 2587+ isStoped: function() {
25882588 return this.thumbnail_disp;
25892589 },
25902590
@@ -2592,7 +2592,7 @@
25932593 * Monitor playback and update interface components.
25942594 * underling plugin objects are responsible for updating currentTime
25952595 */
2596 - monitor:function() {
 2596+ monitor: function() {
25972597 var _this = this;
25982598 //js_log(' ct: ' + this.currentTime + ' dur: ' + ( parseInt( this.duration ) + 1 ) + ' is seek: ' + this.seeking );
25992599 if ( this.currentTime && this.currentTime > 0 && this.duration ) {
Index: branches/js2-work/phase3/js2/mwEmbed/tests/testApiProxy.html
@@ -3,7 +3,7 @@
44 <head>
55 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
66 <title>Api Proxy Test</title>
7 -<script type="text/javascript" src="../mwEmbed.js"></script>
 7+<script type="text/javascript" src="../mwEmbed.js?debug=true"></script>
88
99 <script type="text/javascript" >
1010 //HARD coded local test:
@@ -17,7 +17,7 @@
1818 'client',
1919 {
2020 'server_frame': remote_wiki_host + remote_script_path + '/index.php/MediaWiki:ApiProxy',
21 - 'client_frame_path' : '/wiki_trunk/js2/mwEmbed/libMwApi/NestedCallbackIframe.html',
 21+ 'client_frame_path' : mw.getMwEmbedPath() + 'libMwApi/NestedCallbackIframe.html',
2222 },
2323 function(){
2424 //callback function here:
@@ -42,7 +42,7 @@
4343 'meta':'userinfo'
4444 }
4545 //we use normal do_api_req with keywork 'proxy' for the url
46 - $mw.proxy.doRequest( rObj,
 46+ mw.proxy.doRequest( rObj,
4747 function( data ){
4848 //now we get the data back for that domain
4949 if( !data.query || !data.query.userinfo ){
Index: branches/js2-work/phase3/js2/mwEmbed/libMwApi/NestedCallbackIframe.html
@@ -6,7 +6,7 @@
77 <script type="text/javascript">
88 window.onload = function (){
99 //call the nested callback in top most frame:
10 - top.$mw.proxy.nested( window.location.href.split("#")[1] || false );
 10+ top.mw.proxy.nested( window.location.href.split("#")[1] || false );
1111 }
1212 </script>
1313 </head>
Index: branches/js2-work/phase3/js2/mwEmbed/libMwApi/mw.proxy.js
@@ -52,9 +52,11 @@
5353 $.proxy = { };
5454
5555 /**
56 - * The client setup function:
 56+ * The client setup function:
 57+ *
 58+ * @param {Object} proxyConfig Holds the server_frame & client_frame_path vars
5759 */
58 - $.proxy.client = function( proxyConfig, conf ) {
 60+ $.proxy.client = function( proxyConfig ) {
5961 var _this = this;
6062 // Do client setup:
6163 if ( proxyConfig.server_frame )
@@ -63,8 +65,9 @@
6466 if ( proxyConfig.client_frame_path ) {
6567 $.proxy.client_frame_path = proxyConfig.client_frame_path;
6668 } else {
67 - // Set to default mwEmbed iframe path:
68 - $.proxy.client_frame_path = wgScriptPath + '/js2/mwEmbed/libMwApi/NestedCallbackIframe.html';
 69+ // Set to default via mediaWiki vars:
 70+
 71+ $.proxy.client_frame_path = wgServer + wgScriptPath + '/js2/mwEmbed/libMwApi/NestedCallbackIframe.html';
6972 }
7073
7174 if ( mw.parseUri( $.proxy.server_frame ).host == mw.parseUri( document.URL ).host ) {
@@ -77,18 +80,22 @@
7881 var frameProxyOk = false;
7982
8083 /**
81 - * doFrameProxy
 84+ * Does the frame proxy
8285 * Writes an iframe with a hashed value of the requestQuery
 86+ *
 87+ * @param {Object} requestQuery The api request object
8388 */
8489 $.proxy.doFrameProxy = function( requestQuery ) {
 90+
8591 var hashPack = {
86 - 'cd': mw.parseUri( document.URL ).host,
87 - 'cfp': $.proxy.client_frame_path,
88 - 'req': requestQuery
 92+ // Client domain:
 93+ 'clientFrame' : $.proxy.client_frame_path,
 94+ 'request' : requestQuery
8995 }
90 - js_log( "Do frame proxy request on src: \n" + $.proxy.server_frame + "\n" +
91 - JSON.stringify( requestQuery ) );
92 - // we can't update src's so we have to remove and add all the time :(
 96+
 97+ js_log( "Do frame proxy request on src: \n" + $.proxy.server_frame + "\n" + JSON.stringify( requestQuery ) );
 98+
 99+ // We can't update src's so we have to remove and add all the time :(
93100 // @@todo we should support frame msg system
94101 $j( '#frame_proxy' ).remove();
95102 $j( 'body' ).append( '<iframe style="display:none" id="frame_proxy" name="frame_proxy" ' +
@@ -109,6 +116,10 @@
110117 }
111118 }
112119 var lastApiReq = { };
 120+
 121+ /**
 122+ * Dialog to send the user if a proxy to the remote server could not be created
 123+ */
113124 $.proxy.proxyNotReadyDialog = function() {
114125 var buttons = { };
115126 buttons[ gM( 'mwe-re-try' ) ] = function() {
@@ -135,20 +146,28 @@
136147 buttons
137148 )
138149 }
139 - /*
140 - * doRequest
 150+ /**
141151 * Takes a requestQuery, executes the query and then calls the callback
 152+ * sets the local callback to be called once requestQuery completes
 153+ *
 154+ * @param {Object} requestQuery Api request object
 155+ * @param {Function} callback Function called once the request is complete
142156 */
143157 $.proxy.doRequest = function( requestQuery, callback ) {
144 - js_log( "doRequest:: " + JSON.stringify( reqObj ) );
145 - lastApiReq = reqObj;
 158+ js_log( "doRequest:: " + JSON.stringify( requestQuery ) );
 159+ lastApiReq = requestQuery;
146160 // setup the callback:
147161 $.proxy.callback = callback;
148162 // do the proxy req:
149163 $.proxy.doFrameProxy( requestQuery );
150164 }
 165+
151166 /**
152 - * The nested iframe action that passes its result back up to the top frame instance
 167+ * The nested iframe action that passes its result back up to the top frame instance
 168+ *
 169+ * Entry point for hashResult from nested iframe
 170+ *
 171+ * @param {Object} hashResult Value to be sent to parent frame
153172 */
154173 $.proxy.nested = function( hashResult ) {
155174 // Close the loader if present:
@@ -156,114 +175,140 @@
157176 js_log( '$.proxy.nested callback :: ' + unescape( hashResult ) );
158177 frameProxyOk = true;
159178
160 - // Try to parse the hash result:
 179+ // Try to parse the hash result
161180 try {
162 - var rObj = JSON.parse( unescape( hashResult ) );
 181+ var resultObject = JSON.parse( unescape( hashResult ) );
163182 } catch ( e ) {
164183 js_log( "Error could not parse hashResult" );
165184 }
166185
167186 // Special callback to frameProxyOk flag
168187 // (only used to test the proxy connection)
169 - if ( rObj.state == 'ok' )
 188+ if ( resultObject.state == 'ok' )
170189 return ;
171190
172 - // Pass the callback:
173 - $.proxy.callback( rObj );
 191+ // Pass the result object to the callback:
 192+ $.proxy.callback( resultObject );
174193 }
 194+
 195+
 196+
 197+
 198+
175199 /**
176 - * The server handles the actual proxy
177 - * it adds child frames pointing to the parent "blank" frames
178 - *
179 - * This is (Domain B) in the above described setup
180 - */
181 - $.proxy.server = function( proxyConfig, callback ) {
182 - /* clear the body of any html */
183 - $j( 'body' ).html( 'proxy setup' );
 200+ * API iFrame Server::
 201+ *
 202+ * Handles the server side proxy of requests
 203+ * it adds child frames pointing to the parent "blank" frames
 204+ */
 205+
 206+ /**
 207+ * Api iFrame request:
 208+ * @param {Object} requestObj Api request object
 209+ */
 210+ function doApiRequest( clientRequest ) {
 211+
 212+ // Make sure its a json format
 213+ clientRequest.request[ 'format' ] = 'json';
 214+
 215+ // Process the API request. We don't use mw.apiReq since we need to "post"
 216+ $j.post( wgScriptPath + '/api' + wgScriptExtension,
 217+ clientRequest.request,
 218+ function( data ) {
 219+ // Put it result into nested frame hash string:
 220+ outputResultsFrame( clientRequest.clientFrame, 'nested_push', JSON.parse( data ) );
 221+ }
 222+ );
 223+ }
 224+
 225+ /**
 226+ * Outputs the result object to the client domain
 227+ *
 228+ * @param {String} nestName Name of iframe
 229+ * @param {resultObj} the result to pass back to the client domain
 230+ */
 231+ function outputResultsFrame( clientFrame, nestName, resultObj ) {
 232+ $j( '#nested_push' ).remove();
 233+ // Setup the nested iframe proxy that points back to top domain:
 234+ $j( 'body' ).append(
 235+ $j('<iframe>').attr({
 236+ 'id' : nestName,
 237+ 'name' : nestName,
 238+ 'src' : clientFrame + '#' + escape( JSON.stringify( resultObj ) )
 239+ })
 240+ );
 241+ }
 242+
 243+ /**
 244+ * Api server proxy entry point:
 245+ *
 246+ * @param {Object} proxyConfig The server side proxy configuration
 247+ * @param {Function} callbcak Function to call once server is setup
 248+ *
 249+ */
 250+ $.proxy.server = function( proxyConfig, callback ) {
 251+ /**
 252+ * Clear the body of any html
 253+ */
 254+ $j( 'body' ).html( 'Proxy Setup: ' );
184255
185 - // read the anchor action from the requesting url
186 - var jmsg = unescape( mw.parseUri( document.URL ).anchor );
 256+ var clientRequest = false;
 257+
 258+ // Read the anchor action from the requesting url
 259+ var hashMsg = unescape( mw.parseUri( document.URL ).anchor );
187260 try {
188 - var aObj = JSON.parse( jmsg );
 261+ var clientRequest = JSON.parse( hashMsg );
189262 } catch ( e ) {
190263 js_log( "ProxyServer:: could not parse anchor" );
191264 }
192 - if ( !aObj.cd ) {
 265+
 266+ if ( !clientRequest || !clientRequest.clientFrame ) {
193267 js_log( "Error: no client domain provided " );
 268+ $j( 'body' ).append( "no client frame provided" );
194269 return false;
195 - }
 270+ }
196271
197 - js_log( "Setup server on: " + mw.parseUri( document.URL ).host +
198 - ' client from: ' + aObj.cd +
199 - ' to nested target: ' + aObj.cfp );
200 -
201272 // Make sure we are logged in
202273 // (its a normal mediaWiki page so all site vars should be defined)
203274 if ( !wgUserName ) {
204275 js_log( 'Error Not logged in' );
205276 return false;
206277 }
207 -
208 - var domain = aObj.cd;
209 - var nested_frame_src = 'http://' + aObj.cd + aObj.cfp;
210 - // Check the master whitelist
 278+
 279+ js_log( "Setup server on: " + mw.parseUri( document.URL ).host );
 280+ js_log('Client frame: ' + clientRequest.clientFrame );
 281+
 282+ var clientDomain = mw.parseUri( clientRequest.clientFrame ).host ;
 283+ /**
 284+ * HERE WE CHECK IF THE DOMAIN IS ALLOWED per the proxyConfig
 285+ */
 286+ // Check the master whitelist:
211287 for ( var i in proxyConfig.master_whitelist ) {
212 - if ( domain == proxyConfig.master_whitelist[ i ] ) {
 288+ if ( clientDomain == proxyConfig.master_whitelist[ i ] ) {
213289 // Do the request:
214 - return doNestedProxy( aObj.req );
 290+ return doApiRequest( clientRequest );
215291 }
216292 }
217293 // Check master blacklist
218294 for ( var i in proxyConfig.master_blacklist ) {
219 - if ( domain == proxyConfig.master_blacklist ) {
220 - js_log( 'domain: ' + domain + ' is blacklisted' );
 295+ if ( clientDomain == proxyConfig.master_blacklist ) {
 296+ js_log( 'domain: ' + clientDomain + ' is blacklisted ( no request )' );
221297 return false;
222298 }
223299 }
 300+ // FIXME Add in user based approval ::
 301+
 302+ // offer the user the ability to "approve" requested domain save to
 303+ // their user/ apiProxyDomainList.js page
 304+
224305 // FIXME grab the users whitelist for our current domain
225306 /*var local_api = wgScriptPath + '/index' + wgScriptExtension + '?title=' +
226307 'User:' + wgUserName + '/apiProxyDomainList.js' +
227308 '&action=raw&smaxage=0&gen=js';
228309 $j.get( local_api, function( data ){
229310 debugger;
230 - });*/
231 -
232 - // if still not found:
233 - js_log( "domain " + domain + " not approved" );
234 -
235 - // FIXME :: offer the user the ability to "approve" requested domain save to
236 - // their user/ apiProxyDomainList.js page
237 -
238 - function doNestedProxy( reqObj ) {
239 - js_log( "doNestedProxy to: " + nested_frame_src );
240 -
241 - // Do a quick response to establish the proxy is working
242 - // ( before we actually run the api-request )
243 - doNestedFrame ( 'nested_ok' , { 'state':'ok' } );
244 -
245 - var outputhash = escape( JSON.stringify( reqObj ) );
246 -
247 - // Add some api stuff:
248 - reqObj[ 'format' ] = 'json';
249 -
250 - // Process the api request
251 - $j.post( wgScriptPath + '/api' + wgScriptExtension,
252 - reqObj,
253 - function( data ) {
254 - // Put it into the nested frame hash string:
255 - doNestedFrame( 'nested_push', JSON.parse( data ) );
256 - }
257 - );
258 - }
259 - // Add the doNestedFrame iframe:
260 - function doNestedFrame( nestname, resultObj ) {
261 - $j( '#nested_push' ).remove();
262 - // Setup the nested proxy that points back to top domain:
263 - $j( 'body' ).append( '<iframe id="nested_push" name="nested_push" ' +
264 - 'src="' + nested_frame_src +
265 - '#' + escape( JSON.stringify( resultObj ) ) +
266 - '"></iframe>' );
267 - }
 311+ });*/
 312+
268313 }
269314
270315 } )( window.mw );
Index: branches/js2-work/phase3/js2/mwEmbed/skins/ctrlBuilder.js
@@ -1,7 +1,9 @@
22
3 -// Set the global dismissNativeWarn flag:
4 -_global['dismissNativeWarn'] = false;
 3+// Set the dismiss_playback_warning flag config
 4+// Set via config so a dismiss on one video embed applies to all video embeds.
 5+mw.setConfig( 'dismiss_playback_warning', false );
56
 7+
68 /**
79 * Msg text is inherited from embedPlayer
810 */
@@ -143,19 +145,19 @@
144146 $j( '#ffwarn_' + embedObj.id ).click( function() {
145147 if ( $j( this ).is( ':checked' ) ) {
146148 // set up a cookie for 7 days:
147 - $j.cookie( 'dismissNativeWarn', true, { expires: 7 } );
 149+ $j.cookie( 'dismiss_playback_warning', true, { expires: 7 } );
148150 // set the current instance
149 - _global['dismissNativeWarn'] = true;
 151+ mw.setConfig( 'dismiss_playback_warning', true );
150152 $j( '#gnp_' + embedObj.id ).fadeOut( 'slow' );
151153 } else {
152 - _global['adismissNativeWarn'] = false;
153 - $j.cookie( 'dismissNativeWarn', false );
 154+ mw.setConfig( 'dismiss_playback_warning', false );
 155+ $j.cookie( 'dismiss_playback_warning', false );
154156 }
155157
156158 } );
157159 }
158 - if ( ( $j.cookie( 'dismissNativeWarn' ) !== true ) &&
159 - _global['dismissNativeWarn'] === false ) {
 160+ if ( ( $j.cookie( 'dismiss_playback_warning' ) !== true ) &&
 161+ mw.getConfig( 'dismiss_playback_warning' ) === false ) {
160162 $j( '#gnp_' + embedObj.id ).fadeIn( 'slow' );
161163 }
162164 },
Index: branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js
@@ -32,7 +32,7 @@
3333
3434 /**
3535 * Default global config values. Configuration values are set via mw.setConfig
36 -* Configuration values should genneraly be set prior to dom-ready
 36+* Configuration values should generaly be set prior to dom-ready
3737 */
3838 var mwDefaultConf = {
3939 // Default skin name
@@ -749,69 +749,9 @@
750750 * @key Name of the class
751751 * @value Style sheet path
752752 */
753 - stylePaths : { },
 753+ stylePaths : { },
754754
755 -
756755 /**
757 - * Load a set of scripts.
758 - * Will issue many load requests or package the request for the script-loader
759 - *
760 - * @param {Object} loadSet Set of scripts to be loaded
761 - * @param {Function} callback Function to call once all scripts are loaded.
762 - */
763 - loadMany: function( loadSet, callback ){
764 - //Setup up the local "loadState"
765 - var loadState = { };
766 - // Check if its a dependency set ( nested objects )
767 - if( typeof loadSet [ 0 ] == 'object' ){
768 - //Load sets of classes ( to preserver order for some browsers )
769 - this.loadDependencyChain( loadSet, callback );
770 - return ;
771 - }
772 -
773 - // Set the initial load state for every item in the loadSet
774 - for( var i in loadSet ){
775 - var loadName = loadSet[ i ];
776 - loadState[ loadName ] = 0;
777 - }
778 -
779 - // Issue the load request check check loadState to see if we are "done"
780 - for( var i in loadSet ){
781 - var loadName = loadSet[ i ];
782 - $.load( loadName, function ( loadName ){
783 - loadState[ loadName ] = 1;
784 -
785 - var loadDone = true;
786 - for( var j in loadState ){
787 - if( loadState[ j ] === 0 )
788 - loadDone = false;
789 - }
790 - // Run the parent scope callback for "loadMany"
791 - if( loadDone )
792 - callback();
793 - } );
794 - }
795 - },
796 -
797 - /**
798 - * Load a sets of scripts satisfy dependency order for browsers that execute out of order
799 - *
800 - * @param {Object} loadChain A set of javascript arrays to be loaded.
801 - * Sets are requested in array order.
802 - */
803 - loadDependencyChain: function( loadChain, callback ){
804 - var _this = this;
805 - // Load with dependency checks
806 - this.load( loadChain.shift(), function() {
807 - if ( loadChain.length != 0 ) {
808 - _this.loadDependencyChain( loadChain, callback );
809 - } else {
810 - callback();
811 - }
812 - } );
813 - },
814 -
815 - /**
816756 * Core load function:
817757 *
818758 * @param {Mixed} loadRequest:
@@ -873,7 +813,71 @@
874814 js_log( "Error could not handle load request" );
875815 },
876816
 817+
877818 /**
 819+ * Load a set of scripts.
 820+ * Will issue many load requests or package the request for the script-loader
 821+ *
 822+ * @param {Object} loadSet Set of scripts to be loaded
 823+ * @param {Function} callback Function to call once all scripts are loaded.
 824+ */
 825+ loadMany: function( loadSet, callback ){
 826+
 827+ //Setup up the local "loadState"
 828+ var loadState = { };
 829+
 830+ // Check if its a dependency set ( nested objects )
 831+ if( typeof loadSet [ 0 ] == 'object' ){
 832+ //Load sets of classes ( to preserver order for some browsers )
 833+ this.loadDependencyChain( loadSet, callback );
 834+ return ;
 835+ }
 836+
 837+ // Set the initial load state for every item in the loadSet
 838+ for( var i in loadSet ){
 839+ var loadName = loadSet[ i ];
 840+ loadState[ loadName ] = 0;
 841+ }
 842+
 843+ // Issue the load request check check loadState to see if we are "done"
 844+ for( var i in loadSet ){
 845+ var loadName = loadSet[ i ];
 846+ $.load( loadName, function ( loadName ){
 847+ loadState[ loadName ] = 1;
 848+
 849+ var loadDone = true;
 850+ for( var j in loadState ){
 851+ if( loadState[ j ] === 0 )
 852+ loadDone = false;
 853+ }
 854+
 855+ // Run the parent scope callback for "loadMany"
 856+ if( loadDone )
 857+ callback();
 858+ } );
 859+ }
 860+ },
 861+
 862+ /**
 863+ * Load a sets of scripts satisfy dependency order for browsers that execute out of order
 864+ *
 865+ * @param {Object} loadChain A set of javascript arrays to be loaded.
 866+ * Sets are requested in array order.
 867+ */
 868+ loadDependencyChain: function( loadChain, callback ){
 869+ var _this = this;
 870+ // Load with dependency checks
 871+ this.load( loadChain.shift(), function() {
 872+ if ( loadChain.length != 0 ) {
 873+ _this.loadDependencyChain( loadChain, callback );
 874+ } else {
 875+ callback();
 876+ }
 877+ } );
 878+ },
 879+
 880+
 881+ /**
878882 * Loads javascript associated with a className
879883 *
880884 * @param {String} className Name of class to load
@@ -884,7 +888,7 @@
885889 // Make sure the class is not already defined:
886890 if ( $.isset( className ) ){
887891 js_log( 'Class ( ' + className + ' ) already defined ' );
888 - callback();
 892+ callback( className );
889893 return ;
890894 }
891895
@@ -1269,7 +1273,7 @@
12701274 url += '?' + mw.getUrlParam();
12711275 }
12721276
1273 - // Return if style sheet is already included:
 1277+ // Check if style sheet is already included:
12741278 var foundSheet = false;
12751279 $j( 'link' ).each( function(){
12761280 if( $j( this) .attr( 'href' ) == url )
@@ -2059,21 +2063,21 @@
20602064 *
20612065 * @param mode is either 'server' or 'client'
20622066 */
2063 - $.apiProxy = function( mode, pConf, callback ) {
 2067+ $.apiProxy = function( mode, proxyConfig, callback ) {
20642068 js_log( 'do apiProxy setup' );
20652069 mw.load( [
20662070 'mw.proxy',
20672071 'JSON'
2068 - ], function() {
 2072+ ], function() {
20692073 // do the proxy setup or
20702074 if ( mode == 'client' ) {
20712075 // just do the setup (no callbcak for client setup)
2072 - mw.proxy.client( pConf );
 2076+ mw.proxy.client( proxyConfig );
20732077 if ( callback )
20742078 callback();
20752079 } else if ( mode == 'server' ) {
2076 - // do the request with the callback
2077 - mw.proxy.server( pConf , callback );
 2080+ // Do the request with the callback
 2081+ mw.proxy.server( proxyConfig , callback );
20782082 }
20792083 } );
20802084 }
@@ -2440,6 +2444,7 @@
24412445 }
24422446 return new_url;
24432447 }
 2448+
24442449 /**
24452450 * Given a float number of seconds, returns npt format response.
24462451 *
@@ -2692,7 +2697,7 @@
26932698 * Utility functions
26942699 */
26952700 function js_log( string ) {
2696 - // Add any prepend debug strings if necessary (used for cross browser)
 2701+ // Add any prepend debug strings if necessary
26972702 if ( mw.getConfig( 'pre-append-log' ) )
26982703 string = mw.getConfig( 'pre-append-log' ) + string;
26992704
Index: branches/js2-work/phase3/js2/apiProxyPage.js
@@ -8,7 +8,7 @@
99 * Since this is proxy server set a pre-append debug flag to know which debug msgs are coming from where
1010 */
1111
12 -mw.getConfig( 'pre-append-log' ) = 'Proxy';
 12+mw.setConfig( 'pre-append-log', 'Proxy:');
1313
1414 if ( !mwApiProxyConfig )
1515 var mwApiProxyConfig = { };
@@ -16,13 +16,15 @@
1717 // The default mwApiProxyConfig config
1818 // (presently hard coded but should read from user and site config)
1919 var mwApiProxyDefaultConfig = {
20 - 'master_whitelist' : [ 'en.wikipedia.org', 'localhost', '127.1.1.100' ],
21 - 'master_blacklist' : []
 20+ 'master_whitelist' : [ 'en.wikipedia.org', 'localhost', '127.1.1.100' ],
 21+ 'master_blacklist' : []
2222 };
2323
2424 // User white_list should also be checked and configured at runtime.
2525 mw.addOnloadHook( function() {
26 - // build our configuration from the default and mwApiProxyConfig vars
 26+
 27+ // Build our configuration from the default and mwApiProxyConfig vars
2728 mwApiProxyConfig = $j.extend( true, mwApiProxyDefaultConfig, mwApiProxyConfig );
2829 $j.apiProxy( 'server', mwApiProxyConfig );
 30+
2931 } );
Index: branches/js2-work/phase3/js2/remoteMwEmbed.js
@@ -28,14 +28,14 @@
2929 // Add media wizard
3030 if ( wgAction == 'edit' || wgAction == 'submit' ) {
3131 var jsSetEdit = [ 'remoteSearchDriver', '$j.fn.textSelection', '$j.ui', '$j.ui.sortable' ]
32 - mwr_load_mwEmbed( jsSetEdit, function() {
 32+ loadMwEmbed( jsSetEdit, function() {
3333 loadExternalJs( mwEmbedHostPath + '/editPage.js?' + mwGetReqArgs() );
3434 } );
3535 }
3636
3737 // Timed text display:
3838 if ( wgPageName.indexOf( "TimedText" ) === 0 ) {
39 - mwr_load_mwEmbed( function() {
 39+ loadMwEmbed( function() {
4040 // Load with mw loader to get localized interface:
4141 mw.load( ['mvTimeTextEdit'], function() {
4242 // Could run init here (but mvTimeTextEdit already included onLoad actions)
@@ -47,7 +47,7 @@
4848 if ( wgPageName == "Special:Upload" ) {
4949 var jsSetUpload = [ 'mvBaseUploadInterface', 'mvFirefogg' , '$j.ui',
5050 '$j.ui.progressbar', '$j.ui.dialog', '$j.ui.draggable' ];
51 - mwr_load_mwEmbed( jsSetUpload, function() {
 51+ loadMwEmbed( jsSetUpload, function() {
5252 loadExternalJs( mwEmbedHostPath + '/uploadPage.js?' + mwGetReqArgs() );
5353 } );
5454 }
@@ -55,7 +55,7 @@
5656 // Special api proxy page
5757 if ( wgPageName == 'MediaWiki:ApiProxy' ) {
5858 var wgEnableIframeApiProxy = true;
59 - mwr_load_mwEmbed( [ 'mw.proxy' ], function() {
 59+ loadMwEmbed( [ 'mw.proxy' ], function() {
6060 loadExternalJs( mwEmbedHostPath + '/apiProxyPage.js?' + mwGetReqArgs() );
6161 } );
6262 }
@@ -78,7 +78,7 @@
7979 if ( navigator.userAgent && navigator.userAgent.indexOf("Firefox") != -1 )
8080 jsSetVideo.push( 'nativeEmbed' );
8181
82 - mwr_load_mwEmbed( jsSetVideo, function() {
 82+ loadMwEmbed( jsSetVideo, function() {
8383 mvJsLoader.embedPlayerCheck( function() {
8484 // Do utility rewrite of OggHandler content:
8585 rewrite_for_OggHandler( vidIdList );
@@ -197,14 +197,17 @@
198198 return rurl;
199199 }
200200 /**
 201+* Load the mwEmbed library:
 202+*
201203 * @param {mixed} function or classSet to preload
202204 * classSet saves round trips to the server by grabbing things we will likely need in the first request.
203205 * ( this is essentially a shortcut to mv_jqueryBindings in mwEmbed.js )
204206 * @param {callback} function callback to be called once mwEmbed is ready
205207 */
206 -function mwr_load_mwEmbed( classSet, callback ) {
 208+function loadMwEmbed( classSet, callback ) {
207209 if( typeof classSet == 'function')
208210 callback = classSet;
 211+
209212 // Inject mwEmbed if needed
210213 if ( typeof mw == 'undefined' ) {
211214 if ( ( mwReqParam['uselang'] || mwReqParam['useloader'] ) && mwUseScriptLoader ) {
@@ -218,7 +221,7 @@
219222 // Add requested classSet
220223 for( var i=0; i < classSet.length; i++ ){
221224 var cName = classSet[i];
222 - if( !mwr_check_obj_path( cName ) ){
 225+ if( !mwCheckObjectPath( cName ) ){
223226 rurl += ',' + cName;
224227 }
225228 }
@@ -232,20 +235,24 @@
233236 importScriptURI( mwEmbedHostPath + '/mwEmbed/mwEmbed.js?' + mwGetReqArgs() );
234237 }
235238 }
236 - mwr_check_for_mwEmbed( callback );
 239+ waitMwEmbedReady( callback );
237240 }
238 -
239 -function mwr_check_for_mwEmbed( callback ) {
240 - if ( typeof mw == 'undefined' ) {
 241+/**
 242+* waits for mwEmbed to be ready
 243+*/
 244+function waitMwEmbedReady( callback ) {
 245+ if( ! mwCheckObjectPath( 'mw.version' ) ){
241246 setTimeout( function() {
242 - mwr_check_for_mwEmbed( callback );
 247+ waitMwEmbedReady( callback );
243248 }, 25 );
244249 } else {
245250 callback();
246251 }
247252 }
248 -
249 -function mwr_check_obj_path ( libVar ) {
 253+/**
 254+* Checks an object path to see if its defined
 255+*/
 256+function mwCheckObjectPath ( libVar ) {
250257 if ( !libVar )
251258 return false;
252259 var objPath = libVar.split( '.' )

Status & tagging log