User:Cqm/adminreport.js

/** * Admin report * by User:Cåm */

var reportPages = ['RuneScape:Active_discussions', 'User:Cåm/Scrapbook_7'];

if ($.inArray(mw.config.get('wgPageName'), reportPages) > -1) {

$(function {

var timestamp, utcArr, today, utcArr = [], timestamp2, timestamp3, timestamp4, i,       mwArr = [], lastEdited, members, catLength;

$('#mw-content-text').prepend('  '+       ' '+            ' &bull; &bull; &bull; &bull; '+        ' '+            ' &bull; &bull; '+        ' '+            ' RecentChanges &bull; RCH &bull; AbuseLog &bull; RC Patrol '+        '  '+        '  ');

$(document).ajaxStart(function {           $('#reportLoading').show;        }).ajaxStop(function  {            $('#reportLoading').hide;            $('#reportInner').css('display', 'block');        });

today = new Date; utcArr.push(today.getUTCFullYear); utcArr.push(today.getUTCMonth + 1); // returns value 0-11 utcArr.push(today.getUTCDate); utcArr.push(today.getUTCHours); utcArr.push(today.getUTCMinutes);

/**        * Time function * For formatting the returned value for timestamp */       function time {

timestamp2 = timestamp.replace(/(\:|T|Z)/g, '-'); // use g to replace every occurrence, not just one timestamp3 = timestamp2.split('-'); timestamp4 = timestamp3.filter(function (e) { // remove what's left from Z               return e;            }); for (i = 0; i < timestamp4.length; i++) { mwArr.push(parseFloat(timestamp4[i])); }

if ((utcArr[0] - mwArr[0]) === 0) { //years if ((utcArr[1] - mwArr[1]) === 0) { // months if ((utcArr[2] - mwArr[2]) === 0) { // days if ((utcArr[3] - mwArr[3]) === 0) { // hours if ((utcArr[4] - mwArr[4]) === 1) { lastEdited = '1 minute'; } else { lastEdited = utcArr[4] - mwArr[4] + ' minutes'; }                       } else if ((utcArr[3] - mwArr[3]) === 1) { lastEdited = '1 hour'; } else { lastEdited = utcArr[3] - mwArr[3] + ' hours'; }                   } else if ((utcArr[2] - mwArr[2]) === 1) { lastEdited = '1 day'; } else { lastEdited = utcArr[2] - mwArr[2] + ' days'; }               } else if ((utcArr[1] - mwArr[1]) === 1) { lastEdited = '1 month'; } else { lastEdited = utcArr[1] - mwArr[1] + ' months'; }           } else if ((utcArr[0] - mwArr[0]) === 1) { lastEdited = '1 year'; } else { lastEdited = utcArr[0] - mwArr[0] + ' years'; }

// empty the array or everything turns out the same mwArr.length = 0; }

/**        * Reports the date the page was last edited * Requires individual page ids to access timestamp *        * Reports last time the following pages were edited: *  * RuneScape:Requests for permissions *  * RuneScape:AutoWikiBrowser/Requests *  * RuneScape:Administrator requests *  * RuneScape:User help *  * RuneScape:Counter-Vandalism Unit */

// Requests for permissions - 239188 $.getJSON('/api.php?action=query&prop=info&titles=RuneScape:Requests_for_permissions&format=json', function (data) {           timestamp = data.query.pages['239188'].touched;            time;            $('#permissions').html('Permissions (' + lastEdited + ')');        });

// AutoWikiBrowser requests - 211974 $.getJSON('/api.php?action=query&prop=info&titles=RuneScape:AutoWikiBrowser/Requests&format=json', function (data) {           timestamp = data.query.pages['211974'].touched;            time;            $('#awbRequests').html('AWB (' + lastEdited + ')');        });

// Administrator requests - 197645 $.getJSON('/api.php?action=query&prop=info&titles=RuneScape:Administrator_requests&format=json', function (data) {           timestamp = data.query.pages['197645'].touched;            time;            $('#adminRequests').html('Admin requests (' + lastEdited + ')');        });

// User help - 92936 $.getJSON('/api.php?action=query&prop=info&titles=RuneScape:User_help&format=json', function (data) {           timestamp = data.query.pages['92936'].touched;            time;            $('#userHelp').html('User help (' + lastEdited + ')</a>');        });

// Counter-vandalism unit - 3558 $.getJSON('/api.php?action=query&prop=info&titles=RuneScape:Counter-Vandalism_Unit&format=json', function (data) {           timestamp = data.query.pages['3558'].touched;            time;            $('#cvu').html('CVU (' + lastEdited + ')</a>');        });

/**       * Reports the number of pages in a category * Adjusted to account for RuneScape:Placeholder *       * Reports number of members in: *  * Speedy deletion candidates *  * Speedy move candidates *  * Requests for closure */

// Speedy move candidates $.getJSON('/api.php?action=query&list=categorymembers&cmtitle=Category:Speedy_move_candidates&format=json', function (data) {           members = data.query.categorymembers.length;            catLength = members - 1;            $('#speedyMove').html('Speedy move (' + catLength + ')</a>');        });

// Speedy deletion candidates $.getJSON('/api.php?action=query&list=categorymembers&cmtitle=Category:Speedy_deletion_candidates&format=json', function (data) {           members = data.query.categorymembers.length;            catLength = members - 1;            $('#speedyDel').html('Speedy del (' + catLength + ')</a>');        });

// Requests for closure $.getJSON('/api.php?action=query&list=categorymembers&cmtitle=Category:Requests_for_closure&format=json', function (data) {           members = data.query.categorymembers.length;            catLength = members - 1;            $('#rfClosure').html('Closure (' + catLength + ')</a>');        });

/**        * Special page report * Adapted from MediaWiki:Common.js/spreport.js */

// @todo convert w:c:camtest:MediaWiki:Maintenance

});

}

/* */