Zum Inhalt springen

„Benutzer:P.Copp/scripts/adddeletereason.js“ – Versionsunterschied

aus Wikipedia, der freien Enzyklopädie
Inhalt gelöscht Inhalt hinzugefügt
P.Copp (Diskussion | Beiträge)
K fix für #WEITERLEITUNG
formfix
Zeile 1: Zeile 1:
if (wgAction==='delete') {
if (mw.config.get('wgAction')==='delete') {
function addDeleteReason(res) {
function addDeleteReason(res) {
var wpReason = document.getElementById('wpReason');
var wpReason = document.getElementById('wpReason');
Zeile 16: Zeile 16:
}
}


addOnloadHook(function () {
$(document).ready(function () {
if (!document.getElementById('wpReason')) return;
if (!document.getElementById('wpReason')) return;
try {importScriptURI(wgServer + wgScriptPath + '/api.php?action=query&callback=addDeleteReason&format=json&prop=revisions&rvprop=content&rvlimit=1&pageids=' + wgArticleId);}
try {importScriptURI(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&callback=addDeleteReason&format=json&prop=revisions&rvprop=content&rvlimit=1&pageids=' + mw.config.get('wgArticleId'));}
catch (e) {return;}
catch (e) {return;}
});
});

Version vom 27. Januar 2012, 21:44 Uhr

if (mw.config.get('wgAction')==='delete') {
	function addDeleteReason(res) {
		var wpReason = document.getElementById('wpReason');
		if (!wpReason) return;
		// für Skripte und Links, die automatisch eine Löschbegründung eintragen
		if (location.search.indexOf('wpReason=') > -1) return;

		var text = '';
		if (res && res.query && res.query.pages)
			for (var i in res.query.pages)
				if (res.query.pages[i].revisions)
					text = res.query.pages[i].revisions[0]['*'].substr(0,400).replace(/\n/g,' ');
		var regexp = /(\{\{(?:SLA|Löschen|delete)[^\}]*\}\}(.*(?:MES?Z\)|CES?T\)|(?:REDIRECT|WEITERLEITUNG)[^\]]*\]\]))?)/i;
		var match  = regexp.exec(text);
		wpReason.value = match ? match[1] : "";
	}

	$(document).ready(function () {
		if (!document.getElementById('wpReason')) return;
		try {importScriptURI(mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&callback=addDeleteReason&format=json&prop=revisions&rvprop=content&rvlimit=1&pageids=' + mw.config.get('wgArticleId'));}
		catch (e) {return;}
	});
}