Index: branches/js2-work/phase3/js/mwEmbed/tests/testApiProxy.html |
— | — | @@ -9,23 +9,14 @@ |
10 | 10 | //HARD coded local test: |
11 | 11 | var remote_wiki_host = 'http://test.wikipedia.org'; |
12 | 12 | var remote_script_path = '/w'; |
| 13 | +var remote_api_url = remote_wiki_host + remote_script_path + '/api.php'; |
13 | 14 | |
14 | 15 | mw.ready( function(){ |
15 | | - $j('#hostName').text( remote_wiki_host ); |
16 | | - //run the api-proxy setup: |
17 | | - $j.apiProxy( |
18 | | - 'client', |
19 | | - { |
20 | | - 'server_frame': remote_wiki_host + remote_script_path + '/index.php/MediaWiki:ApiProxy', |
21 | | - 'client_frame_path' : mw.getMwEmbedPath() + 'libMwApi/NestedCallbackIframe.html', |
22 | | - }, |
23 | | - function(){ |
24 | | - //callback function here: |
25 | | - $j('#setupDone').show('slow'); |
26 | | - $j('#doHello').click( doHello ); |
27 | | - $j('#doAppend').click(doAppend); |
28 | | - } |
29 | | - ); |
| 16 | + $j('#hostName').text( remote_wiki_host ); |
| 17 | + //callback function here: |
| 18 | + $j('#setupDone').show('slow'); |
| 19 | + $j('#doHello').click( doHello ); |
| 20 | + $j('#doAppend').click( doAppend ); |
30 | 21 | }); |
31 | 22 | function doHello(){ |
32 | 23 | mw.log('to a hello user'); |
— | — | @@ -42,8 +33,7 @@ |
43 | 34 | 'meta':'userinfo' |
44 | 35 | } |
45 | 36 | // Do proxy request |
46 | | - mw.proxy.doRequest( rObj, |
47 | | - function( data ){ |
| 37 | + mw.getJSON( remote_api_url, rObj, function( data ){ |
48 | 38 | //now we get the data back for that domain |
49 | 39 | if( !data.query || !data.query.userinfo ){ |
50 | 40 | mw.log("Error no query.userinfo "); |
— | — | @@ -58,10 +48,10 @@ |
59 | 49 | function doAppend(){ |
60 | 50 | $j('#appendTarget').html( mw.loading_spinner() ); |
61 | 51 | //get user name |
62 | | - getUserName(function(userName){ |
| 52 | + getUserName( function(userName){ |
63 | 53 | var eTitle = 'User_talk:' + userName; |
64 | | - //get a edit token |
65 | | - mw.getToken( eTitle, 'proxy', function( token ){ |
| 54 | + // Get a edit token |
| 55 | + mw.getToken( remote_api_url, eTitle, function( token ) { |
66 | 56 | mw.log("got token: " + token) ; |
67 | 57 | var request = { |
68 | 58 | 'action':'edit', |
— | — | @@ -70,7 +60,7 @@ |
71 | 61 | 'appendtext': "\n\n==== Hello from Api proxy At: " + Date() + " ====", |
72 | 62 | 'token': token |
73 | 63 | } |
74 | | - mw.getJSON('proxy', request, function( result ){ |
| 64 | + mw.getJSON( remote_api_url, request, function( result ){ |
75 | 65 | if(result.edit && result.edit.newrevid){ |
76 | 66 | $j('#appendTarget').html( "success: " + JSON.stringify ( result) ); |
77 | 67 | url = remote_wiki_host + remote_script_path + '/index.php/'; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedTextEdit.js |
— | — | @@ -94,7 +94,8 @@ |
95 | 95 | $j('<a>') |
96 | 96 | .attr( 'href', '#tab-' + edit_stage_id ) |
97 | 97 | .append( |
98 | | - $j('<span style="float:left;">') |
| 98 | + $j('<span />') |
| 99 | + .css( "float","left" ) |
99 | 100 | .addClass( 'ui-icon ui-icon-' + editStage.icon ) |
100 | 101 | , |
101 | 102 | $j('<span>') |
— | — | @@ -155,12 +156,16 @@ |
156 | 157 | // Check if user has XHR file upload support & we are on the target wiki |
157 | 158 | |
158 | 159 | $target.append( |
159 | | - $j('<div class="leftcolumn">') |
| 160 | + $j('<div />') |
| 161 | + .addClass( "leftcolumn" ) |
160 | 162 | .append('<h4>') |
161 | 163 | .text( gM('mwe-upload-text') ), |
162 | | - $j('<div class="rightcolumn">') |
| 164 | + $j('<div />') |
| 165 | + .addClass( 'rightcolumn' ) |
163 | 166 | .append( |
164 | | - $j('<span id="timed-text-rightcolum-desc">').append( |
| 167 | + $j( '<span />' ) |
| 168 | + .attr('id', "timed-text-rightcolum-desc") |
| 169 | + .append( |
165 | 170 | $j('<h4>') |
166 | 171 | .text( gM('mwe-upload-text-desc-title') ), |
167 | 172 | $j('<i>').text ( gM( 'mwe-upload-text-desc-help' ) ), |
— | — | @@ -190,14 +195,25 @@ |
191 | 196 | 'width':'300px', |
192 | 197 | 'float': 'left' |
193 | 198 | }).append( |
194 | | - '<input type="file" id="timed-text-file-upload"></input><br />' |
| 199 | + $j('<input />') |
| 200 | + .attr( { |
| 201 | + 'type': "file", |
| 202 | + 'id' : "timed-text-file-upload" |
| 203 | + }), |
| 204 | + $j('<br />') |
195 | 205 | ) |
196 | 206 | ) |
197 | 207 | |
198 | 208 | |
199 | 209 | $target.append( |
200 | 210 | //Get a little helper input filed to update the language |
201 | | - $j('<input id="timed-text-langKey-input" type="text" maxlength="10" size="3">') |
| 211 | + $j('<input />') |
| 212 | + .attr( { |
| 213 | + 'id' : "timed-text-langKey-input", |
| 214 | + 'type' : "text", |
| 215 | + 'maxlength' : "10", |
| 216 | + 'size' :"3" |
| 217 | + } ) |
202 | 218 | .change(function(){ |
203 | 219 | var langKey = $j(this).val(); |
204 | 220 | if( mw.languages[ langKey ] ){ |
— | — | @@ -277,7 +293,10 @@ |
278 | 294 | |
279 | 295 | //Add an upload button: |
280 | 296 | $target.append( |
281 | | - $j('<div style="clear: both"></div><br /><br />'), |
| 297 | + $j('<div />') |
| 298 | + .css('clear', 'both'), |
| 299 | + $j('<br />'), |
| 300 | + $j('<br />'), |
282 | 301 | $j.button( { |
283 | 302 | 'style': { 'float' : 'left' }, |
284 | 303 | 'text': gM('mwe-upload-text'), |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.Firefogg.js |
— | — | @@ -907,7 +907,7 @@ |
908 | 908 | } |
909 | 909 | |
910 | 910 | // No edit token. Fetch it asynchronously and then do the upload. |
911 | | - mw.getToken( 'File:'+ _this.formData['filename'], _this.api_url, function( editToken ) { |
| 911 | + mw.getToken( _this.api_url, 'File:'+ _this.formData['filename'], function( editToken ) { |
912 | 912 | if( !editToken || editToken == '+\\' ) { |
913 | 913 | _this.updateProgressWin( gM( 'fogg-badtoken' ), gM( 'fogg-badtoken' ) ); |
914 | 914 | return false; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -2397,7 +2397,7 @@ |
2398 | 2398 | } |
2399 | 2399 | } ); |
2400 | 2400 | // Get the edit token |
2401 | | - _this.getEditToken( function( token ) { |
| 2401 | + mw.getToken( _this.upload_api_target, function( token ) { |
2402 | 2402 | uploader.editToken = token; |
2403 | 2403 | |
2404 | 2404 | // Close the loader now that we are ready to present the progress dialog:: |
— | — | @@ -2413,29 +2413,6 @@ |
2414 | 2414 | }, |
2415 | 2415 | |
2416 | 2416 | /** |
2417 | | - * get an edit Token |
2418 | | - * depends on upload_api_target being initialized |
2419 | | - * |
2420 | | - * @param {Function} callback Function to be called once the token is available |
2421 | | - */ |
2422 | | - getEditToken: function( callback ) { |
2423 | | - var _this = this; |
2424 | | - if ( _this.upload_api_target != 'proxy' ) { |
2425 | | - // (if not a proxy) first try to get the token from the page: |
2426 | | - var editToken = $j( "input[name='wpEditToken']" ).val(); |
2427 | | - if ( editToken ) { |
2428 | | - callback( editToken ); |
2429 | | - return; |
2430 | | - } |
2431 | | - } |
2432 | | - // @@todo try to load over ajax if( _this.local_wiki_api_url ) is set |
2433 | | - // ( for cases where inserting from a normal page view (that did not have wpEditToken) |
2434 | | - mw.getToken( _this.upload_api_target, function( token ) { |
2435 | | - callback( token ); |
2436 | | - } ); |
2437 | | - }, |
2438 | | - |
2439 | | - /** |
2440 | 2417 | * Shows a preview of the given resource |
2441 | 2418 | */ |
2442 | 2419 | showPreview: function( resource ) { |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/jquery.simpleUploadForm.js |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | } |
48 | 48 | |
49 | 49 | // Get an edit Token for "uploading" |
50 | | - mw.getToken( 'File:MyRandomFileTokenCheck.jpg', options.api_target, function( eToken ) { |
| 50 | + mw.getToken( options.api_target, 'File:MyRandomFileTokenCheck.jpg', function( eToken ) { |
51 | 51 | if ( !eToken || eToken == '+\\' ) { |
52 | 52 | $( _this.selector ).html( gM( 'mwe-error_not_loggedin' ) ); |
53 | 53 | return false; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.Sequencer.js |
— | — | @@ -537,19 +537,13 @@ |
538 | 538 | this.sequenceEditToken = $j( 'input[wpEditToken]' ).val(); |
539 | 539 | |
540 | 540 | if ( typeof this.sequenceEditToken == 'undefined' && this.getLocalApiUrl() != null ) { |
541 | | - mw.getToken( _this.plObj.mTitle, _this.getLocalApiUrl(), |
542 | | - function( token ) { |
| 541 | + mw.getToken( _this.getLocalApiUrl(), _this.plObj.mTitle, function( token ) { |
543 | 542 | if ( token ) { |
544 | 543 | _this.sequenceEditToken = token; |
545 | 544 | _this.updateSeqSaveButtons(); |
546 | 545 | } |
547 | | - } |
548 | | - ); |
549 | | - get_mw_token( _this.plObj.mTalk, _this.getLocalApiUrl(), |
550 | | - function( token ) { |
551 | | - _this.clipboardEditToken = token; |
552 | | - } |
553 | | - ); |
| 546 | + } ); |
| 547 | + |
554 | 548 | // also grab permissions for sending clipboard commands to the server |
555 | 549 | |
556 | 550 | // (calling the sequencer inline) try and get edit token via api call: |
Index: branches/js2-work/phase3/js/mwEmbed/modules/ApiProxy/mw.proxy.js |
— | — | @@ -1,4 +1,4 @@ |
2 | | -/* |
| 2 | +/** |
3 | 3 | * |
4 | 4 | * Api proxy system |
5 | 5 | * |
— | — | @@ -55,19 +55,21 @@ |
56 | 56 | * @param {Object} proxyConfig Proxy configuration |
57 | 57 | * @param {Function} callback The function called once proxy request is done |
58 | 58 | */ |
59 | | -$.apiProxy = function( mode, proxyConfig, callback ) { |
60 | | - mw.log( 'do apiProxy setup' ); |
61 | | - // do the proxy setup or |
62 | | - if ( mode == 'client' ) { |
63 | | - // just do the setup (no callbcak for client setup) |
64 | | - mw.proxy.client( proxyConfig ); |
65 | | - if ( callback ) |
66 | | - callback(); |
67 | | - } else if ( mode == 'server' ) { |
68 | | - // Do the request with the callback |
69 | | - mw.proxy.server( proxyConfig , callback ); |
| 59 | +( function( $ ) { |
| 60 | + $.apiProxy = function( mode, proxyConfig, callback ) { |
| 61 | + mw.log( 'do apiProxy setup' ); |
| 62 | + // do the proxy setup or |
| 63 | + if ( mode == 'client' ) { |
| 64 | + // just do the setup (no callbcak for client setup) |
| 65 | + mw.proxy.client( proxyConfig ); |
| 66 | + if ( callback ) |
| 67 | + callback(); |
| 68 | + } else if ( mode == 'server' ) { |
| 69 | + // Do the request with the callback |
| 70 | + mw.proxy.server( proxyConfig , callback ); |
| 71 | + } |
70 | 72 | } |
71 | | -} |
| 73 | +} )( jQuery ); |
72 | 74 | |
73 | 75 | ( function( $ ) { |
74 | 76 | |
— | — | @@ -91,9 +93,8 @@ |
92 | 94 | if ( proxyConfig.client_frame_path ) { |
93 | 95 | $.proxy.client_frame_path = proxyConfig.client_frame_path; |
94 | 96 | } else { |
95 | | - // Set to default via mediaWiki vars: |
96 | | - |
97 | | - $.proxy.client_frame_path = wgServer + wgScriptPath + '/js/mwEmbed/libMwApi/NestedCallbackIframe.html'; |
| 97 | + // Set to default via mediaWiki vars: |
| 98 | + $.proxy.client_frame_path = wgServer + wgScriptPath + '/js/mwEmbed/modules/ApiProxy/NestedCallbackIframe.html'; |
98 | 99 | } |
99 | 100 | |
100 | 101 | if ( mw.isLocalDomain( $.proxy.server_frame ) ) { |
— | — | @@ -190,14 +191,14 @@ |
191 | 192 | |
192 | 193 | /** |
193 | 194 | * The nested iframe action that passes its result back up to the top frame instance |
194 | | - * |
| 195 | + * |
195 | 196 | * Entry point for hashResult from nested iframe |
196 | 197 | * |
197 | 198 | * @param {Object} hashResult Value to be sent to parent frame |
198 | 199 | */ |
199 | 200 | $.proxy.nested = function( hashResult ) { |
200 | 201 | // Close the loader if present: |
201 | | - $j.closeLoaderDialog(); |
| 202 | + mw.closeLoaderDialog(); |
202 | 203 | mw.log( '$.proxy.nested callback :: ' + unescape( hashResult ) ); |
203 | 204 | frameProxyOk = true; |
204 | 205 | |
— | — | @@ -217,7 +218,6 @@ |
218 | 219 | $.proxy.callback( resultObject ); |
219 | 220 | } |
220 | 221 | |
221 | | - |
222 | 222 | |
223 | 223 | |
224 | 224 | |
— | — | @@ -250,12 +250,13 @@ |
251 | 251 | /** |
252 | 252 | * Outputs the result object to the client domain |
253 | 253 | * |
254 | | - * @param {String} nestName Name of iframe |
| 254 | + * @param {clientFrame} clientFrame Client frame name |
| 255 | + * @param {String} nestName Name of iframe |
255 | 256 | * @param {resultObj} the result to pass back to the client domain |
256 | 257 | */ |
257 | 258 | function outputResultsFrame( clientFrame, nestName, resultObj ) { |
258 | 259 | $j( '#nested_push' ).remove(); |
259 | | - // Setup the nested iframe proxy that points back to top domain: |
| 260 | + // Setup the nested iframe proxy that points back to top domain: |
260 | 261 | $j( 'body' ).append( |
261 | 262 | $j('<iframe>').attr({ |
262 | 263 | 'id' : nestName, |
— | — | @@ -308,7 +309,14 @@ |
309 | 310 | |
310 | 311 | /** |
311 | 312 | * HERE WE CHECK IF THE DOMAIN IS ALLOWED per the proxyConfig |
312 | | - */ |
| 313 | + */ |
| 314 | + // Check master blacklist |
| 315 | + for ( var i in proxyConfig.master_blacklist ) { |
| 316 | + if ( clientDomain == proxyConfig.master_blacklist ) { |
| 317 | + mw.log( 'domain: ' + clientDomain + ' is blacklisted ( no request )' ); |
| 318 | + return false; |
| 319 | + } |
| 320 | + } |
313 | 321 | // Check the master whitelist: |
314 | 322 | for ( var i in proxyConfig.master_whitelist ) { |
315 | 323 | if ( clientDomain == proxyConfig.master_whitelist[ i ] ) { |
— | — | @@ -316,14 +324,7 @@ |
317 | 325 | return doApiRequest( clientRequest ); |
318 | 326 | } |
319 | 327 | } |
320 | | - |
321 | | - // Check master blacklist |
322 | | - for ( var i in proxyConfig.master_blacklist ) { |
323 | | - if ( clientDomain == proxyConfig.master_blacklist ) { |
324 | | - mw.log( 'domain: ' + clientDomain + ' is blacklisted ( no request )' ); |
325 | | - return false; |
326 | | - } |
327 | | - } |
| 328 | + |
328 | 329 | // FIXME Add in user based approval :: |
329 | 330 | |
330 | 331 | // offer the user the ability to "approve" requested domain save to |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -1360,19 +1360,18 @@ |
1361 | 1361 | |
1362 | 1362 | /** |
1363 | 1363 | * mediaWiki JSON a wrapper for jQuery getJSON: |
1364 | | - * $j.getJSON( url, [data], [callback] ) |
1365 | 1364 | * |
1366 | 1365 | * The mediaWiki version lets you skip the url part |
1367 | 1366 | * mw.getJSON( [url], data, callback ); |
1368 | 1367 | * |
1369 | | - * Lets you assume a few things: |
| 1368 | + * Lets you assume: |
1370 | 1369 | * url is optional |
1371 | 1370 | * ( If the first argument is not a string we assume a local mediaWiki api request ) |
1372 | 1371 | * callback parameter is not needed we setup the callback automatically |
1373 | 1372 | * url param 'action'=>'query' is assumed ( if not set to something else in the "data" param |
1374 | 1373 | * format is set to "json" automatically |
1375 | 1374 | * automatically issues request over "POST" if action={postActions} |
1376 | | - * ~soon~ will setup apiProxy where needed. |
| 1375 | + * automatically will setup apiProxy where needed. |
1377 | 1376 | * |
1378 | 1377 | * @param {Mixed} url or data request |
1379 | 1378 | * @param {Mixed} data or callback |
— | — | @@ -1396,8 +1395,7 @@ |
1397 | 1396 | callback = ( typeof arg2 == 'function') ? arg2 : false; |
1398 | 1397 | if( ! callback && ( typeof arg3 == 'function') ){ |
1399 | 1398 | callback = arg3; |
1400 | | - } |
1401 | | - |
| 1399 | + } |
1402 | 1400 | |
1403 | 1401 | // Make sure we got a url: |
1404 | 1402 | if( !url ){ |
— | — | @@ -1406,26 +1404,44 @@ |
1407 | 1405 | } |
1408 | 1406 | |
1409 | 1407 | // Add default action if unset: |
1410 | | - if( !data['action'] ) |
| 1408 | + if( !data['action'] ){ |
1411 | 1409 | data['action'] = 'query'; |
| 1410 | + } |
1412 | 1411 | |
1413 | 1412 | // Add default format if not set: |
1414 | | - if( !data['format'] ) |
| 1413 | + if( !data['format'] ){ |
1415 | 1414 | data['format'] = 'json'; |
| 1415 | + } |
1416 | 1416 | |
1417 | | - mw.log("run getJSON: " + mw.replaceUrlParams(url, data ) ); |
1418 | | - |
1419 | | - // Check if we need to setup proxy or do the request as a "post" |
1420 | | - if( $j.inArray( data['action'], mw.getConfig( 'apiPostActions' ) ) != -1 ){ |
| 1417 | + mw.log("run getJSON: " + mw.replaceUrlParams( url, data ) ); |
| 1418 | + // Check if the request requires a "post" (that does not work with callbacks cross domain) |
| 1419 | + if( mw.checkRequestPost( data ) ){ |
| 1420 | + // Check if we need to setup a proxy |
1421 | 1421 | if( ! mw.isLocalDomain( url ) ){ |
1422 | | - mw.log( "Error:: Do setup proxy here" ); |
1423 | | - return ; |
| 1422 | + // Load the proxy and issue the request |
| 1423 | + mw.load( 'ApiProxy', function(){ |
| 1424 | + var parsedUrl = mw.parseUri( url ); |
| 1425 | + var server_frame = parsedUrl.protocol + '://' + parsedUrl.authority + '/w/index.php/MediaWiki:ApiProxy'; |
| 1426 | + $j.apiProxy( |
| 1427 | + 'client', |
| 1428 | + { |
| 1429 | + // NOTE:: we need to setup a special page rather than the rewrite hack I use bellow: |
| 1430 | + // The rewrite hack is very slow cuz it loads the whole mediaWiki interface & skin |
| 1431 | + 'server_frame' : server_frame, |
| 1432 | + 'client_frame_path' : mw.getMwEmbedPath() + 'modules/ApiProxy/NestedCallbackIframe.html', |
| 1433 | + }, |
| 1434 | + function(){ |
| 1435 | + mw.proxy.doRequest( data, callback ) |
| 1436 | + } |
| 1437 | + ) |
| 1438 | + }); |
1424 | 1439 | }else{ |
1425 | | - $j.post( url, data, callback, 'json'); |
1426 | | - return ; |
| 1440 | + // Do the request an ajax post |
| 1441 | + $j.post( url, data, callback, 'json'); |
1427 | 1442 | } |
| 1443 | + return ; |
1428 | 1444 | } |
1429 | | - //If cross domain setup a callback: |
| 1445 | + // If cross domain setup a callback: |
1430 | 1446 | if( ! mw.isLocalDomain( url ) ){ |
1431 | 1447 | if( url.indexOf( 'callback=' ) == -1 || data[ 'callback' ] == -1 ){ |
1432 | 1448 | // jQuery specific: ( second ? is replaced with the callback ) |
— | — | @@ -1434,9 +1450,29 @@ |
1435 | 1451 | } |
1436 | 1452 | // Pass off the jQuery getJSON request: |
1437 | 1453 | $j.getJSON( url, data, callback ); |
1438 | | - } |
| 1454 | + } |
1439 | 1455 | |
1440 | 1456 | /** |
| 1457 | + * Checks if a mw request data requires a proxy or not |
| 1458 | + * @param {Object} |
| 1459 | + * @return {Boolean} |
| 1460 | + * true if the request requires a proxy |
| 1461 | + * false if the request does not |
| 1462 | + */ |
| 1463 | + mw.checkRequestPost = function ( data ){ |
| 1464 | + if( $j.inArray( data['action'], mw.getConfig( 'apiPostActions' ) ) != -1 ){ |
| 1465 | + return true; |
| 1466 | + } |
| 1467 | + if( data['prop'] == 'info' && data['intoken'] ){ |
| 1468 | + return true; |
| 1469 | + } |
| 1470 | + if( data['meta'] = 'userinfo' ){ |
| 1471 | + return true; |
| 1472 | + } |
| 1473 | + return false; |
| 1474 | + } |
| 1475 | + |
| 1476 | + /** |
1441 | 1477 | * Metavid specific roe request helper function |
1442 | 1478 | * |
1443 | 1479 | * NOTE: depreciated, will be removed once standard callback is |
— | — | @@ -1477,29 +1513,20 @@ |
1478 | 1514 | /** |
1479 | 1515 | * Simple api helper to grab an edit token |
1480 | 1516 | * |
1481 | | - * @param {String} [title] The wiki page title you want to edit |
1482 | | - * @param {String} [api_url] The target API URL |
| 1517 | + * @param {String} [api_url] Optional target API URL (uses default local api if unset) |
| 1518 | + * @param {String} title The wiki page title you want to edit |
1483 | 1519 | * @param {callback} callback Function to pass the token to |
1484 | 1520 | */ |
1485 | | - mw.getToken = function( title, api_url, callback ) { |
1486 | | - if( typeof api_url == 'function' ) |
1487 | | - callback = api_url; |
1488 | | - if( typeof title == 'function') |
| 1521 | + mw.getToken = function( api_url, title, callback ) { |
| 1522 | + // Make the api_url be optional: |
| 1523 | + if( typeof title == 'function' ){ |
1489 | 1524 | callback = title; |
| 1525 | + title = api_url; |
| 1526 | + api_url = mw.getLocalApiUrl(); |
| 1527 | + } |
1490 | 1528 | |
1491 | | - mw.log( 'mw:getToken' ); |
| 1529 | + mw.log( 'mw:getToken' ); |
1492 | 1530 | |
1493 | | - // If no title is provided get a token for the user page: |
1494 | | - if ( typeof title != 'string' ) { |
1495 | | - if( typeof wgUserName != 'undefined' && wgUserName ){ |
1496 | | - title = 'User:' + wgUserName; |
1497 | | - }else{ |
1498 | | - // Try maintalk page: |
1499 | | - title = 'Talk:Main_Page'; |
1500 | | - } |
1501 | | - } |
1502 | | - |
1503 | | - |
1504 | 1531 | var request = { |
1505 | 1532 | 'prop': 'info', |
1506 | 1533 | 'intoken': 'edit', |
— | — | @@ -1547,7 +1574,7 @@ |
1548 | 1575 | * @param {Mixed} buttons A button object for the dialog |
1549 | 1576 | * Can be 'ok' for oky button. |
1550 | 1577 | */ |
1551 | | - mw.addDialog = function ( title, msg_txt, buttons ) { |
| 1578 | + mw.addDialog = function ( title, msg_html, buttons ) { |
1552 | 1579 | $j( '#mwe_tmp_loader' ).remove(); |
1553 | 1580 | // Append the style free loader ontop: |
1554 | 1581 | $j( 'body' ).append( |
— | — | @@ -1557,7 +1584,7 @@ |
1558 | 1585 | 'title' : title |
1559 | 1586 | }) |
1560 | 1587 | .css('display', 'none') |
1561 | | - .text( msg_text ) |
| 1588 | + .html( msg_html ) |
1562 | 1589 | ); |
1563 | 1590 | // Special buttons == ok gives empty give a single "oky" -> "close" |
1564 | 1591 | if ( buttons == 'ok' ) { |
— | — | @@ -2644,14 +2671,8 @@ |
2645 | 2672 | 'right':'0px', |
2646 | 2673 | 'bottom':'0px' |
2647 | 2674 | } ); |
2648 | | - } |
2649 | | - |
2650 | | - $.mwProxy = function( apiConf ) { |
2651 | | - mw.load( ['mw.apiProxy'], |
2652 | | - function() { |
2653 | | - mw.apiProxy( apiConf ); |
2654 | | - } ); |
2655 | | - } |
| 2675 | + } |
| 2676 | + |
2656 | 2677 | } )( jQuery ); |
2657 | 2678 | } |
2658 | 2679 | |
Index: branches/js2-work/phase3/js/apiProxyPage.js |
— | — | @@ -22,9 +22,9 @@ |
23 | 23 | |
24 | 24 | // User white_list should also be checked and configured at runtime. |
25 | 25 | mw.ready( function() { |
26 | | - |
27 | | - // Build our configuration from the default and mwApiProxyConfig vars |
28 | | - mwApiProxyConfig = $j.extend( true, mwApiProxyDefaultConfig, mwApiProxyConfig ); |
29 | | - $j.apiProxy( 'server', mwApiProxyConfig ); |
30 | | - |
| 26 | + mw.load( 'ApiProxy', function(){ |
| 27 | + // Build our configuration from the default and mwApiProxyConfig vars |
| 28 | + mwApiProxyConfig = $j.extend( true, mwApiProxyDefaultConfig, mwApiProxyConfig ); |
| 29 | + $j.apiProxy( 'server', mwApiProxyConfig ); |
| 30 | + }); |
31 | 31 | } ); |