MediaWiki:Gadget-RevdelInfo.js

Hello, you have come here looking for the meaning of the word MediaWiki:Gadget-RevdelInfo.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word MediaWiki:Gadget-RevdelInfo.js, but we will also tell you about its etymology, its characteristics and you will know how to say MediaWiki:Gadget-RevdelInfo.js in singular and plural. Everything you need to know about the word MediaWiki:Gadget-RevdelInfo.js you have here. The definition of the word MediaWiki:Gadget-RevdelInfo.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofMediaWiki:Gadget-RevdelInfo.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
// {{documentation}}
/*jshint undef:true */
/*global mw, jQuery */
(function(){

var api = new mw.Api();

function el(tag, child, attr, events) {
	var node = document.createElement(tag);
 
	if (child) {
		if (typeof child !== 'object')
			child = ;
		for (var i = 0; i < child.length; ++i) {
			var ch = child;
			if ((ch === void(null)) || (ch === null))
				continue;
			else if (typeof ch !== 'object')
				ch = document.createTextNode(String(ch));
			node.appendChild(ch);
		}
	}
 
	if (attr) for (var key in attr) {
		node.setAttribute(key, String(attr));
	}
 
	if (events) for (var key in events) {
		node.addEventListener(key, events, false);
	}
 
	return node;
}

function fmtDate(date) {
	// XXX: uses browser's time zone instead of preferences
	date = new Date(date);

	switch (mw.user.options.get('date')) {
	case 'dmy'     : return date.toLocaleTimeString() + ', ' + date.getDate() + ' ' + mw.language.months.genitive + ' ' + date.getFullYear();
	case 'mdy'     : return date.toLocaleTimeString() + ', ' + mw.language.months.genitive + ' ' + date.getFullYear() + ', ' + date.getDate();
	case 'ymd'     : return date.toLocaleTimeString() + ', ' + date.getFullYear() + ' ' + mw.language.months.genitive + ' ' + date.getDate();
	case 'default' : return date.toLocaleString();
	case 'ISO 8601': return date.toISOString(); 
	}
}

function makeBox(rev1, rev2) {
	var query = {
		'action': 'query',
		'list': 'logevents',
		'leaction': 'delete/revision',
		'letitle': mw.config.get('wgPageName'),
		'continue': ''
	};
	
	var list, node = el('div', [
		el('p', 'Details from the deletion log:'),
		list = el('ul')
	], {
		'class': 'mw-warning-with-logexcerpt',
		'style': 'display: none;'
	});
	
	function processResult(result) {
		var events = result.query.logevents;
		for (var i = 0; i < events.length; ++i) {
			if ((events === rev1) || (events === rev2)) {
				var item = events;
				
				// XXX: item and item contain flags... might as well show these too
				// XXX: change link to plaintext based on whether the user has the 'deleterevision' right

				list.appendChild(el('li', [
					fmtDate(item.timestamp), ": ",
					el('a', item.user, { href: mw.util.getUrl('User:' + item.user) }),
					" changed visibility of ", el('a', ], { href: mw.util.getUrl(mw.config.get('wgPageName'), { oldid: item, unhide: '1' }) }),
					item.comment && " (", item.comment, item.comment && ")"
				]));
				node.style.display = '';
			}
		}
		if (result) {
			for (var key in result)
				query = result;
			api.get(query).then(processResult);
		}
	}
	api.get(query).then(processResult);

	return node;
}

if (mw.config.get('wgAction') !== 'view')
	return;
if (!(mw.util.getParamValue('diff') || mw.util.getParamValue('oldid')))
	return;

if (document.getElementById('mw-rev-deleted-no-diff') || document.getElementById('mw-rev-deleted-unhide-diff')) {
	var rev1, rev2;

	var ot = document.getElementById('mw-diff-otitle1');
	var nt = document.getElementById('mw-diff-ntitle1');
	if (ot) { ot = new mw.Uri(ot.getElementsByTagName('a').href); rev1 = ot.query.oldid; }
	if (nt) { nt = new mw.Uri(nt.getElementsByTagName('a').href); rev2 = nt.query.oldid; }

	document.getElementById('mw-content-text').appendChild(makeBox(rev1, rev2));
} else if (document.getElementById('mw-content-text').firstChild.classList.contains('mw-warning')) { // ugly, ugly hack
	var rev = mw.util.getParamValue('oldid');
	document.getElementById('mw-content-text').appendChild(makeBox(rev, null));
}

})();