Utente:Alex brollo/medagliette.js
Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.
- Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
- Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
- Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
- Opera: premi Ctrl-F5.
// rimuove il box di visualizzazione
function delShow() {$("#showCode").remove();}
function medagliette() {
oggetto=JSON.parse($.ajax({url:"/w/api.php?"+
"action=query&"+
"format=json&"+
"rcnamespace=108&"+
"list=recentchanges&"+
"rcprop=user|title|comment&"+
"rclimit=500",
async: false
}).responseText);
og=oggetto.query.recentchanges;
var listaUtenti=[];
var lista=[];
for (var i=0;i<og.length;i+=1) {
if (og[i].comment.replace(/_/g," ").indexOf("/* Pagine SAL 100% */")>-1 && og[i].title.indexOf(wgTitle)>-1) {
commento=og[i].comment;
utente="* [[Utente:"+og[i].user+"]]";
titolo=og[i].title;
lista.push([og[i].comment,og[i].user,og[i].title]);
if (listaUtenti.indexOf(utente)==-1) listaUtenti.push(utente);
}
}
var box='<div ondblclick="delShow()" style="white-space:pre-wrap; background-color:#F2FFFF; font-family:Courier; font-size:0.7pc; position:fixed; width:30%; height:300px; top:20px; right:20px; z-index:999; overflow:auto; resize:both; border:1px solid black;" id="showCode">';
box+='<div class="showCodeBarHeader" style="background-color:lightBlue;width:100%;height:25px">'+
'<button class="btn" onclick="delShow()" style="float:right;">Chiudi</button></div>'+
"Utenti che hanno portato a SAL 100% una pagina, ultime 500 modifiche:<br /><br />"+
listaUtenti.join("</br>")+
'</div>';
$(box).appendTo($("body"));
return [listaUtenti,lista];
}
// crea un tattoo per invocare la funzione show
function showMedagliette() {
if (wgCanonicalNamespace=="Index" && wgAction=="view"){
var tattooDiv='<div id="tattoo" style="position:fixed; bottom:40px;right:10px; z-index:1003;display:block">';
tattooDiv+='<a href="javascript:medagliette()"><img src="//upload.wikimedia.org/wikipedia/commons/f/f5/Silk_award_star_bronze_1.png" /></a>';
tattooDiv+='</div>';
document.getElementById("content").innerHTML += tattooDiv;
}
}
// carica il codice tattoo
$(document).ready(showMedagliette);