User:Ciencia Al Poder/common.js

/* Fix the damn upload by URL input box disabled */ $(document.body).on('click', '#wpSourceTypeUrl', function { $('#wpUploadFileURL').prop('disabled', !this.checked); });

// Summaries for setting a website as defunct 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' ]);

/** * 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 ').prependTo('#p-cactions');		// Make the Page Action button respond to hover		$button.on('mouseenter', function { $elems.addClass('open right').css({top: '32px', left: '785px'}); });		$elems.on('mouseleave', function { $elems.removeClass('open').css({top: '-9999px', left: '785px'}); });	},	_elementClick = function {		var index, api;		index = $('a', '#drop_gone').index(this);		if (index == -1) { return; }		api = new mw.Api;		api.post({ action: 'sfautoedit', form: 'Website', target: mw.config.get('wgPageName'), query: 'Website[Flags][2]=Gone&Website[Defunct][value]=1&wpSummary='+encodeURIComponent(_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') {		$(_init);	} })(jQuery, mw);