User:Technical 13/Scripts/Jobs.js
var oldUsers = -1, oldPages = -1, oldJobs = -1, oldMms = -1;
function stopRefreshing() {
clearInterval( refreshStats );
$( '#stopButton' ).replaceWith( 'Last updated' );
}
function updateResults() {
new mw.Api().get( {
action: 'query',
meta: 'siteinfo',
siprop: 'statistics'
} ).done( function( siteStats ) {
var statPath = siteStats.query.statistics;
if ( oldUsers === -1 ) { oldUsers = statPath.users; }
if ( oldPages === -1 ) { oldPages = statPath.pages; }
if ( oldJobs === -1 ) { oldJobs = statPath.jobs; }
if ( oldMms === -1 ) { oldMms = statPath[ 'queued-massmessages' ]; }
var userInfo = '
statPath.users.toLocaleString() +
'
userInfo += '
( Math.round( statPath.activeusers / statPath.users * 1000000 ) / 10000 ) + '%
userInfo += '
( Math.round( statPath.admins / statPath.users * 1000000 ) / 10000 ) + '%
var pageInfo = '
statPath.pages.toLocaleString() +
'
pageInfo += '
( Math.round( statPath.articles / statPath.pages * 1000000 ) / 10000 ) + '%
pageInfo += '
( Math.round( statPath.images / statPath.pages * 1000000 ) / 10000 ) + '%
var jobInfo = '
statPath.jobs.toLocaleString() +
'
var mmsInfo = '
statPath[ 'queued-massmessages' ] +
'
var displayInfo = '
stat | ' +value | ' +change |
---|---|---|
Stop updating: ' + nowTimeDate.toLocaleTimeString() + ' | ||
' +
'Documentation' + ' |
mw.notify( $( displayInfo ), { title: 'Current enwp statistics:', tag: 'siteInfo', autoHide: false } );
oldUsers = statPath.users;
oldJobs = statPath.jobs;
oldMms = statPath[ 'queued-massmessages' ];
} );
};
updateResults();
var refreshStats = window.setInterval( updateResults, 15000 );