Utente:FiloSottile/monobook.js/standard.js

Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.


Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.

//<pre><nowiki>

var myButtons = new Array([2,'{{Utente:FiloSottile/Auguri}}\\n','','Cancellazione',70,'Tanti Auguri!']);
var nomeBot="BotSottile";







/*

Questo script consente di effettuare ricerche su google selezionando del testo con il mouse mentre si tiene premuto Ctrl. La ricerca viene avviata in una nuova finestra non appena si rilascia il pulsante del mouse.

*/
//<pre><nowiki>
//Speedy Google Search
$(function(){
  var listener = function(e){
    e = (e) ? e : ((window.event) ? window.event : null);
    if(e && e.ctrlKey){
      if(navigator.appName=='Microsoft Internet Explorer' && navigator.userAgent.indexOf("Opera")==-1) //IE
        var t = document.selection.createRange().text;
      else //Non-IE
        var t = document.getSelection().toString();
      t = t.replace(/^\s+/, '').replace(/\s+$/, ''); //trim
      var q = t.indexOf('"') == -1 ? '"' : '';
      if(t)
        window.open("http://www.google.com/search?q=" + q + encodeURIComponent(t) + q);
    }
  }
  if (window.addEventListener)
    window.addEventListener('mouseup', listener, false); //Non-IE
  else
    document.onmouseup = listener; //IE
});
//</nowiki></pre>

//Mostra i Tatoo
importScript("Utente:FiloSottile/Tatoo");


//************SET TATOO***********

// adds tab "set tatoo"
	mw.loader.using( 'mediawiki.util' )
		.then( function () {
			mw.util.addPortletLink('p-cactions', 'javascript:setCurrentTatoo()', 'set tatoo', 'pb-sstatus');
	} );

function setCurrentTatoo()
{
Greeter = "       Inserisci la nuova pagina       ";
    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(0)';
				$(a).on('click', function() { $('#inlinePopupDiv').remove(); } );
                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('Pagina:'));
                     
            var stato = document.createElement('input');
            stato.name = 'status';
            stato.id = 'stato';
            stato.type = 'text';
            p.appendChild(stato);
       
            var button = document.createElement('input');
            button.value = 'OK';
            button.type = 'button';
            button.setAttribute('onclick', 'saveNewTatoo()');
            p.appendChild(button);

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

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

function saveNewTatoo()
{
    // Questo e' il valore che avevi scritto nella casella di testo
    var newTatoo = document.getElementById('stato').value;
        
    var newString = '//LAVORI\n'+
'var Lavori="<div style=\\"position:fixed;background-color:transparent;bottom:10px;right:10px;z-index:1000;display:block\\"><A '+
'HREF=\\"http://it.wikipedia.org/wiki/'+newTatoo+'\\"><IMG '+
'SRC=\\"http://upload.wikimedia.org/wikipedia/commons/1/1a/FinkCommander_in_use.png\\" WIDTH=\\"40\\" HEIGHT=\\"40\\" '+
'ALT=\\"Lavoro attuale\\"></IMG></A></div>";\nmw.util.$content.append(Lavori);';

    // registra il valore
    new mw.Api().postWithEditToken( {
			action: 'edit',
			title: 'Utente:FiloSottile/Tatoo',
			text: newString,
			summary: 'tatoo modificato in "' + newTatoo + '"'
		} )
		.done ( function () {
		    // e chiudi il popup
    		$('#inlinePopupDiv').remove();
		} );
}

//</pre>

//************SET STATUS***********

// adds tab "set status"
	mw.loader.using( 'mediawiki.util' )
		.then( function () {
			mw.util.addPortletLink('p-cactions', 'javascript:setCurrentStatus()', 'set status', 'pb-sstatus');
	} );

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(0)';
$(a).on('click', function() { $('#inlinePopupDiv').remove(); } );
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;
                        
                        option = new Option("connesso",' ');
                        option.value = "connesso!";
                        sel.options[sel.options.length] = option;

                        option = new Option("occupato",' ');
                        option.value = "occupato...";
                        sel.options[sel.options.length] = option;

                        option = new Option("disconnesso",' ');
                        option.value = "disconnesso";
                        sel.options[sel.options.length] = option;

                        p.appendChild(sel);

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

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

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

function saveNewStatus()
{
var newStatus = document.getElementById('inlinePopupDiv').getElementsByTagName('select')[0].value;
        var newString='Io sono '+newStatus+'\n';
        
        // registra il valore
    	new mw.Api().postWithEditToken( {
			action: 'edit',
			title: 'Utente:FiloSottile/Status',
			text: newString,
			summary: 'status modificato in "' + newStatus + '"'
		} )
		.done ( function () {
		    // e chiudi il popup
    		$('#inlinePopupDiv').remove();
		} );
}

//************SET FINE SCUOLA***********
function setCurrentFine()
{
Greeter = "    Inserisci il giorno di fine scuola    ";
    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(0)';
				$(a).on('click', function() { $('#inlinePopupDiv').remove(); } );
                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('Giorno:'));
                     
            var stato = document.createElement('input');
            stato.name = 'status';
            stato.id = 'stato';
            stato.type = 'text';
            p.appendChild(stato);
       
            var button = document.createElement('input');
            button.value = 'OK';
            button.type = 'button';
            button.setAttribute('onclick', 'saveNewFine()');
            p.appendChild(button);

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

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

function saveNewFine()
{
    // Questo e' il valore che avevi scritto nella casella di testo
    var newFine = document.getElementById('stato').value;
    
    // registra il valore
	new mw.Api().postWithEditToken( {
		action: 'edit',
		title: 'Utente:FiloSottile/Scuola/1',
		text: newFine,
		summary: 'fine modificato in "' + newFine + '"'
	} )
		.done ( function () {
		    // e chiudi il popup
    		$('#inlinePopupDiv').remove();
		} );
}

/*
</nowiki>
==Set Canc==
<nowiki>
*/


function impostaCookie (nome, valore, scadenza) {
 
    if (scadenza == "") {
        var oggi = new Date();
        oggi.setMonth(oggi.getMonth() + 3);
        //restituisce la data nel formato necessario
        scadenza = oggi.toGMTString();
    }
    valore = escape(valore);
    document.cookie=nome + "=" + valore + ";expires=" + scadenza;
}

function valoreCookie (nome) {
   var valore=document.cookie; //ottiene la stringa di cookie
   var inizioCookie=valore.indexOf(" " + nome + "="); //trova il cookie desiderato
 
   if (inizioCookie == -1) { //se non esiste, magari è all'inizio della stringa
      inizioCookie = valore.indexOf(nome + "=");
   }
 
   if (inizioCookie == -1) { //il cookie non esiste proprio
      valore = null;
   }
 
   if (inizioCookie >= 0) //il cookie esiste
   {
      inizioCookie = valore.indexOf("=", inizioCookie) + 1; //qui inizia la stringa del valore
      var fineCookie = valore.indexOf(";", inizioCookie); //qui finisce
      if (fineCookie == -1)  //se non viene trovato, allora è l'ultimo cookie
         fineCookie = valore.length;
      valore = unescape(valore.substring(inizioCookie, fineCookie)); //elimina i caratteri commutati
   }
 
   return valore;
}

function cookieAttivi () {

    var oggi = new Date();
    oggi.setDate(oggi.getDate() + 1);
    //restituisce la data nel formato necessario
    var scade = oggi.toGMTString();

    ris = false; //imposta il risultato a falso
    impostaCookie("testCookie", "test", scade); //crea il cookie fittizio
    if (valoreCookie("testCookie") == "test") { //se esiste
        ris = true; //allora i cookie sono abilitati
    }
    return ris;
}



// adds tab "set canc"
if (wgAction == 'edit') {
	mw.loader.using( 'mediawiki.util' )
		.then( function () {
			mw.util.addPortletLink('p-cactions', 'javascript:setCurrentCanc()', 'set canc', 'pb-sstatus');
	} );
 }


function biscotto() {

var Istruzioni = '';

 if (cookieAttivi()) {

  if (valoreCookie(CancWiki) == 'null') {
   impostaCookie (CancWiki, 'true', 'Mon, 27 December 2010 00:00:00');
   alert (Istruzioni);
   setCurrentCanc();
  } else {
   setCurrentCanc();
  }


 } else {
 setCurrentCanc();
 }
}


function setCurrentCanc()
{
Greeter = "Attenzione: lo script non funziona con caratteri quali è maiuscola (ecc.) o /";
    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(0)';
				$(a).on('click', function() { $('#inlinePopupDiv').remove(); } );
                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('Motivo della richiesta di cancellazione:'));
                     
            var stato = document.createElement('input');
            stato.name = 'status';
            stato.id = 'stato';
            stato.type = 'text';
            p.appendChild(stato);
       
            var button = document.createElement('input');
            button.value = 'OK';
            button.type = 'button';
            button.setAttribute('onclick', 'saveNewCanc()');
            p.appendChild(button);

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

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







function saveNewCanc()
{
    var newCaPa = '{{subst:' + wgPageName + '}}'
    var newCanc = wgPageName;
    var newUser = wgUserName;
    var newMoti = document.getElementById('stato').value;
    var newCont = '{{Cancellazione/richiesta|' + wgPageName + '}}\n\n' + newMoti + ' ~~' + '~~';
    var newPage = '<noinclude>{{cancellazione}}</noinclude> \n {{subst:' + 'Utente:' + newUser + '/Canc/Page' + '}}';


arrayMese = new Array("gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", 
                      "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre");
var date = new Date();
giorno = "" + date.getDate();
mese = arrayMese[date.getMonth()];
anno = "" + date.getFullYear();

    var newDate = anno + "_" + mese + "_" + giorno;

    //wpTextbox1 = document.getElementById("wpTextbox1")
    //document.editform.wpTextbox1.value = newTemp;
    //document.editform.wpSummary.value = 'Script cancellazione';
    //document.editform.wpSave.click();

document.editform.wpTextbox1.value = '{{cancellazione}}' + '\n' + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = '+cancellazione';


    // registra il valore
	new mw.Api().postWithEditToken( {
		action: 'edit',
		title: 'Utente:' + mw.config.get('wgUserName'),
		text: newCanc,
		summary: 'Set Pagina da cancellare'
	} )
		.done(function() {
			new mw.Api().postWithEditToken( {
				action: 'edit',
				title: 'Wikipedia:Pagine_da_cancellare/' + newCanc,
				text: newCont,
				summary: 'Da aiutare da tempo'
			} )
			.done( function() {
				// e chiudi il popup
    			$('#inlinePopupDiv').remove();
    			// apre la pagina
    			window.open('http://it.wikipedia.org/w/index.php?title=Wikipedia:Pagine_da_cancellare/Log/' + newDate + '&action=edit');

			    // apre la pagina
    			window.open('http://it.wikipedia.org/w/index.php?title=' + newCanc + '&action=history');

				document.editform.wpSave.click();
			} )
		} )
}

//</nowiki></pre>