Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.special.js |
— | — | @@ -52,7 +52,8 @@ |
53 | 53 | sortDirection: 'desc', |
54 | 54 | limit: 25, |
55 | 55 | continue: null, |
56 | | - continueId: null // Sort of a tie-breaker for continue values. |
| 56 | + continueId: null, // Sort of a tie-breaker for continue values. |
| 57 | + disabled: false // Prevent (or at least limit) a flood of ajax requests. |
57 | 58 | }; |
58 | 59 | |
59 | 60 | /** |
— | — | @@ -468,6 +469,15 @@ |
469 | 470 | * @param dir int the direction of the mark (-1 = tick down; 1 = tick up) |
470 | 471 | */ |
471 | 472 | $.articleFeedbackv5special.flagFeedback = function ( id, type, dir ) { |
| 473 | + if( $.articleFeedbackv5special.listControls.disabled ) { |
| 474 | + return false; |
| 475 | + } |
| 476 | + |
| 477 | + // Put a lock on ajax requests to prevent another one from going |
| 478 | + // through while this is still running. Prevents manic link-clicking |
| 479 | + // messing up the counts, and generally seems like a good idea. |
| 480 | + $.articleFeedbackv5special.listControls.disabled = true; |
| 481 | + |
472 | 482 | $.ajax( { |
473 | 483 | 'url' : $.articleFeedbackv5special.apiUrl, |
474 | 484 | 'type' : 'POST', |
— | — | @@ -550,9 +560,13 @@ |
551 | 561 | } |
552 | 562 | } |
553 | 563 | } |
| 564 | + // Re-enable ajax flagging. |
| 565 | + $.articleFeedbackv5special.listControls.disabled = false; |
554 | 566 | }, |
555 | 567 | 'error': function ( data ) { |
556 | 568 | $( '#articleFeedbackv5-' + type + '-link-' + id ).text( mw.msg( 'articlefeedbackv5-error-flagging' ) ); |
| 569 | + // Re-enable ajax flagging. |
| 570 | + $.articleFeedbackv5special.listControls.disabled = false; |
557 | 571 | } |
558 | 572 | } ); |
559 | 573 | return false; |