Misplaced Pages

User:NQ/sandbox.js: Difference between revisions

Article snapshot taken from[REDACTED] with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:NQ Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 00:09, 9 August 2016 view sourceNQ (talk | contribs)Extended confirmed users, Pending changes reviewers, Rollbackers6,648 edits User:Gary/link_intermediate_revisions.js← Previous edit Revision as of 00:38, 9 August 2016 view source NQ (talk | contribs)Extended confirmed users, Pending changes reviewers, Rollbackers6,648 edits changesNext edit →
Line 1: Line 1:
function createDiffMultiLink() function createDiffMultiLink()
{ {
if (!mw.util.getParamValue('diff') || !mw.util.getParamValue('oldid')) return false; if (!mw.util.getParamValue('oldid')) return false;
$.get(mw.config.get('wgScriptPath') + '/api.php', { action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'timestamp', rvstartid: mw.util.getParamValue('diff'), rvendid: mw.util.getParamValue('oldid'), rvlimit: '5000', format: 'json', indexpageids: 1 }, diffMultiCallback); $.get(mw.config.get('wgScriptPath') + '/api.php', { action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'timestamp', rvstartid: mw.config.get('wgRevisionId'), rvendid: mw.util.getParamValue('oldid'), rvlimit: '5000', format: 'json', indexpageids: 1 }, diffMultiCallback);
} }


Line 15: Line 15:
{ {
if (!response || !response || response == -1) return false; if (!response || !response || response == -1) return false;
var diffMulti = $('#bodyContent .diff-multi').eq(0);
if (!diffMulti.length) return false;
var pageId = response; var pageId = response;
var page = response; var page = response;
var revisions = page; var revisions = page;
if (!revisions) return false; if (!revisions) return false;

var oldid = new Date(revisions);
oldid = oldid.getUTCFullYear().toString() + twoDigitPadding(oldid.getUTCMonth() + 1).toString() + oldid.getUTCDate().toString() + twoDigitPadding(oldid.getUTCHours() + 1).toString() + twoDigitPadding(oldid.getUTCMinutes() + 1).toString() + twoDigitPadding(oldid.getUTCSeconds() + 1).toString();
var diff = new Date(revisions); var diff = new Date(revisions);
diff = diff.getUTCFullYear().toString() + twoDigitPadding(diff.getUTCMonth() + 1).toString() + diff.getUTCDate().toString() + twoDigitPadding(diff.getUTCHours() + 1).toString() + twoDigitPadding(diff.getUTCMinutes() + 1).toString() + twoDigitPadding(diff.getUTCSeconds() + 1).toString(); diff = diff.getUTCFullYear().toString() + twoDigitPadding(diff.getUTCMonth() + 1).toString() + twoDigitPadding(diff.getUTCDate()).toString() + twoDigitPadding(diff.getUTCHours()).toString() + twoDigitPadding(diff.getUTCMinutes() + 1).toString() + twoDigitPadding(diff.getUTCSeconds()).toString();
mw.util.addPortletLink('p-tb', mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName') + '&action=history&offset=' + diff, "(Diff History)");
var a = $('<a href="' + mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName') + '&action=history&offset=' + diff + '&limit=' + revisions.length + '"></a>').append(diffMulti.contents().eq(0));
diffMulti.prepend(a);
} }



Revision as of 00:38, 9 August 2016

function createDiffMultiLink()
{
	if (!mw.util.getParamValue('oldid')) return false;
	$.get(mw.config.get('wgScriptPath') + '/api.php', { action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'timestamp', rvstartid: mw.config.get('wgRevisionId'), rvendid: mw.util.getParamValue('oldid'), rvlimit: '5000', format: 'json', indexpageids: 1 }, diffMultiCallback);
}

function twoDigitPadding(integer)
{
	var string = integer.toString();
	if (string.length == 1) return '0' + integer;
	else return integer;
}

function diffMultiCallback(response)
{
	if (!response || !response || response == -1) return false;
		
	var pageId = response;
	var page = response;
	var revisions = page;
	if (!revisions) return false;

	var diff = new Date(revisions);
	diff = diff.getUTCFullYear().toString() + twoDigitPadding(diff.getUTCMonth() + 1).toString() + twoDigitPadding(diff.getUTCDate()).toString() + twoDigitPadding(diff.getUTCHours()).toString() + twoDigitPadding(diff.getUTCMinutes() + 1).toString() + twoDigitPadding(diff.getUTCSeconds()).toString();
    mw.util.addPortletLink('p-tb', mw.config.get('wgScript') + '?title=' + mw.config.get('wgPageName') + '&action=history&offset=' + diff, "(Diff History)");
}

$(createDiffMultiLink);
User:NQ/sandbox.js: Difference between revisions Add topic