MediaWiki:Common.js: differenze tra le versioni

nessun oggetto della modifica
(disabilito Wikidata, serve a 1 fava)
Nessun oggetto della modifica
Riga 1:
/* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti. */
 
/* AGGIUNTE NOSTRE */
 
// Funzione per inserire il nome utente in appositi elementi
// Autore: Sparkla
function usernameReplace() {
var spanList = $('span.insertusername');
if(!spanList.length) {
return;
}
var defaultText = '<tuo nome>';
if(wgUserName) {
spanList.text(wgUserName);
return;
}
else {
spanList.text(defaultText);
}
var userPage = $('#pt-anonuserpage');
if(userPage.length > 0) {
var IP = $('a:first', userPage);
if(!IP.length) {
return;
}
spanList.each(function() {
if($(this).text() == defaultText) {
$(this).text(IP.text());
}
});
return;
}
var IP = undefined;
$.ajax({
url: wgServer + wgScriptPath + '/api.php?action=query&meta=userinfo&format=xml',
dataType: 'xml',
async: false,
success: function(data) {
IP = $('userinfo', data).attr('name');
}
});
if(!IP) {
return;
}
spanList.each(function() {
if($(this).text() == defaultText) {
$(this).text(IP);
}
});
return;
}
 
/** SCOPIAZZATO DA WIKIPEDIA: https://it.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=102712037 **/