Index: trunk/extensions/FlaggedRevs/client/review.js |
— | — | @@ -52,10 +52,10 @@ |
53 | 53 | |
54 | 54 | // (a) If only a few levels are zero ("incomplete") then disable submission. |
55 | 55 | // (b) Re-enable submission for already accepted revs when ratings change. |
56 | | - var rsubmit = document.getElementById('mw-fr-submit-accept'); |
57 | | - if( rsubmit ) { |
58 | | - rsubmit.disabled = somezero ? 'disabled' : ''; |
59 | | - rsubmit.value = wgAjaxReview.flagMsg; // reset to "Accept" |
| 56 | + var asubmit = document.getElementById('mw-fr-submit-accept'); |
| 57 | + if( asubmit ) { |
| 58 | + asubmit.disabled = somezero ? 'disabled' : ''; |
| 59 | + asubmit.value = wgAjaxReview.flagMsg; // reset to "Accept" |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Update colors of <select> |
— | — | @@ -68,9 +68,9 @@ |
69 | 69 | */ |
70 | 70 | FlaggedRevs.maybeDisableAcceptButton = function() { |
71 | 71 | if ( typeof(jsReviewNeedsChange) != 'undefined' && jsReviewNeedsChange == 1 ) { |
72 | | - var rsubmit = document.getElementById('mw-fr-submit-accept'); |
73 | | - if( rsubmit ) { |
74 | | - rsubmit.disabled = 'disabled'; |
| 72 | + var asubmit = document.getElementById('mw-fr-submit-accept'); |
| 73 | + if( asubmit ) { |
| 74 | + asubmit.disabled = 'disabled'; |
75 | 75 | } |
76 | 76 | } |
77 | 77 | } |
— | — | @@ -215,48 +215,28 @@ |
216 | 216 | window.clearTimeout(wgAjaxReview.timeoutID); |
217 | 217 | } |
218 | 218 | var tier = 0; // review tier |
219 | | - var response = request.responseText; |
| 219 | + var response = request.responseText; // full response text |
220 | 220 | var msg = response.substr(6); // remove <err#> or <suc#> |
221 | 221 | var tierMatch = msg.match(/^<t#(\d)>/); |
222 | 222 | if( tierMatch ) { |
223 | 223 | tier = tierMatch[1]; |
224 | 224 | msg = msg.substr(5); // remove <t#x> |
225 | 225 | } |
226 | | - var diffRevRatings = null; |
227 | | - // Errors: output any error response message |
228 | | - if( response.indexOf('<err#>') == 0 ) { |
229 | | - jsMsg( msg, 'review' ); // success/failure notice |
230 | | - window.scroll(0,0); // scroll up to notice |
231 | | - // OK: get new diff UI elements |
232 | | - } else { |
233 | | - var diffUIParams = document.getElementById("mw-fr-diff-dataform"); |
234 | | - // Diffs: update the contents of the mw-fr-diff-headeritems div |
235 | | - if ( diffUIParams ) { |
236 | | - wgAjaxReview.inprogress = true; |
237 | | - var args = []; // <oldid, newid> |
238 | | - args.push( diffUIParams.getElementsByTagName('input')[0].value ); |
239 | | - args.push( diffUIParams.getElementsByTagName('input')[1].value ); |
240 | | - // Send! |
241 | | - var old = sajax_request_type; |
242 | | - sajax_request_type = "GET"; |
243 | | - sajax_do_call( "FlaggedArticleView::AjaxBuildDiffHeaderItems", |
244 | | - args, wgAjaxReview.processDiffHeaderItemsResult ); |
245 | | - sajax_request_type = old; |
246 | | - } |
247 | | - } |
248 | | - var rsubmit = document.getElementById("mw-fr-submit-accept"); |
249 | | - var usubmit = document.getElementById("mw-fr-submit-unaccept"); |
250 | | - var legend = document.getElementById("mw-fr-reviewformlegend"); |
251 | | - var diffNotice = document.getElementById("mw-fr-difftostable"); |
| 226 | + // Some form elements... |
| 227 | + var asubmit = document.getElementById('mw-fr-submit-accept'); |
| 228 | + var usubmit = document.getElementById('mw-fr-submit-unaccept'); |
| 229 | + var legend = document.getElementById('mw-fr-reviewformlegend'); |
| 230 | + var diffNotice = document.getElementById('mw-fr-difftostable'); |
252 | 231 | var tagBox = document.getElementById('mw-fr-revisiontag'); |
253 | 232 | // On success... |
254 | 233 | if( response.indexOf('<suc#>') == 0 ) { |
| 234 | + // (a) Update document title and form buttons... |
255 | 235 | document.title = wgAjaxReview.actioncomplete; |
256 | | - if( rsubmit && usubmit ) { |
| 236 | + if( asubmit && usubmit ) { |
257 | 237 | // Revision was flagged |
258 | | - if( rsubmit.value == wgAjaxReview.sendingMsg ) { |
259 | | - rsubmit.value = wgAjaxReview.flaggedMsg; // done! |
260 | | - rsubmit.style.fontWeight = 'bold'; |
| 238 | + if( asubmit.value == wgAjaxReview.sendingMsg ) { |
| 239 | + asubmit.value = wgAjaxReview.flaggedMsg; // done! |
| 240 | + asubmit.style.fontWeight = 'bold'; |
261 | 241 | // Unlock and reset *unflag* button |
262 | 242 | usubmit.value = wgAjaxReview.unflagMsg; |
263 | 243 | usubmit.removeAttribute( 'style' ); // back to normal |
— | — | @@ -266,29 +246,52 @@ |
267 | 247 | usubmit.value = wgAjaxReview.unflaggedMsg; // done! |
268 | 248 | usubmit.style.fontWeight = 'bold'; |
269 | 249 | // Unlock and reset *flag* button |
270 | | - rsubmit.value = wgAjaxReview.flagMsg; |
271 | | - rsubmit.removeAttribute( 'style' ); // back to normal |
272 | | - rsubmit.disabled = ''; |
| 250 | + asubmit.value = wgAjaxReview.flagMsg; |
| 251 | + asubmit.removeAttribute( 'style' ); // back to normal |
| 252 | + asubmit.disabled = ''; |
273 | 253 | } |
274 | 254 | } |
275 | | - // Hide "review this" box on diffs |
276 | | - if( diffNotice ) diffNotice.style.display = 'none'; |
277 | | - // Remove review tag from draft |
| 255 | + // (b) Remove review tag from drafts |
278 | 256 | if( tagBox ) tagBox.style.display = 'none'; |
| 257 | + // (c) Update diff-related items... |
| 258 | + var diffUIParams = document.getElementById('mw-fr-diff-dataform'); |
| 259 | + if ( diffUIParams ) { |
| 260 | + // Hide "review this" box on diffs |
| 261 | + if( diffNotice ) diffNotice.style.display = 'none'; |
| 262 | + // Update the contents of the mw-fr-diff-headeritems div |
| 263 | + wgAjaxReview.inprogress = true; |
| 264 | + var args = []; // <oldid, newid> |
| 265 | + args.push( diffUIParams.getElementsByTagName('input')[0].value ); |
| 266 | + args.push( diffUIParams.getElementsByTagName('input')[1].value ); |
| 267 | + // Send! |
| 268 | + var old = sajax_request_type; |
| 269 | + sajax_request_type = "GET"; |
| 270 | + sajax_do_call( "FlaggedArticleView::AjaxBuildDiffHeaderItems", |
| 271 | + args, wgAjaxReview.processDiffHeaderItemsResult ); |
| 272 | + sajax_request_type = old; |
| 273 | + } |
279 | 274 | // On failure... |
280 | 275 | } else { |
| 276 | + // (a) Update document title and form buttons... |
281 | 277 | document.title = wgAjaxReview.actionfailed; |
282 | | - if( rsubmit && usubmit ) { |
| 278 | + if( asubmit && usubmit ) { |
283 | 279 | // Revision was flagged |
284 | | - if( rsubmit.value == wgAjaxReview.sendingMsg ) { |
285 | | - rsubmit.value = wgAjaxReview.flagMsg; // back to normal |
286 | | - rsubmit.disabled = ''; // unlock flag button |
| 280 | + if( asubmit.value == wgAjaxReview.sendingMsg ) { |
| 281 | + asubmit.value = wgAjaxReview.flagMsg; // back to normal |
| 282 | + asubmit.disabled = ''; // unlock flag button |
287 | 283 | // Revision was unflagged |
288 | 284 | } else if( usubmit.value == wgAjaxReview.sendingMsg ) { |
289 | 285 | usubmit.value = wgAjaxReview.unflagMsg; // back to normal |
290 | 286 | usubmit.disabled = ''; // unlock |
291 | 287 | } |
292 | 288 | } |
| 289 | + // (b) Output any error response message |
| 290 | + if ( response.indexOf('<err#>') == 0 ) { |
| 291 | + jsMsg( msg, 'review' ); // success/failure notice |
| 292 | + } else { |
| 293 | + jsMsg( request.responseText, 'review' ); // fatal notice |
| 294 | + } |
| 295 | + window.scroll(0,0); // scroll up to notice |
293 | 296 | } |
294 | 297 | wgAjaxReview.unlockForm(); |
295 | 298 | }; |
— | — | @@ -307,9 +310,9 @@ |
308 | 311 | } |
309 | 312 | |
310 | 313 | wgAjaxReview.onLoad = function() { |
311 | | - var rsubmit = document.getElementById("mw-fr-submit-accept"); |
312 | | - if( rsubmit ) { |
313 | | - rsubmit.onclick = wgAjaxReview.ajaxCall; |
| 314 | + var asubmit = document.getElementById("mw-fr-submit-accept"); |
| 315 | + if( asubmit ) { |
| 316 | + asubmit.onclick = wgAjaxReview.ajaxCall; |
314 | 317 | } |
315 | 318 | var usubmit = document.getElementById("mw-fr-submit-unaccept"); |
316 | 319 | if( usubmit ) { |