Technical_13

$.ajax -->> (new mw.Api)

Jun 7th, 2016
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       var qpoffset = 0;
  2.       while ( qpoffset !== -1 ) {
  3.         $.ajax( {
  4.           url: 'http://ddowiki.com/api.php?action=query&format=json&list=querypage&qplimit=max&qpoffset=' + qpoffset + '&qppage=' + encodeURIComponent( qppage ),
  5.           dataType: 'json',
  6.           async: false,//* REALLY DON'T LIKE THIS!!! IT WILL FAIL IN THE FUTURE!!! */
  7.           success: function ( successData ) {
  8.             if ( successData[ 'query-continue' ] !== undefined ){
  9.               qpoffset = successData['query-continue'].querypage.qpoffset;
  10.             } else {
  11.               var membersInGroup = qpoffset + successData.query.querypage.results.length;
  12.               qpoffset = -1;
  13.               $( 'a[title="Special:' + title + '"]' ).after( ' (' + membersInGroup.toLocaleString() + ')' );
  14.             }
  15.           },
  16.           fail: function ( failureData ) {
  17.             alert( 'Sorry, failed to retrieve page counts for workable pages.\nPlease check the console for more details if available.' );
  18.             console.error( '%O', failureData );
  19.           }
  20.         } );
  21.       }
Add Comment
Please, Sign In to add comment