Gebruiker:Zanaq/verwijdernominaties.js
Opmerking: na het publiceren is het wellicht nodig uw browsercache te legen om de veranderingen te zien.
- Firefox / Safari: houd Shift ingedrukt terwijl u:je op Vernieuwen klikt of druk op Ctrl-F5 of Ctrl-R (⌘-Shift-R op een Mac)
- Google Chrome: druk op Ctrl-Shift-R (⌘-Shift-R op een Mac)
- Edge: houd Ctrl ingedrukt terwijl u:je op Vernieuwen klikt of druk op Ctrl-F5.
/*===================================================================
semi-automatisch nomineren voor verwijdering door [[User:Zanaq]]
- een fragment van de [[Gebruiker:Zanaq/Zeusmodus|Zeusmodus]]
===================================================================*/
//<pre><nowiki>
if (document.implementation.createDocument) {
var xmlparser = new DOMParser();
}
function XMLParse(string) {
if (document.implementation.createDocument) {
return xmlparser.parseFromString(string, "text/xml");
} else if (window.ActiveXObject) {
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.async = "false";
ret = xmldoc.loadXML(string);
if (!ret)
return null;
return xmldoc.documentElement;
}
return null;
}
var xmlhttp;
function HTTPClient() {
var http;
if(window.XMLHttpRequest) {
http = new XMLHttpRequest();
} else if (window.ActiveXObject) {
try {
http = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
http = false;
}
}
}
return http;
}
var txtSavePage = 'Opslaan';
var txtMinorEdit = '<b>k</b>';
var qTemplate = new Array();
var qPos = new Array();
var qCategory = new Array();
var qTemplateText = new Array();
var qPrompt = new Array();
var qDisplayText = new Array();
var qDefault = new Array();
var dontusesquirlyBrackets = new Array();
var qAdvancedParameters = new Array();
var namespaceSpecial='Speciaal';
var customTemplateIdentifier = new Array();
var txtEditconflict = 'Edit conflict: Someone has altered the page since you last loaded it';
var k = 0;
var templateDeleteIdentifier= 0;
txtEditconflict = '<big><b>Bewerkingsconflict: De inhoud is gewijzigd of verwijderd sinds je de pagina geladen hebt.</b></big>';
if (wgPageName.substring(0,24) == 'Wikipedia:Te_verwijderen')
{
addDeletionNominationTemplate();
qTemplate[++k] = 'Verwijdernominatie' ; qPos[k] ='top' ; qCategory[k] = 'Categorie:Wikipedia:Werk in uitvoering' ;qTemplateText[k] = '$1\n* $2 — [[Gebruiker:Zanaq/Htlinks|Zanaq]] [[Overleg gebruiker:Zanaq/Htlinks|(<b>?</b>)]] 18 feb 2007 04:07 (CET)';qPrompt[k] = 'tekst voor de nominatie';dontusesquirlyBrackets[k]=1;
customTemplateIdentifier[0] = k;
qTemplate[++k] = 'nuweg' ; qPos[k] ='top' ; qCategory[k] = 'Categorie:Wikipedia:Nuweg' ;qTemplateText[k] = '{{nuweg|1=$2}}\n$1';qPrompt[k] = 'commentaar';
qTemplate[++k] = '-' ; qPos[k] = '3%';
}
function checkTemplatesLoadEditForm() {
xmlhttp = HTTPClient();
if (!xmlhttp)
return;
var thetitle="/w/index.php?title="+document.title.slice(0, String(document.title).indexOf(" - "));
xmlhttp.open("GET", thetitle + '&action=edit', true);
xmlhttp.onreadystatechange = checkTemplatesCheckEditForm;
xmlhttp.send(null);
}
var editText = '';
function checkTemplatesCheckEditForm() {
if (xmlhttp.readyState != 4)
return;
startTA=xmlhttp.responseText.indexOf('<textarea ');
startTA=xmlhttp.responseText.indexOf('>', startTA+3);
stopTA=xmlhttp.responseText.indexOf('</textarea>');
editText=(xmlhttp.responseText.substring(startTA+1, stopTA));
for (i=1;i < qTemplate.length; i++)
{
if (qTemplate[i] != '-') {
if (editText.toUpperCase().indexOf('{{'+qTemplate[i].toUpperCase() +'}}') == -1)
{
document.getElementById('chk' + qTemplate[i]).checked = false;
} else {
document.getElementById('chk' + qTemplate[i]).checked = true;
}
document.getElementById('chk' + qTemplate[i]).disabled = false;
}
}
//if (wgPageName.substring(0,4) == 'Gebr')
if (wgPageName.substring(0,24) == 'Wikipedia:Te_verwijderen')
detectFirstEmptySection();
findTemplate()
}
function saveTemplatesLoadEditForm() {
xmlhttp = HTTPClient();
if (!xmlhttp)
return;
qAP = (qAdvancedParameters[buttonClicked] == null) ? '' : qAdvancedParameters[buttonClicked];
var thetitle="/w/index.php?title="+document.title.slice(0, String(document.title).indexOf(" - ")) + qAP;
xmlhttp.open("GET", thetitle + '&action=edit', true);
xmlhttp.onreadystatechange = saveTemplatesCheckEditForm;
xmlhttp.send(null);
}
var editText = '';
buttonClicked = -1;
function saveTemplatesCheckEditForm() {
if (xmlhttp.readyState != 4)
return;
var form, newform, l;
if ( !(xmlhttp.responseText.indexOf('var wgCurRevisionId = "' + wgCurRevisionId + '";') > 0))
{
document.getElementById('bodyContent').innerHTML = txtEditconflict + '<br />' + document.getElementById('bodyContent').innerHTML;
return(0);
}
// Insert the downloaded form in our current page, using
// only hidden form inputs.
doc = XMLParse(xmlhttp.responseText);
form = doc.getElementById('editform');
wpComment='';
for (i=1;i < qTemplate.length; i++)
{
if (qTemplate[i] != '-')
{
if (form.getElementsByTagName('textarea')[0].value.toUpperCase().indexOf('{{'+qTemplate[i].toUpperCase() +'}}') == -1)
{
if (document.getElementById('chk' + qTemplate[i]).checked == true)
{
if (dontusesquirlyBrackets[i]==null) { squirlyBracketsOpen = '+{{';squirlyBracketsClose='}}, ';} else { squirlyBracketsOpen = '';squirlyBracketsClose='';}
wpComment += squirlyBracketsOpen + qTemplate[i] + squirlyBracketsClose;
form.getElementsByTagName('textarea')[0].value = addTemplate(form.getElementsByTagName('textarea')[0].value, i);
}
} else {
if (document.getElementById('chk' + qTemplate[i]).checked == false)
{
wpComment += '-{{'+qTemplate[i] +'}}, ';
form.getElementsByTagName('textarea')[0].value=rmTemplate(form.getElementsByTagName('textarea')[0].value, i);
}
}
}
}
wpComment = ((wpComment != '') ? wpComment.substring(0, wpComment.length-2) : '')
if ((qPrompt[buttonClicked] != null) && (buttonClicked != -1))
{
prompted=prompt(qPrompt[buttonClicked], (qDefault[buttonClicked]==null) ? '' : qDefault[buttonClicked]);
if (prompted == null) { buttonClicked = -1;return;}
filler = (wpComment != '') ? ', ' : ''
if (dontusesquirlyBrackets[buttonClicked]==null) { squirlyBracketsOpen = '+{{';squirlyBracketsClose='}} - ';} else { squirlyBracketsOpen = '';squirlyBracketsClose=' - ';}
wpComment = wpComment + filler + squirlyBracketsOpen + qTemplate[buttonClicked] + squirlyBracketsClose + prompted;
form.getElementsByTagName('textarea')[0].value= trim(qTemplateText[buttonClicked].replace(/\$1/g, trim(form.getElementsByTagName('textarea')[0].value)).replace(/\$2/g, prompted));
} else {
// alert( qTemplateText[buttonClicked].replace(/\$1/g, ''));
filler = (wpComment != '') ? ', ' : ''
if (buttonClicked != -1)
{
if (dontusesquirlyBrackets[buttonClicked]==null) { squirlyBracketsOpen = '+{{';squirlyBracketsClose='}}';} else { squirlyBracketsOpen = '';squirlyBracketsClose='';}
wpComment = wpComment + filler + squirlyBracketsOpen + qTemplate[buttonClicked] + squirlyBracketsClose;
form.getElementsByTagName('textarea')[0].value = trim(qTemplateText[buttonClicked].replace(/\$1/g, trim(form.getElementsByTagName('textarea')[0].value)));
}
wpComment = prompt(txtComment, wpComment);
if (wpComment == null) { buttonClicked = -1;return;}
}
// form.getElementsByTagName('textarea')[0].value = "Laat ons testen";
newform = document.createElement('form');
l = form.getElementsByTagName('textarea');
for (i = l.length; i--; ) {
var t = document.createElement('input');
t.type = 'hidden';
t.name = l[i].name;
t.value = l[i].value;
newform.appendChild(t);
}
l = form.getElementsByTagName('input');
for (i = l.length; i--; ) {
if (l[i].name == 'wpSummary') {
// l[i].value = revertpage.replace(/\$1/g, gml_editor).replace(/\$2/g, gml_vandal);
// comment = wpComment;
l[i].value = wpComment ;
// alert (wpComment);
//alert(l[i].value);
} else if (l[i].name == 'wpMinoredit') {
l[i].value = (document.getElementById('chkMinorEdit').checked == true) ? (1) : (0);//document.getElementById('chkMinorEdit').checked;
} else if (l[i].name == 'wpWatchthis') {
if (!l[i].checked)
continue; // Don’t touch the "watch" status
l[i].value = "on";
} else if (l[i].name == 'wpPreview') {
continue;
} else if (l[i].name == 'wpDiff') {
continue;
}
l[i].type = 'hidden';
newform.appendChild(l[i]);
}
newform.name = form.name;
newform.method = form.method;
newform.id = form.id;
newform.action = form.action;
document.getElementById('bodyContent').innerHTML += '<br />Submitting form...';
document.getElementById('bodyContent').appendChild(newform);
// Submit the form
//if (wpComment.length > 0) alert(form.getElementsByTagName('textarea')[0].value);
if (wpComment.length > 0) newform.submit();
//alert (wpComment + ' - submitting');
}
var oldTemplates = '';
function clickTemplateSubmit()
{
if (editText == '')
{
wpComment = (document.editform.wpSummary.value == '') ? prompt(txtComment, '') : document.editform.wpSummary.value;
if (wpComment == null) return;
document.editform.wpSummary.value = wpComment;
document.editform.submit();
} else {
// alert ('submit templates only');
saveTemplatesLoadEditForm(-1);
}
}
function submitButtonedTemplate(template)
{
if (
(document.location.href.indexOf('&action=edit') == -1) &&
(document.location.href.indexOf('&action=submit') == -1)
)
{
buttonClicked=template;
clickTemplateSubmit();
} else {
if (qPrompt[template] == null)
{
prompted = '';
} else {
prompted = prompt(qPrompt[template], (qDefault[template]==null) ? '' : qDefault[template]);
if (prompted==null) return;
}
document.editform.wpTextbox1.value = trim(qTemplateText[template].replace(/\$1/g, trim(document.editform.wpTextbox1.value)).replace(/\$2/g, prompted));
if (dontusesquirlyBrackets[template]==null) { squirlyBracketsOpen = '+{{';squirlyBracketsClose='}}';} else { squirlyBracketsOpen = '';squirlyBracketsClose='';}
document.editform.wpSummary.value += ((document.editform.wpSummary.value == '')?'':', ') + squirlyBracketsOpen + qTemplate[template] + squirlyBracketsClose;
};
}
function addQTemplate() {
// var csub=document.getElementById("top");
// var msg=document.createElement("p");
// msg.innerHTML = ''<img src="' + imgZeus + '" align="left">';
// csub.appendChild(msg);
var csub=document.getElementById("contentSub");
var msg=document.createElement("p");
msg.innerHTML = '';
wikifybar = '';
if (location.href.indexOf('token=') != -1)
return 0;
if ( //Case 1: the bar must be drawn
(location.href.indexOf(':Contributions') == -1) &&
(location.href.indexOf(':Preferences') == -1) &&
(document.getElementById('ca-edit')!=null) &&
// (location.href.indexOf('&action=history') == -1) &&
(location.href.indexOf('/wiki/' + namespaceSpecial + ':') == -1)
)
{
wikifybar = '<table width=100% style="margin-bottom:-.2em"><tr>';
for (i=1;i < qTemplate.length; i++)
{
qT= "'" + qTemplate[i] + "'";
wikifybar += (qTemplate[i] != '-')
? (qTemplateText[i] == null)
? '<td><center><input type="checkbox" DISABLED style="margin-top:-.3em" id="chk' + qTemplate[i] + '" name="' + qTemplate[i] + '" value="greyed" onclick="toggleTemplate(' + i + ');"> <a href="/wiki/' + qCategory[i] + '">' + ((qDisplayText[i]==null) ? qTemplate[i] : qDisplayText[i])+ '</a></center></td>'
:'<td><center><input type="button" style="width:15px;height:15px;margin-top:-.5em" id="chk' + qTemplate[i] + '" name="' + qTemplate[i] + '" value="" onclick="submitButtonedTemplate(' + i + ');"> <a href="/wiki/' + qCategory[i] + '">' + ((qDisplayText[i]==null) ? qTemplate[i] : qDisplayText[i]) + '</a></center></td>'
: '<td width="' + qPos[i] + '"> </td>';
//<input type="INPUT"
}
if ( //if in an editwindow
(
(location.href.indexOf('&action=edit') != -1)
|| (location.href.indexOf('&action=submit') != -1)
)
&& (
(location.href.indexOf('§ion=') == -1)
|| (location.href.indexOf('§ion=0') != -1)
)
)
{
wikifybar += '<td><center><input type="checkbox" style="margin-top:-1em" CHECKED id="chkMinorEdit" name="chkMinorEdit" value="grayed" onclick=""> ' + txtMinorEdit + '</center></td>'
wikifybar += '<td><input id="wpSave" type="submit" style="margin-top:-1em" value="' + txtSavePage + '" name="wpSave" accesskey="s" title="Sla uw wijzigingen op [alt-s]"/ onclick="clickTemplateSubmit();"></td>';
wikifybar += '</tr></table>';
} else {
wikifybar += '<td><center><input type="checkbox" CHECKED id="chkMinorEdit" name="chkMinorEdit" value="grayed" onclick=""> ' + txtMinorEdit + '</center></td>'
wikifybar += '<td><input id="wpSave" type="submit" value="' + txtSavePage + '" name="wpSave" accesskey="s" title="Sla uw wijzigingen op [alt-s]"/ onclick="clickTemplateSubmit();"></td>';
wikifybar += '</tr></table>';
}
}
if (
(
(location.href.indexOf('&action=edit') != -1)
|| (location.href.indexOf('&action=submit') != -1)
)
&& (
(location.href.indexOf('§ion=') == -1)
|| (location.href.indexOf('§ion=0') != -1)
)
)
{
msg.innerHTML+= wikifybar;
// alert(msg.innerHTML);
csub.insertBefore(msg, csub.firstChild);
akeytt();
editText = '';
oldTemplates = '';
for (i=1;i < qTemplate.length; i++)
{
if (qTemplate[i] != '-') {
if (document.editform.wpTextbox1.value.toUpperCase().indexOf('{{'+qTemplate[i].toUpperCase() +'}}') == -1)
{
document.getElementById('chk' + qTemplate[i]).checked = false;
} else {
document.getElementById('chk' + qTemplate[i]).checked = true;
oldTemplates += '{{'+qTemplate[i] +'}}';
}
document.getElementById('chk' + qTemplate[i]).disabled = false;
}
}
} else {
msg.innerHTML+= wikifybar;
csub.insertBefore(msg, csub.firstChild);
akeytt();
if (wikifybar != '')
checkTemplatesLoadEditForm();
}
}
if (wgPageName.substring(0,24) == 'Wikipedia:Te_verwijderen')
{
if (location.href.indexOf('&action=edit') == -1)
window.addEventListener ('DOMContentLoaded',addQTemplate,false);
} else {
findTemplate()
}
function trim(stringToTrim)
{
for (s=0;s < stringToTrim.length && stringToTrim[s++] < 33;);
for (e=stringToTrim.length; e >0 && stringToTrim[--e] < 33;);
return(stringToTrim.substring(s-1,e+1));
}
function findTemplate()
{
verwijderlink=document.getElementById('verwijderpagina');
if (verwijderlink==null) return(0);
var regexFindTemplates = /\{\{(nuweg|wb|wiu|weg|auteur|reclame|ne)(.*)\}\}/im;
a = regexFindTemplates.exec(editText);
a[2] = (a[2][0]=='|') ? a[2].substring(1,100) : '';
a[2] = (a[2][1]=='=') ? a[2].substring(2) : a[2];
url='?template=' + escape(a[1]) + '&pagename=' + escape(wgPageName);
if (a[2] != '') url += '&reason=' + escape(a[2]);
verwijderlink.getElementsByTagName('a')[0].href += url;
}
function addDeletionNominationTemplate()
{
url=document.location.href;
tp=url.indexOf('?template=');
if (tp == -1) return(0);
pp=url.indexOf('&pagename=');
rp=url.indexOf('&reason=');
if (rp == -1)
{
rp = url.length;
reason= '';
} else {
reason=unescape(url.substring(rp+8));
}
template=unescape(url.substring(tp+10,pp));
pagename=unescape(url.substring(pp+10,rp));
qTemplate[++k] = 'Verwijdernominatie ' + pagename ; qPos[k] ='top' ; qCategory[k] = pagename ;qTemplateText[k] = '$1\n* [[' + pagename + ']] - ' + template + ' - $2 — [[Gebruiker:Zanaq/Htlinks|Zanaq]] [[Overleg gebruiker:Zanaq/Htlinks|(<b>?</b>)]] 18 feb 2007 04:07 (CET)' ;qPrompt[k] = 'reden'; qDefault[k] = reason; dontusesquirlyBrackets[k]=1;
templateDeleteIdentifier= k;
}
function detectFirstEmptySection()
{
var first=null;
a=editText.split(/={2,}[^=]+={2,}/);
for (i = 0; (i < a.length); i++)
{
if (a[i].length < 10)
{
first= (first == null) ? i : first;
}
}
first=first - 1 ;
first=(first < 2) ? 2 : first;
qAdvancedParameters[templateDeleteIdentifier]='§ion=' + first ;
for (i=0;i < customTemplateIdentifier.length;i++)
qAdvancedParameters[customTemplateIdentifier[i]]='§ion=' + first ;
}
//</nowiki></pre>