User:Gary/link intermediate revisions.js

/*	LINK INTERMEDIATE REVISIONS Description: Link intermediate revisions when viewing a diff, to easily see which revisions are between the two diffs currently being viewed.

function createDiffMultiLink {	if (!mw.util.getParamValue('diff') || !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); }

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

function diffMultiCallback(response) {	if (!response['query'] || !response['query']['pages'] || response['query']['pageids'][0] == -1) return false; var diffMulti = $('#bodyContent .diff-multi').eq(0); if (!diffMulti.length) return false; var pageId = response['query']['pageids'][0]; var page = response['query']['pages'][pageId]; var revisions = page['revisions']; if (!revisions) return false; var oldid = new Date(revisions[revisions.length - 1]['timestamp']); 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[0]['timestamp']); 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; var a = $('').append(diffMulti.contents.eq(0)); diffMulti.prepend(a); }

$(createDiffMultiLink);