Utente:FiloSottile/tatoo.js

Da Wikipedia, l'enciclopedia libera.
Vai alla navigazione Vai alla ricerca

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.

/*
ATTENZIONE VA IN CONFLITTO CON I TATOO NORMALI: NON USARE ENTRAMBI.

Visualizza un tatoo il cui link è settabile da una comoda finestrella. Ottenendo un comodo rimando alla pagina a cui state lavorando sempre sullo schermo

Basta insereire questo in fondo al [[Special:MyPage/monobook.js|proprio monobook]]:
importScript('Utente:FiloSottile/tatoo.js"></script>');


*/
//Mostra i Tatoo

$.get('//it.wikipedia.org/w/index.php?title=Utente:FiloSottile/Tatoo&action=raw&ctype=text/plain', function (data) {
    var Lavori = "<div style=\"position:fixed;background-color:transparent;bottom:10px;right:10px;z-index:1000;display:block\"><A HREF=\"//it.wikipedia.org/wiki/" + data + "\"><IMG SRC=\"http://upload.wikimedia.org/wikipedia/commons/1/1a/FinkCommander_in_use.png\" WIDTH=\"40\" HEIGHT=\"40\" ALT=\"Lavoro attuale\"></IMG></A></div>";
    mw.util.$content.append(Lavori);
});	

//************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;

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


/*<
Ricordatevi di aggiornare la cache ogni volta che cambiate il link. 
Grazie a [[Utente:Jalo|Jalo]]
*/