Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -1207,6 +1207,34 @@ |
1208 | 1208 | launchFeedback: function() { |
1209 | 1209 | _this = this; |
1210 | 1210 | |
| 1211 | + var displayError = function( message ) { |
| 1212 | + $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box |
| 1213 | + $('#mwe-upwiz-feedback-form').append ( $('<div style="color:#990000;margin-top:0.4em;"></div>').msg( message ) ); |
| 1214 | + } |
| 1215 | + |
| 1216 | + var useTokenToPostFeedback = function( token ) { |
| 1217 | + $.ajax({ |
| 1218 | + url: wgScriptPath + '/api.php?', |
| 1219 | + data: 'action=edit&title='+encodeURIComponent(mw.UploadWizard.config['feedbackPage'])+'§ion=new&summary='+encodeURIComponent(subject)+'&text='+encodeURIComponent(message)+'&format=json&token='+encodeURIComponent(token), |
| 1220 | + dataType: 'json', |
| 1221 | + type: 'POST', |
| 1222 | + success: function( data ) { |
| 1223 | + if ( typeof data.edit != 'undefined' ) { |
| 1224 | + if ( data.edit.result == "Success" ) { |
| 1225 | + $feedbackForm.dialog("close"); // edit complete, close dialog box |
| 1226 | + } else { |
| 1227 | + displayError( 'mwe-upwiz-feedback-error1' ); // unknown API result |
| 1228 | + } |
| 1229 | + } else { |
| 1230 | + displayError( 'mwe-upwiz-feedback-error2' ); // edit failed |
| 1231 | + } |
| 1232 | + }, |
| 1233 | + error: function( xhr ) { |
| 1234 | + displayError( 'mwe-upwiz-feedback-error3' ); // ajax request failed |
| 1235 | + } |
| 1236 | + }); // close Ajax request |
| 1237 | + }; // close useTokenToPost function |
| 1238 | + |
1211 | 1239 | // Set up buttons for dialog box. We have to do it the hard way since the json keys are localized |
1212 | 1240 | var cancelButton = gM( 'mwe-upwiz-feedback-cancel' ); |
1213 | 1241 | var submitButton = gM( 'mwe-upwiz-feedback-submit' ); |
— | — | @@ -1221,36 +1249,9 @@ |
1222 | 1250 | if ( message.indexOf('~~~~') == -1 ) { |
1223 | 1251 | message = message+' ~~~~'; |
1224 | 1252 | } |
1225 | | - var useTokenToPost = function( token ) { |
1226 | | - $.ajax({ |
1227 | | - url: wgScriptPath + '/api.php?', |
1228 | | - data: 'action=edit&title='+encodeURIComponent(mw.UploadWizard.config['feedbackPage'])+'§ion=new&summary='+encodeURIComponent(subject)+'&text='+encodeURIComponent(message)+'&format=json&token='+encodeURIComponent(token), |
1229 | | - dataType: 'json', |
1230 | | - type: 'POST', |
1231 | | - success: function( data ) { |
1232 | | - if ( typeof data.edit != 'undefined' ) { |
1233 | | - if ( data.edit.result == "Success" ) { |
1234 | | - $feedbackForm.dialog("close"); |
1235 | | - } else { |
1236 | | - displayError( 'mwe-upwiz-feedback-error1' ); |
1237 | | - } |
1238 | | - } else { |
1239 | | - displayError( 'mwe-upwiz-feedback-error2' ); |
1240 | | - } |
1241 | | - }, |
1242 | | - error: function( xhr ) { |
1243 | | - displayError( 'mwe-upwiz-feedback-error3' ); |
1244 | | - } |
1245 | | - }); // close Ajax request |
1246 | | - }; // close useTokenToPost function |
1247 | | - _this.api.getEditToken( useTokenToPost ); |
| 1253 | + _this.api.getEditToken( useTokenToPostFeedback ); |
1248 | 1254 | }; // close submit button function |
1249 | 1255 | |
1250 | | - var displayError = function( message ) { |
1251 | | - $('#mwe-upwiz-feedback-form div').hide(); // remove everything else from the dialog box |
1252 | | - $('#mwe-upwiz-feedback-form').append ( $('<div style="color:#990000;margin-top:0.4em;"></div>').msg( message ) ); |
1253 | | - } |
1254 | | - |
1255 | 1256 | // Construct the feedback form |
1256 | 1257 | var feedbackLink = '<a href="'+wgArticlePath.replace( '$1', mw.UploadWizard.config['feedbackPage'].replace( /\s/g, '_' ) )+'" target="_blank">'+mw.UploadWizard.config['feedbackPage']+'</a>'; |
1257 | 1258 | $feedbackForm = $('<div id="mwe-upwiz-feedback-form" style="position:relative;"></div>') |