// <pre>
$(function() {
mw.util.addPortletLink('p-tb','https://dictious.com/it/Speciale:CreazioneRapida','Creazione rapida');
});
if(wgPageName == 'Speciale:CreazioneRapida') {
document.title = 'Creazione rapida';
appendCSS('#content {visibility:hidden;}');
addOnloadHook(creazionerapidaForm);
}
function creazionerapidaForm() {
var con = (document.getElementById('content')) ? document.getElementById('content') : document.getElementById('mw_content')
var bcon = (document.getElementById('bodyContent')) ? document.getElementById('bodyContent') : document.getElementById('mw_contentholder')
var fh = getElementsByClassName(con,'h1','firstHeading');
while(fh.firstChild) fh.removeChild(fh.firstChild)
fh.appendChild(document.createTextNode('Creazione rapida'));
for(var i=0;i<bcon.childNodes.length;i++) {
bcur = bcon.childNodes;
if(bcur.id != 'siteSub' && bcur.id != 'contentSub' && bcur.className != 'visualClear') {
while(bcur.firstChild) bcur.removeChild(bcur.firstChild)
if(bcur.nodeType == 3) bcur.nodeValue = '';
}
}
if(queryString('submit')) {
bcon.innerHTML += '<img src="http://upload.wikimedia.org/wikipedia/commons/5/52/Nuvola_apps_edu_miscellaneous.png" style="border:1px dashed red;" /><br>'
+ '<b style="color:#990000;">{{in|' + queryString('lingua') + '|' + queryString('parte') + '}}'
+ '<br>{{pn}} \'\' ' + queryString('genere') + ' \'\' '
+ '<br> '
+ '<br># ' + queryString('definizione')
+ '<br> '
+ '<br>{{-hyph-}}'
+ '<br>; ' + queryString('sillabazione')
+ '<br> '
+ '<br>{{-etim-}}'
+ '<br>' + queryString('etim')
+ '<br> '
+ '<br>{{-ref-}}'
+ '<br>' + queryString('ref')
}
//Note: I was writing this as nice dom, but since it is for a gag anyways, it is too much work'
bcon.innerHTML += '<form method="get" action="' + mw.config.get('wgServer') + mw.config.get('wgScript') + '"><input name="title" type="hidden" value="Speciale:CreazioneRapida" />'
+ '<fieldset><legend>Creazione rapida delle pagine per utenti inesperti</legend>'
+ '<label for="user">User: </label><input id="user" type="text" name="user" /><p></p>'
+ '<label for="lingua"> Lingua: </label><select id="lingua" name="lingua">'
+ '<option selected="selected" value="it">Italiano</option><option value="fr">Francese</option><option value="de">Tedesco</option>'
+ '<option value="en">Inglese</option><option value="es">Spagnolo</option><option value="pt">Portoghese</option></select>'
+ '<label for="parte"> Parte del discorso: </label><select id="parte" name="parte">'
+ '<option value="agg">Aggettivo</option><option value="noun">Sostantivo</option><option value="verb">Verbo</option>'
+ '<option value="agg_form">Aggettivo forma flessa</option><option value="noun_form">Sostantivo forma flessa</option><option selected="selected" value="verb_form">Verbo forma flessa</option>'
+ '<option value="abbr">Abreviazione</option><option value="comp">Complementi</option><option value="avv">Avverbi</option><option value="phrase">Espressioni</option></select>'
+ '<input id="genere_m" value="m" name="genere" type="radio" checked="checked" /><label for="genere_m">Maschile</label>'
+ '<input id="genere_f" value="f" name="genere" type="radio" /><label for="genere_f">Femminile</label> '
+ '<small> (<a href="http://it.wiktionaryhttps://dictious.com/it/wikizionario:Manuale di stile">help</a>)</small><p></p>'
+ '<label for="etim"> Conosci l\'etimologia?: </label><input id="etim_n" value="{{Noetim|' + queryString('lingua') + '}}" name="etim" type="radio" checked="checked" /><label for="etim_n">No</label>'
+ '<input id="etim_s" value="scrivi qui l\'etimologia" name="etim" type="radio" /><label for="etim_s">Si</label><p></p>'
+ '<label for="definizione">Definizione: </label><input id="definizione" type="text" name="definizione" value=""/><p></p>'
+ '<label for="definizione">Sillabazione: </label><input id="Sillabazione" type="text" name="sillabazione" value=""/><p></p>'
+ '<label for="ref">Conosci una fonte?: </label><input id="ref_n" value="{{Noref|' + queryString('lingua') + '}}" name="ref" type="radio" /><label for="ref_n">No</label>'
+ '<input id="ref_s" value="* {{Fonte|' + queryString('fonti') + '}}" name="ref" type="radio" checked="checked" /><label for="ref_s">Si:</label>'
+ '<label for="fonti"> Scegli la fonte: </label><select id="fonti" name="fonti">'
+ '<option value="dem">De Mauro Paravia</option><option value="dizit">Il dizionario italiano</option><option value="verb">Verbo</option>'
+ '<option value="trec">Vocabolario Treccani</option><option value="sape">Sapere.it</option><option selected="selected" value="hoep">Hoepli Gabrielli</option>'
+ '<option value="0">0</option><option value="480">480</option><option value="2000">2000</option><option value="60000">60,000</option></select><p></p>'
+ '<input type="submit" value="Genera" name="submit" />'
+ '</fieldset></form>'
appendCSS('#content {visibility:visible;}');
if(queryString('user')) document.getElementById('user').value = queryString('user');
if(queryString('definizione')) document.getElementById('definizione').value = queryString('definizione');
if(queryString('sillabazione')) document.getElementById('sillabazione').value = queryString('sillabazione');
;
}
function appendCSS(text) {
var s = document.createElement('style');
s.type = 'text/css';
s.rel = 'stylesheet';
if (s.styleSheet) s.styleSheet.cssText = text //IE
else s.appendChild(document.createTextNode(text + '')) //Safari sometimes borks on null
document.getElementsByTagName('head').appendChild(s);
return s;
}
function queryString(p) {
var re = RegExp('' + p + '=(*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches);
} catch (e) {
}
}
return null;
}
//BATCH DELETE
/* Ajax batch delete thingy, version
Originally from: http://en.wikipedia.orghttps://dictious.com/it/User:Splarka/ajaxbatchdelete.js
Notes:
* It is a bit verbose, after debugging perhaps some output should be removed.
* It waits 1 second after every delete before starting the next.
* Can be aborted by simply deleting the contents of the textarea, or leaving the page.
* Stops when it hits a blank line.
* Nonfatal errors (skip to next line):
** Bad character or malformed line
** Bad token
** Unexpected response
* Pauses in execution can be added with a blank line.
To do:
* Cache the token if two the same?
** Please note the delete token is not guaranteed to be static, but currently it always is.
*/
$(function() {
mw.util.addPortletLink('p-tb','https://dictious.com/it/Special:BlankPage?blankspecial=ajaxbd','Batch Delete');
});
if(wgCanonicalSpecialPageName && wgCanonicalSpecialPageName.toLowerCase() == 'blankpage' && queryString('blankspecial') == 'ajaxbd') {
document.title = 'Ajax Batch Deletion';
$(abdForm);
}
function abdForm() {
mw.util.addPortletLink('p-tb','https://dictious.com/it/Special:Log/delete?user=' + encodeURIComponent(wgUserName),'My delete log');
//subvert this Special: page to our own needs.
var con = document.getElementById('content') || document.getElementById('mw_content');
var bcon = document.getElementById('bodyContent') || document.getElementById('mw_contentholder');
var fh = getElementsByClassName(con,'h1','firstHeading');
while(fh.firstChild) fh.removeChild(fh.firstChild)
fh.appendChild(document.createTextNode('Ajax Batch Deletion'));
for(var i=0;i<bcon.childNodes.length;i++) {
bcur = bcon.childNodes;
if(bcur.id != 'siteSub' && bcur.id != 'contentSub' && bcur.className != 'visualClear') {
while(bcur.firstChild) bcur.removeChild(bcur.firstChild)
if(bcur.nodeType == 3) bcur.nodeValue = '';
}
}
//generate content
var form = document.createElement('form');
form.appendChild(document.createTextNode('Lista delle pagine da cancellare:'));
form.appendChild(document.createElement('p'));
form.setAttribute('action','javascript:void(0);');
var txt = document.createElement('textarea');
txt.style.height = '20em';
txt.style.width = '50%';
txt.setAttribute('id','abd-textarea');
form.appendChild(txt);
form.appendChild(document.createElement('p'));
var lab1 = document.createElement('label');
lab1.setAttribute('for','abd-reason')
lab1.appendChild(document.createTextNode('Oggetto delle cancellazioni: '));
form.appendChild(lab1);
var inp1 = document.createElement('input');
inp1.style.width = '20em';
inp1.setAttribute('type','text');
inp1.setAttribute('id','abd-reason');
form.appendChild(inp1);
form.appendChild(document.createElement('p'));
var sub1 = document.createElement('input');
sub1.setAttribute('type','button');
sub1.setAttribute('id','abd-startbutton');
sub1.setAttribute('value','start');
sub1.setAttribute('onclick','abdStart()');
form.appendChild(sub1);
bcon.appendChild(form);
var pre = document.createElement('pre');
pre.setAttribute('id','abd-output');
bcon.appendChild(pre);
}
function abdStart() {
document.getElementById('abd-startbutton').setAttribute('disabled','disabled');
var out = document.getElementById('abd-output');
var txt = document.getElementById('abd-textarea');
var deletes = txt.value.split('\n');
var page = deletes;
if(page == '') {
out.appendChild(document.createTextNode('* fatto! Non resta altro da fare, o la riga successiva è vuota.\n'));
document.getElementById('abd-startbutton').removeAttribute('disabled');
} else {
var badchars = /(\#|\<|\>|\|\{|\}|\|)/;
if(badchars.test(page)) {
out.appendChild(document.createTextNode('! trovato un carattere non ammesso, la pagina' + page + ' è stata ignorata\n'));
setTimeout('abdStart()',1000);
} else {
out.appendChild(document.createTextNode('> Tento di cancellare ]\n'));
abdGetToken(page);
}
}
deletes = deletes.slice(1,deletes.length);
txt.value = deletes.join('\n');
}
function abdGetToken(page) {
var out = document.getElementById('abd-output');
out.appendChild(document.createTextNode(' > Recupero delete token per ]\n'));
var url = wgScriptPath + '/api.php?action=query&prop=info&indexpageids=1&intoken=delete&format=json&titles=' + encodeURIComponent(page);
var req = sajax_init_object();
req.open('GET', url, true);
req.onreadystatechange = function() {
if(req.readyState == 4 && req.status == 200) {
eval("abdDelete(" + req.responseText + ",'" + req.responseText.replace(/\'/g,"`") + "','" + page + "')");
}
}
req.send(null);
}
function abdDelete(obj,txt,page) {
var out = document.getElementById('abd-output');
if(obj) {
out.appendChild(document.createTextNode(' ! Errore nelle API: ' + obj + ' - ' + obj + '\n'));
return;
}
if(!obj || !obj || !obj] || !obj]) {
out.appendChild(document.createTextNode(' ? Unexpected response: ' + txt + '\n'));
return;
}
var token = obj];
out.appendChild(document.createTextNode(' > Token trovato, attendere la cancellazione\n'));
var reason = document.getElementById('abd-reason').value;
var params = 'action=delete&format=json&token=' + encodeURIComponent(token) + '&title=' + encodeURIComponent(page) + '&reason=' + encodeURIComponent(reason);
var url = wgScriptPath + '/api.php';
var req = sajax_init_object();
req.open('POST', url, true);
req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
req.setRequestHeader('Content-length', params.length);
req.setRequestHeader('Connection', 'close');
req.onreadystatechange = function() {
if(req.readyState == 4 && req.status == 200) {
eval("abdDeleteAftermath(" + req.responseText + ",'" + req.responseText.replace(/\'/g,"`") + "')");
}
}
req.send(params);
}
function abdDeleteAftermath(obj,txt) {
var out = document.getElementById('abd-output');
if(obj) {
out.appendChild(document.createTextNode(' ! Api error: ' + obj + ' - ' + obj + '\n'));
} else if(obj && obj) {
out.appendChild(document.createTextNode(' > La pagina + ']] è stata cancellata\n'));
} else {
out.appendChild(document.createTextNode(' ? Unexpected response: ' + txt + '\n'));
return;
}
setTimeout('abdStart()',1000);
}
function queryString(p) {
var re = RegExp('' + p + '=(*)');
var matches;
if (matches = re.exec(document.location)) {
try {
return decodeURI(matches);
} catch (e) {
}
}
return null;
}
// </pre>