Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
// <pre>
/*global wgNamespaceNumber, wgPageName, wgTitle, addOnloadHook */
/*global SimpleAjax, newActionBar, AdminActions, SimpleUI, displayBoxPage, Join, SimpleWiki, UserCfg, copySlotsRecursively, getBody, nextItem */
/*global Actions, DOM */
var LK = {
nextNamespace: null,
disk: 'Wikipedia:Löschkandidaten',
antrag: null,
section: '0',
tasks: [
{
caption: 'Löschen',
desc: 'Gibt dem Löschantrag statt',
func: function () {
LK.promptReason(
function() {
if (DOM.get('wpDeleteReason').value === '') {
return;
}
var join = new Join (
function() { displayBoxPage('/wiki/Spezial:Linkliste/' + encodeURIComponent(mw.config.get('wgPageName'))); },
2
);
LK.sendReason(
"$1 $2 (gelöscht) $1\n$3\n'''Gelöscht:''' " + DOM.get('wpDeleteReason').value + " ~~~~",
'gelöscht',
join.check.bind(join)
);
AdminActions.nukeDelete (
'siehe [[' + LK.disk + '#' + LK.section + ' (gelöscht)]]',
join.check.bind(join),
wgPageName,
SimpleWiki.getTalkpage(),
true
);
join.finalize();
}
);
}
},
{
caption: 'Behalten',
desc: 'Lehnt den Löschantrag ab',
func: function () {
LK.promptReason(
function() {
if (DOM.get('wpDeleteReason').value === '') {
return;
}
LK.sendReason(
"$1 $2 (bleibt) $1\n$3\n'''Bleibt:''' " + DOM.get('wpDeleteReason').value + " ~~~~",
'bleibt',
function (spam) {
location.href = DOM.get('ca-edit').getElementsByTagName('a')[0].href;
}
);
}
);
}
},
{
caption: 'Weiterleitung',
desc: 'Wandelt den Artikel in eine Weiterleitung um',
func: function () {
function decideRedir() {
if (DOM.get('wpDeleteReason').value === '') {
return;
}
var redirTarget = DOM.get('wpRedirTarget').value.match(/^\s*(\[\[)?\s*(.+)\s*(\]\])?\s*$/);
if (redirTarget === null || redirTarget[2] === null) {
return;
}
redirTarget = redirTarget[2];
var join = new Join (
function() { displayBoxPage('/wiki/Spezial:Linkliste/' + encodeURIComponent(mw.config.get('wgPageName'))); },
2
);
LK.sendReason(
"$1 $2 (Weiterleitung) $1\n$3\n'''Weiterleitung auf [[" + redirTarget + "]]:''' " +
DOM.get('wpDeleteReason').value + " ~~~~",
'weiterleitung',
join.check.bind(join)
);
SimpleUI.Box('Weiterleitung wird erstellt …', 'delete');
function change(form) {
form.wpTextbox1.value = '#REDIRECT [[' + redirTarget + ']]';
form.wpSave = true;
return true;
}
var args = {
title: wgTitle,
action: "edit"
};
Actions.action(null, args, 'editform', change, 200, Actions.afterEditFunc(null, join.check.bind(join)));
join.finalize();
}
SimpleUI.InputBox(
[ ['Begründung angeben:', 'wpDeleteReason', '120', '500', '' ], ['Ziel angeben:', 'wpRedirTarget', '120', '500', '' ] ],
[ ['Weiter', decideRedir] ],
'delete'
);
}
},
{
caption: 'Nächstes',
desc: 'Springt zum nächsten Löschkandidaten',
func: function () {
if (LK.nextNamespace !== null) {
nextItem('Wikipedia:Löschkandidat', LK.nextNamespace);
} else {
nextItem('Wikipedia:Löschkandidat');
}
}
}
],
init: function() {
LK.antrag = DOM.get('loeschantragstext');
if (!LK.antrag) {
return;
}
var boldie = LK.antrag.getElementsByTagName('b');
if (!boldie || boldie.length < 2 || boldie.length > 3) {
return;
}
var diskulink = boldie[boldie.length - 1].getElementsByTagName('a');
if (!diskulink || diskulink.length !== 1) {
return;
}
var linkmatch = diskulink[0].getAttribute('href').match(/\/wiki\/(Wikipedia:L%C3%B6schkandidaten\/\d{1,2}\._\w+_\d{4})#(.+)$/);
if (!linkmatch) {
linkmatch = diskulink[0].getAttribute('href').match(/\/wiki\/(Wikipedia:WikiProjekt_Kategorien\/Diskussionen\/\d{4}\/[^\/]+\/\d{1,2})#(.+)$/);
if (!linkmatch) {
return;
}
}
LK.disk = decodeURIComponent(linkmatch[1]).replace(/_/g, ' ');
LK.section = linkmatch[2];
// Alle simplen Werte abgeholt, jetzt geht's los
SimpleAjax.get('/wiki/' + LK.disk, '', LK.gotTalk, true);
var action_div = newActionBar('Löschantrag_Actions');
for (var key in LK.tasks) {
if (typeof LK.tasks[key] === 'object') {
action_div.addLink(
LK.tasks[key].caption,
LK.tasks[key].desc,
'',
LK.tasks[key].func
);
}
}
LK.antrag.insertBefore(action_div, LK.antrag.firstChild);
var talk_div = newActionBar('Löschantrag_Diskussion');
talk_div.appendChild (document.createTextNode('Löschdiskussion wird geladen … '));
LK.antrag.appendChild(talk_div);
},
gotTalk: function(request) {
/* determines the appropriate section */
function getTalkHeading (content) {
function crawlTheLinks(parent, func) {
var as = DOM.fetch(parent, 'a');
if (as !== null) {
for ( var i = 0 ; i < as.length ; ++i ) {
if (as[i].title === wgPageName.replace(/_/g, ' ') || as[i].title === LK.section) {
return func(as[i]);
}
}
}
return null;
}
/* first we start with the captions. link to our page? */
var spans = DOM.fetch(content, 'span', 'mw-headline');
if (spans !== null) {
for ( var n = 0 ; n < spans.length ; ++n ) {
if (crawlTheLinks(spans[n], function(){return true;}) !== null) {
return spans[n].parentNode;
}
}
}
/* nope, so scan the whole page's content */
return crawlTheLinks(
content,
function (item) {
var talkelem = item;
/* quite awful. I want to get to the top item in body. */
while (talkelem.parentNode !== content) {
talkelem = talkelem.parentNode;
}
while (!talkelem.tagName || !talkelem.tagName.match(/h\d/i)) {
talkelem = talkelem.previousSibling;
}
return talkelem;
}
);
}
var talk = getTalkHeading (getBody(SimpleAjax.getResponseXML(request)));
var talk_div = DOM.get('Löschantrag_Diskussion');
if (talk === null) {
talk_div.innerHTML += 'nicht gefunden!';
return;
}
function getTalk (startnode) {
var talk = document.createElement('div');
var talkelem = startnode.nextSibling;
var nextheading = talkelem.previousSibling.tagName.match(/h(\d)/i)[1];
talk.appendChild(startnode);
while (talkelem !== null && (!talkelem.tagName || !talkelem.tagName.match(/h(\d)/i) || talkelem.tagName.match(/h(\d)/i)[1] > nextheading) && talkelem.className !== 'printfooter') {
talkelem = talkelem.nextSibling;
talk.appendChild(talkelem.previousSibling);
}
return talk;
}
talk = getTalk(talk);
talk.style.border = '2px solid #C00000';
talk.style.paddingLeft = '0.3em';
talk.style.display = 'none';
talk.style.overflow = 'auto';
talk.style.maxHeight = '30em';
talk.style.textAlign = 'left';
talk.id = 'ld';
talk_div.innerHTML = '';
talk_div.addLink('Löschdiskussion', 'Blendet die zugehörige Löschdiskussion ein und aus', '', "document.getElementById('ld').style.display = document.getElementById('ld').style.display == 'block' ? 'none' : 'block'; ");
talk_div.appendChild(talk);
LK.antrag.appendChild(talk_div);
},
promptReason: function(callback) {
SimpleUI.InputBox( [ ['Begründung angeben:', 'wpDeleteReason', '120', '500', '' ] ], [ ['Weiter', callback] ], 'delete');
},
sendReason: function(replace_value, summary, callback) {
SimpleUI.Box('Begründung wird abgegeben …', 'delete');
function change(form) {
form.wpSummary.value += summary;
form.wpTextbox1.value = form.wpTextbox1.value.replace(/^(={1,3})\s*(.+?)\s*={1,3}\n([\w\W]+)$/m, replace_value);
form.wpSave = true;
return true;
}
var h = document.getElementById('ld').firstChild;
while (h.tagName !== 'h1' && h.tagName !== 'h2' && h.tagName !== 'h3' && h.tagName !== 'h4') {
h = h.nextSibling;
}
var editLink = h.firstChild;
while (editLink.tagName !== 'span' || editLink.className !== 'editsection') {
editLink = editLink.nextSibling;
}
var editA = editLink.firstChild;
while (editA.innerHTML !== 'Bearbeiten') {
editA = editA.nextSibling;
}
var args = {
title: LK.disk,
action: "edit",
section: editA.href.match(/§ion=(\d+)/)[1]
};
Actions.action(null, args, 'editform', change, 200, Actions.afterEditFunc(null, callback));
}
};
if (typeof UserCfg === 'object' && typeof UserCfg.LK === 'object') {
copySlotsRecursively(LK, UserCfg.LK);
}
addOnloadHook(LK.init);
// </pre>