MediaWiki:Common.js: differenze tra le versioni

username fix
Nessun oggetto della modifica
(username fix)
Riga 4:
// per Template:USERNAME, che mostra il nome dell'utente che legge
mw.loader.load( '/w/index.php?title=MediaWiki:Insertusername.js&action=raw&ctype=text/javascript' );
 
function usernameReplace() {
var spanList = $('span.insertusername');
wgServer=mw.config.get("wgServer");
wgScriptPath=mw.config.get("wgScriptPath");
wgUserName=mw.config.get("wgUserName");
if(!spanList.length) {
return;
}
var defaultText = '<Dio>';
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;
}
$(usernameReplace);
 
/** SCOPIAZZATO DA WIKIPEDIA: https://it.wikipedia.org/w/index.php?title=MediaWiki:Common.js&oldid=102712037 **/
Line 107 ⟶ 157:
// Supporto ai template
// ============================
 
/**
* Utilizzata in [[template:USERNAME]] (?)
*/
 
function usernameReplace() {
var spanList = $('span.insertusername');
if(!spanList.length) {
return;
}
var defaultText = '<Dio>';
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;
}
$( usernameReplace );
 
/**