Zum Inhalt springen

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

aus Wikipedia, der freien Enzyklopädie
Inhalt gelöscht Inhalt hinzugefügt
formfix
+mwl
Zeile 18: Zeile 18:
$(document).ready(function () {
$(document).ready(function () {
if (!document.getElementById('wpReason')) return;
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'));}
try {mw.loader.load(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 26. Juni 2015, 10:12 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 {mw.loader.load(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;}
	});
}