Utente:LikeLifer/monobook.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nuova pagina: // →‎<pre> <nowiki>: // Elenco dei tool da caricare. NB: La stringa deve iniziare e finire con uno spazio var myButtons = new Array([2,'{{blocco|','|}}','Blocco',10,'+ blocco'],...
(Nessuna differenza)

Versione delle 20:45, 2 gen 2012

// /* <pre> <nowiki> */
// Elenco dei tool da caricare. NB: La stringa deve iniziare e finire con uno spazio

var myButtons = new Array([2,'{{blocco|','|}}','Blocco',10,'+ blocco'],[1,'{{da aiutare|data={{subst:CURRENTDAY}} {{subst:CURRENTMONTHNAME}} del {{subst:CURRENTYEAR}}}}','0','aiutare',0,'Da aiutare'],[2,'<quiz display=simple>\\n{\\n|type="()"}\\n-\\n-\\n+\\n-','</quiz>','quiz risp.multipla',0,''],[2,'<quiz display=simple>\\n{\\n|type="{}"}\\n { }','</quiz>','quiz risp.scritta',0,''],[1,'','0','+ cat',0,'+ cat'],[1,'','0','wikificato',0,'wikificato'],[1,'','0','new page',0,'creata pagina'],[1,'','0','new cat',0,'creata categoria']);

var myLinks = new Array(['CU tool','http://all-nettools.com/toolbox'],['it.wiki CU','http://it.wikipedia.org/wiki/Wikipedia:Check_user/Richieste'],['Richieste CU (meta)','http://meta.wikimedia.org/wiki/Requests_for_CheckUser_information'],['lookup city','http://www.maxmind.com/app/lookup_city']);

var toLoad = "purg led ns0 lks tabs chat mjs mcss sand blk admin prob syop whois ulmod allp voto cat test wnb benv canc aviol unv ipro sta avan cwtch cmd goo stex tatoo ptb riex rev movetxt adlink adrus adtog canctxt cancfiletxt";



//Monobook Modulare di wikibooks ver.2.0.1
//Lancia il vero monobook
// Vedi [[Wikibooks:Monobook.js/MonobookCompleto.js]]

/*</pre>
==Monobook Admin==
<pre>*/
document.writeln('<script type="text/javascript" src="/w/index.php?title=Utente:'+wgUserName+'/aggiornamenti.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/*</pre>
==Prove al vero monobook==
<pre>*/
document.writeln('<script type="text/javascript" src="/w/index.php?title=Wikibooks:Monobook.js/MonobookCompleto.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//-----------
document.writeln('<script type="text/javascript" src="/w/index.php?title=Utente:'+wgUserName+'/monolibro.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/*</pre>
==Configurazione popup==
<pre>*/
popupDelay = 1.5; // aspetta 1.5 secondi per aprirsi
popupHideDelay=0.3; //aspetta 0.3 secondi prima di chiudersi
popupRedlinkRemoval = true; // elimina i collegamenti a link rossi
popupQueriedRevertSummary = "Rollback da popup. Ripristinata la versione di $3";
popupRedlinkSummary = "Eliminato link rosso: %s";
popupAdminLinks=true; //LINK ALLE FUNZIONI PER ADMIN
popupShortcutKeys=true; //SCORCIATOIE DA TASTIERA ABILITATE
popupFixDabs=true;
popupPreviewKillTemplates=false; 
popupPreviewFirstParOnly=false;
popupOnlyArticleLinks=false;
popupExtraUserMenu='<menurow><<monobook|shortcut=M>>|<<editMonobook|edit>></menurow>';
popupFixRedirs=true; //CORREGGI REDIRECT
extraPopupFilters=[
function(data) { if (/[{]{2}[Ff]eatured article[}]{2}/.test(data) )
   return '<img src="http://upload.wikimedia.org/wikipedia/en/thumb/c/cf/Cscr-featured.png/7px-Cscr-featured.png">';
   else return ''; }
];
popupFixDabs = true;
popupImageLinks = true;
//     EDIT COUNT
popupEditCounterTool="custom";
popupEditCounterUrl="http://tools.wikimedia.org/~misza13/cgi-bin/count.py?user=$1&project=itwikibooks_p&edits=on&logs=on";
//    /EDIT COUNT
popupShortcutKeys=true; // optional: enable keyboard shortcuts
popupAdminLinks=true;   // optional: enable admin links

/*</pre>
== Aggiunge collegamenti nella toolbar personale==
<pre>/*
document.writeln('<script type="text/javascript" src="/w/index.php?title=Utente:'+wgUserName+'/personaltbar.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/*</pre>
== Mostra i Tatoo ==
<pre> */
  if ((toLoad.indexOf(" tatoo ")!=-1))
document.writeln('<script type="text/javascript" src="/w/index.php?title=Utente:'+wgUserName+'/Tatoo&action=raw&ctype=text/javascript&dontcountme=s"></script>');


/*</pre>
==Set status  ==
<pre> */
//GRAZIE A [[w:Utente:Jalo]]
//<pre>
var stati = new Array ('connesso', 'occupato', 'disconnesso', 'su it.wiktionary', 'vacanziero', 'patroller', 'chattarolo', 'stanchissimo', 'no-wiki');

addOnloadHook(function () {
    var logout = document.getElementById('pt-logout');
    var newpt = document.createElement('li');
    var link = document.createElement('a');
    link.id = 'setStatus';
    link.href = 'javascript:setCurrentStatus()';

    // Crea la stringa mostrata a video
    link.appendChild(document.createTextNode("Set Status"));

    // just one little ID attribute would be _so_ nice...
    newpt.appendChild(link);
    logout.parentNode.insertBefore(newpt, logout);
});

function setCurrentStatus()
{
Greeter = "       Hai chiesto di cambiare il tuo logon status\n.       " +
		  "       Scegli il nuovo stato dalla lista       ";
    var div = document.createElement('div');
        div.id = 'inlinePopupDiv';
        div.style.position = 'absolute';
        div.style.zIndex   = 1000;
        div.style.left     =  '5px';
        div.style.top      =  '5px';
        div.style.padding      =  '5px';
        div.style.backgroundColor = '#FFFFFF';
        div.style.borderStyle     = 'solid';
        div.style.borderWidth     = ' medium';
        div.style.borderColor     = '#000000';

        var top = document.createElement('div');
            top.id = 'inlinePopupTop';
            top.style.textAlign = 'right';
            top.style.margin = '8px';
            top.style.backgroundColor = '#DDDDDD';

            var a = document.createElement('a');
                a.appendChild( document.createTextNode('Close'));
                a.href = "javascript:void RemoveNode('inlinePopupDiv')";
                a.style.margin = '8px';

            top.appendChild(a);

        div.appendChild(top);

        var greet = document.createElement('p');
        greet.innerHTML = Greeter;
        div.appendChild(greet);

        var form = document.createElement('form');
        form.name = "popupForm";
        var p = document.createElement('p');

            p.appendChild(document.createTextNode('Stato:'));
                     
            var sel = document.createElement('select');
            sel.name = 'popupSelect';
            sel.size = 1;
			
            var option;
            
            // Carica nel combo box il contenuto della variabile globale
            for (i = 0; i < stati.length; i++)
            {
                option = new Option(stati[i],stati[i]);
                sel.options[sel.options.length] = option;
            }

			p.appendChild(sel);

            var button = document.createElement('input');
            button.value = 'OK';
            button.type = 'button';
            button.setAttribute('onclick', 'salvaNewStatus()');
            p.appendChild(button);

        form.appendChild(p);
        div.appendChild(form);

    document.body.appendChild(div);
    div.getElementsByTagName('input')[0].focus();
}

function salvaNewStatus()
{
    var newStatus = document.getElementById('inlinePopupDiv').getElementsByTagName('select')[0].value;
	var newString='{{Utente:'+wgUserName+'/StatusTemplate|'+newStatus+'}}\n';
	
	// registra il valore
	setpagecontent('Utente:'+wgUserName+'/Status',newString,'stato modificato in "' + newStatus + '"');
	
	// e chiudi il popup
	RemoveNode('inlinePopupDiv');
}

function addToolBoxLinks()
{
        cur_user = "";
        if (wgPageName.substr(0,7) == "Utente:")
        {
            if (wgPageName.indexOf('/') != -1) // se siamo in una sottopagina dell'utente
                cur_user = wgPageName.substr(7, wgPageName.indexOf('/') - 7);
            else
                cur_user = wgPageName.substr(7);
        }
        if (wgPageName.substr(0,19) == "Discussioni_utente:")
        {
            if (wgPageName.indexOf('/') != -1) // se siamo in una sottopagina della discussione dell'utente
                cur_user = wgPageName.substr(19, wgPageName.indexOf('/') - 19);
            else
                cur_user = wgPageName.substr(19);
        }
        
        // trasforma gli underscore in spazi
        while (cur_user.indexOf("_") != -1)
        {
           temp = cur_user.substr(0,cur_user.indexOf("_"));
           temp += " ";
           temp += cur_user.substr(cur_user.indexOf("_")+1);
           cur_user = temp;
        }
        
        if (cur_user != "") //Se siamo in una pagina/sottopagina della pagina utente/discussione
            addlilink(tb, 'http://tools.wikimedia.de/~vvv/deletedcontribs.php?wiki=itwikibooks_p&user=' + cur_user, 'Delected edit (' + cur_user + ')', '');
    }    


addOnloadHook(function (){
		if(queryString("submitdelete")=="true") document.forms[0].wpConfirmB.click();
	});
	function queryString(p) {
		var re = RegExp('[&?]' + p + '=([^&]*)');
		var matches;
		if (matches = re.exec(document.location)) {
			try { 
				return decodeURI(matches[1]);
			} catch (e) {
			}
		}
		return null;
	};

/*</pre>
== Menù peronali ==
<pre> */

function shortcutsInit ()
{ 
shortcutsAddLink ( 'Monobook Admin', 'Utente:Wim_b/aggiornamenti.js' );
shortcutsAddLink ( 'Seconda SandBox', 'Utente:Wim_b/Sandbox2' );
shortcutsAddLink ( 'Corso di roccia', 'Corso_di_roccia' );

shortcutsStartSection ('Utilità');

shortcutsAddLink ( 'Richieste Monobook', 'Utente:Wim_b/reind' );
shortcutsAddLink ( 'Il monobook di Wikibooks', 'Wikibooks:Monobook.js' );
shortcutsAddLink ( 'Formule matematiche TeX', 'w:Wikipedia:Formule_matematiche_TeX' );
shortcutsAddLink ( 'Codici dei colori', 'Aiuto:Colori' );

shortcutsStartSection ('Admin');

shortcutsAddLink ( 'trasferimenti', 'w:Wikipedia:Proposte_di_trasferimento/Wikibooks' );
shortcutsAddLink ( 'Ricerca collegamenti esterni', 'Speciale:Linksearch' );
shortcutsAddLink ( 'template', 'Aiuto:Schema_dei_template#Template' );
shortcutsAddLink ( 'semi-protette', 'Categoria:Pagine semi-protette' );
shortcutsAddLink ( 'protette', 'Categoria:Pagine protette' );
shortcutsAddLink ( 'Titoli protetti', 'Speciale:Protectedtitles' );

}

/*</pre>
== Pulsante personale per utenti problematici ==
<pre> */
      if(document.title.indexOf("Utenti problematici") != -1 )
  {
        mwCustomEditButtons[mwCustomEditButtons.length] = {
        "imageFile": "http://upload.wikimedia.org/wikipedia/commons/7/79/Button_bombe.png",
        "speedTip": "segnalazione chiusa",
        "tagOpen": "'''Segnalazione chiusa, ",
        "tagClose": ".'''--~~~~",
        "sampleText": "abuso di pagina di servizio"};
  }

/*</pre>
==Agiornamento automatico RC  ==
<pre> */


if (window.location.href.indexOf("Utente:Wim_b/Controllo_vandalismi")  > -1)
{
window.setTimeout("location.replace('http://it.wikibooks.org/wiki/Utente:Wim_b/Controllo_vandalismi?action=purge')", 1000*60*3.5);
}

/*</pre>
== Tab "utilità" ==
<pre> */
addOnloadHook(function (){
var urlLinkHere = location.href;
urlLinkHere = urlLinkHere.replace('/Speciale:PuntanoQui/', '/');
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlimenu(tabs, 'utilità', 'utilità'); //puoi cambiare 'Utilità' in qualcos'altro, ma non cambiare 'Sysop'
var utilità = document.getElementById('utilità').getElementsByTagName('ul')[0];
 
//Una riga per ogni voce del menu
      if(document.title.indexOf("Pagine che puntano a") != -1 )
  {
addlilink(utilità, urlLinkHere + '?action=delete','Cancella', '');
  }
     if(document.title.indexOf("Pagine che puntano a") == -1 )
  {
addlilink(utilità,'/wiki/Speciale:PuntanoQui/' + wgPageName,'Puntano qui', ''); // Esempio di collegamento nel menu
  }/*
      if(document.title.indexOf("Discussion") != -1 )
  {
addlilink(utilità,'','Oldid: ' + wgPageName, '');
  }*/

});

/*</pre>
== Coronologia avanzata ==
<pre> */

document.write('<script type="text/javascript" src="' +
'http://it.wiktionary.org/w/index.php?title=MediaWiki:Gadget-CronoAvanzataBase.js' +
'&action=raw&ctype=text/javascript&dontcountme=s"></script>');

document.write('<script type="text/javascript" src="' +
'http://it.wiktionary.org/w/index.php?title=MediaWiki:Gadget-CronoAvanzata.js' +
'&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
/*</pre>
== Script globale ==
<pre> */

document.write('<script type="text/javascript" src="' +
'http://meta.wikimedia.org/w/index.php?title=User:Pathoschild/Scripts/Ajax_sysop.js' +
'&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 

/*</pre>

== Batch delete ==
<pre> */

/* Ajax batch delete thingy, version [0.1.1b]
Originally from: http://en.wikipedia.org/wiki/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.
*/
 
addOnloadHook(function() {
  addPortletLink('p-tb','/wiki/Special:BlankPage?blankspecial=ajaxbd','Batch Delete');
});
 
if(wgCanonicalSpecialPageName && wgCanonicalSpecialPageName.toLowerCase() == 'blankpage' && queryString('blankspecial') == 'ajaxbd') {
  document.title = 'Ajax Batch Deletion';
  addOnloadHook(abdForm);
}
 
function abdForm() {
  addPortletLink('p-tb','/wiki/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')[0];
  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[i];
    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[0];
  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 [[' + page + ']]\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 [[' + page + ']]\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['error']) {
    out.appendChild(document.createTextNode(' ! Errore nelle API: ' + obj['error']['code'] + ' - ' + obj['error']['info'] + '\n'));
    return;
  }
  if(!obj['query'] || !obj['query']['pageids'] || !obj['query']['pages'][obj['query']['pageids'][0]] || !obj['query']['pages'][obj['query']['pageids'][0]]['deletetoken']) {
    out.appendChild(document.createTextNode('  ? Unexpected response: ' + txt + '\n'));
    return;
  }
  var token = obj['query']['pages'][obj['query']['pageids'][0]]['deletetoken'];
  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['error']) {
    out.appendChild(document.createTextNode('   ! Api error: ' + obj['error']['code'] + ' - ' + obj['error']['info'] + '\n'));
  } else if(obj['delete'] && obj['delete']['title']) {
    out.appendChild(document.createTextNode('   > La pagina [[' + obj['delete']['title'] + ']] è 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[1]);
    } catch (e) {
    }
  }
  return null;
}


/*</pre>
== Script per i titoli nei JS ==
<pre> */

function sourceheadings() {
     if ((wgNamespaceNumber == 2 || wgNamespaceNumber == 8) && wgTitle.lastIndexOf('.js') != -1 && wgAction == 'view') {
    var bc = document.getElementById('bodyContent');
    if (bc != null) {
      var pres = bc.getElementsByTagName('pre');
      if (pres.length == 1) {
        var spans = pres[0].getElementsByTagName('span');
        var numspans = spans.length;
        var j = 0;
 
        for (var i = 0; i < numspans; i++) {
          if (spans[i].className == 'coMULTI') {
           var res = null;
           if (spans[i].firstChild.nodeValue)
               // TODO \n+ doesn't seem to work here
               res = spans[i].firstChild.nodeValue.match(/\/\*\s*<\/pre>[\r\n\s]+(==+)(.*?)(==+)[\r\n\s]+<pre>\s*\*\//,"gi");
 
            if (res!= null && res.length != 0) {
              j++;
              var l = res[1].length < res[3].length ? res[1].length : res[3].length;
 
              var h = document.createElement('h' + l);
 
              h.innerHTML = 
                '<span class="editsection">[<a href="' +
                  wgScript + '?title=' + wgPageName + '&amp;action=edit&amp;section=' + j +
                  '">edit</a>]</span><span class="mw-headline">' + res[2] + '</span>';
 
              pres[0].replaceChild(h, spans[i]);
            }
          }
        }
      }
    }
  }
}
 
addOnloadHook(sourceheadings);

// NukeLink V1.0
// Di [[wikt:it:User:Wim b]]
function showNukeLink()
{
 if (wgPageName == 'Speciale:Contributi')
  {
    var usercontribs = document.getElementById('siteSub');
    if (usercontribs)
    {
       var Nukecontribs = document.createElement('a');
       Nukecontribs.href = '/wiki/Special:Nuke' + usercontribs.baseURI.replace("http://it.wikibooks.org/wiki/Speciale:Contributi","")
       Nukecontribs.title = 'Cancella in massa tutte le ultime pagine create da questo utente';
       Nukecontribs.appendChild(document.createTextNode('\n· Cancellazione di massa'));
       usercontribs.appendChild(Nukecontribs);
    }
 }
}
 
addOnloadHook(showNukeLink);

//</nowiki> </pre>