MediaWiki:Gadget-MarkWebsiteAsDefunct.js

// Summaries for setting a website as defunct if (!mw.config.get('gonesummaries')) { mw.config.set('gonesummaries', [		'domain does not resolve DNS',		'domain expired',		'error 404',		'no longer using MediaWiki',		'now using Wordpress',		'can\'t connect',		'requires HTTP authentication',		'private wiki',		'gives error and no data collected for a long time',		'wiki has been closed'	]); }

/** * Set website as defunct without entering in edit mode * */ (function($, mw) {	'use strict';	var _summaries = [],	_init = function {		var $elems, $button, i;		_summaries = mw.config.get('gonesummaries');		if (!_summaries) { return; }		$elems = $('').prependTo('#p-cactions');		for (i = 0; i < _summaries.length; i++) {			$elems.append($('').text(_summaries[i]).wrap('').parent);		}		$elems.on('click', 'a', _elementClick);		$button = $(' Mark as defunct ').insertAfter('#p-cactions a.button:last-of-type');		// Make the Page Action button respond to hover		$button.on('mouseenter', function { $elems.addClass('open right').css({top: '32px', left: '585px'}); // KILL THE F ACTION DROPDOWN!!1ONE!1 $('#drop1').css({display: 'none'}); // But it executes right after this event, which means I hide it and then the other code kicks in, revealing the other dropdown again window.setTimeout(function {				$('#drop1').removeClass('open').css({top: '-9999px', display: ''});			}, 200); });		$elems.on('mouseleave', function { $elems.removeClass('open').css({top: '-9999px', left: '585px'}); });	},	_elementClick = function {		var index, api;		index = $('a', '#drop_gone').index(this);		if (index == -1) { return; }		api = new mw.Api;		api.post({ action: 'pfautoedit', form: 'Website', target: mw.config.get('wgPageName'), query: 'Website[Flags][2]=Gone&Website[Defunct][value]=1&wpSummary='+encodeURIComponent('defunct: '+_summaries[index]) }).done(_postDone);		return false;	},	_postDone = function(data) {		if (data.status == 200) {			//if (data.redirect) {			//	document.location.href = data.redirect;			//}			location.reload(true);		} else {			if (window.console && console.dir) {				console.dir(data);			}			alert('An error ocurred!');		}	};	if (mw.config.get('wgNamespaceNumber') === 0 && mw.config.get('wgAction') == 'view' && mw.config.get('wgCategories',[]).indexOf('Website') != -1) {		$(_init);	} })(jQuery, mw);