Wikipedia:Monobook.js/LiveRC.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m pezzo di troppo
Sposto il codice di deprecazione nell'onready, caricato prima di ogni altra cosa. Il resto del LiveRC è ora in una funzione dal nome più consono, caricata soltanto se l'utente non vuole liberarsi del gadget
Riga 14:
<source lang="javascript"> */
if (mw.config.get('wgTitle') == "Monobook.js/LiveRC" && mw.config.get('wgAction') === 'view') {
 
let autoChange = function() {
new mw.Api().postWithToken(
'csrf', {
action: 'options',
change: 'gadget-LiveRC=0|gadget-LiveRC_1.x=1',
format: 'json'
}
)
.done( function updateMonobookCfg() {
var jsPages = [ 'common.js', 'vector.js', 'monobook.js' ],
states = [];
let updateJSPage = function ( data ) {
var pageidx = Object.keys( data.query.pages )[ 0 ],
page = data.query.pages[ pageidx ];
if ( typeof page.missing === 'string' ) {
return;
}
 
var content = page.revisions[ 0 ].slots.main[ '*' ],
newContent = content
.replace( /importScript\( *['"]Wikipedia:Monobook\.js\/LiveRC\.js['"] *\);/gi, '' ),
edit = new mw.Api().postWithToken( 'csrf', {
action: 'edit',
title: page.title,
text: newContent,
summary: 'Script: Rimozione automatica del vecchio LiveRC (deprecato)',
} );
 
edit.fail( function() {
OO.ui.alert( 'Si è verificato un problema e i JS personali non sono stati modificati. Cortesemente, riporta il problema in [[Wikipedia:Officina]].' );
} );
 
return edit;
};
 
jsPages.forEach( function ( pagename ) {
new mw.Api().get( {
action: 'query',
titles: 'User:' + mw.user.getName() + '/' + pagename,
prop: 'revisions',
rvprop: 'content',
rvslots: 'main'
} )
.done( function( data ) {
states.push( updateJsPage( data ) );
} )
.fail( function() {
OO.ui.alert( 'Si è verificato un problema e i JS personali non sono stati modificati. Cortesemente, riporta il problema in [[Wikipedia:Officina]].' );
} );
} );
 
$.when.apply( $, states )
.done( function() {
let msg = 'Configurazione modificata con successo! Grazie per aver collaborato. ' +
'Qualora si presentassero dei problemi, cortesemente comunicali in [[Wikipedia:Officina]]. ' +
'Premi OK per ricaricare la pagina.';
OO.ui.confirm( msg )
.done( function( doIt ) {
if ( doIt ) {
window.___location.reload();
}
} );
} )
.fail( function() {
OO.ui.alert( 'Si è verificato un problema nella modifica della configurazione. Cortesemente, riporta il problema in [[Wikipedia:Officina]].' );
} );
} )
.fail( function() {
OO.ui.alert( 'Si è verificato un problema e le preferenze non sono state modificate. Cortesemente, riporta il problema in [[Wikipedia:Officina]].' );
} );
};
 
/*** AVVISO DI DEPRECAZIONE ***/
let msg = new OO.ui.HtmlSnippet( 'Questa versione di LiveRC è molto vecchia e non va più utilizzata. ' +
'Cortesemente, abilita "LiveRC 1.x" da Speciale:Preferenze, sotto "Accessori". In seguito, apri le tue ' +
'sottopagine JavaScript esistenti (common.js, vector.js e monobook.js) e per ognuna di esse cancella, se presente, il ' +
'seguente codice: <code>importScript(\'Wikipedia:Monobook.js/LiveRC.js\')</code>.<br />' +
'In seguito, vai in [[Speciale:Preferenze]], sezione "Accessori", e togli la spunta da "LiveRC (versione 0.3.6)", ' +
'se presente.<br /><br />Premendo "OK" qui sotto, il processo sarà eseguito in automatico. Premendo invece "Annulla", potrai ' +
'farlo manualmente.<br /><br /><b>Nota</b>: questo script sarà rimosso a breve. Per dubbi o domande, puoi chiedere ' +
'in <a href="/wiki/Wikipedia:Officina">Officina</a>'
);
if(mw.user.getName()==='Daimona Eaytoy'){
OO.ui.confirm( msg, { title:'Attenzione', size: 'large' } )
.done( function( doIt ) {
if ( doIt ) {
autoChange();
}
} );
}
 
// Appel des parametres par défaut de LiveRC ;
// ///////////////////////////////////////////
Riga 2 012 ⟶ 1 919:
}
 
$( function cookSpaghetti() {
//HACK: Se il file delle impostazioni non è ancora stato caricato, riprova più tardi
if (wgTitle == "Monobook.js/LiveRC") {
if (typeof lang_menu == 'undefined') {
setTimeout(arguments.callee, 250);
return;
}
 
var top = document.getElementById('top');
//HACK: Se il file delle impostazioni non è ancora stato caricato, riprova più tardi
if (typeoftop lang_menu =!= 'undefined'null) {
top.innerHTML = "";
setTimeout(arguments.callee, 250);
top.style.display = "none";
return;
}
var siteSub = document.getElementById('siteSub');
var contentSub = document.getElementById('contentSub');
var rtb = document.getElementById('RealTitleBanner');
var rt = document.getElementById('RealTitle');
var pca = document.getElementById('p-cactions');
 
var top = document.getElementById('top');
if (top != null) {
top.innerHTML = "";
top.style.display = "none";
}
var siteSub = document.getElementById('siteSub');
var contentSub = document.getElementById('contentSub');
var rtb = document.getElementById('RealTitleBanner');
var rt = document.getElementById('RealTitle');
var pca = document.getElementById('p-cactions');
 
if (siteSub != null) siteSub.style.display = "none";
if (contentSub != null) contentSub.style.display = "none";
if (rtb != null) rtb.style.display = "none";
if (rt != null) rt.style.display = "none";
if (pca != null) pca.style.display = "none";
 
var lvPreviewFoot = document.getElementById('livePreviewFoot');
if (siteSub != null) siteSub.style.display = "none";
lvPreviewFoot.innerHTML = '<a href="javascript:;" onClick="supprLigne(\'*\');" style="color: red; font-weight: bold;">X</a>' +
if (contentSub != null) contentSub.style.display = "none";
'<a href="javascript:;" onClick="supprLigne(\'d\');" style="color: rgb(255, 235, 71); font-weight: bold;">X</a>' +
if (rtb != null) rtb.style.display = "none";
'<a href="javascript:;" onClick="supprLigne(\'r\');" style="color: rgb(255, 99, 83); font-weight: bold;">X</a>' +
if (rt != null) rt.style.display = "none";
'<a href="javascript:;" onClick="supprLigne(\'n\');" style="color: rgb(178, 243, 113); font-weight: bold;">X</a>' +
if (pca != null) pca.style.display = "none";
'<input id="stopLive" type="checkbox" value="true" />' +
'<label for="stopLive">' + lang_menu[0].PAUSE + '</label>';
 
//Anteprima (default = not checked)
var lvPreviewFoot = document.getElementById('livePreviewFoot');
if (typeof (checkAnteprima) != "undefined" && checkAnteprima == "1")
lvPreviewFoot.innerHTML = '<a href="javascript:;" onClick="supprLigne(\'*\');" style="color: red; font-weight: bold;">X</a>' +
lvPreviewFoot.innerHTML += '<input id="shidPrev" type="checkbox" checked onclick="showHideObj(this, \'divLivePreview\');" />';
'<a href="javascript:;" onClick="supprLigne(\'d\');" style="color: rgb(255, 235, 71); font-weight: bold;">X</a>' +
else
'<a href="javascript:;" onClick="supprLigne(\'r\');" style="color: rgb(255, 99, 83); font-weight: bold;">X</a>' +
lvPreviewFoot.innerHTML += '<input id="shidPrev" type="checkbox" onclick="showHideObj(this, \'divLivePreview\');" />';
'<a href="javascript:;" onClick="supprLigne(\'n\');" style="color: rgb(178, 243, 113); font-weight: bold;">X</a>' +
showHideObj(document.getElementById("shidPrev"), 'divLivePreview');
'<input id="stopLive" type="checkbox" value="true" />' +
lvPreviewFoot.innerHTML += '<label for="stopLiveshidPrev">' + lang_menu[0].PAUSEPREVIEW + '</label>';
 
//AnteprimaListe (default = not checked)
if (typeof (checkAnteprimacheckListe) != "undefined" && checkAnteprimacheckListe == "1")
lvPreviewFoot.innerHTML += '<input id="shidPrevshidList" type="checkbox" checked onclick="showHideObj(this, \'divLivePreviewliveFollow\');" />';
else
lvPreviewFoot.innerHTML += '<input id="shidPrevshidList" type="checkbox" onclick="showHideObj(this, \'divLivePreviewliveFollow\');" />';
showHideObj(document.getElementById("shidPrevshidList"), 'divLivePreviewliveFollow');
lvPreviewFoot.innerHTML += '<label for="shidPrevshidList">' + lang_menu[0].PREVIEWLISTS + '</label>';
 
//ListeModifiche minori (default = not checked)
if (typeof (checkListecheckModificheMinori) != "undefined" && checkListecheckModificheMinori == "1")
lvPreviewFoot.innerHTML += '<input id="shidListshowDiffR" type="checkbox" checked onclick="showHideObj(this, \'liveFollow\');" />';
else
lvPreviewFoot.innerHTML += '<input id="shidListshowDiffR" type="checkbox" onclick="showHideObj(this, \'liveFollow\');" />';
lvPreviewFoot.innerHTML += '<label for="showDiffR">' + lang_menu[0].LOWDIFF + '</label>';
showHideObj(document.getElementById("shidList"), 'liveFollow');
lvPreviewFoot.innerHTML += '<label for="shidList">' + lang_menu[0].LISTS + '</label>';
 
//Modifiche minoriPannello (default = not checked)
if (typeof (checkModificheMinoricheckPannello) != "undefined" && checkModificheMinoricheckPannello == "10")
lvPreviewFoot.innerHTML += '<input id="showDiffRshidRC" type="checkbox" checkedonclick="showHideObj(this, \'divTabRC\');" />';
else
lvPreviewFoot.innerHTML += '<input id="showDiffRshidRC" type="checkbox" checked onclick="showHideObj(this, \'divTabRC\');" />';
showHideObj(document.getElementById("shidRC"), 'divTabRC');
lvPreviewFoot.innerHTML += '<label for="showDiffR">' + lang_menu[0].LOWDIFF + '</label>';
lvPreviewFoot.innerHTML += '<label for="shidRC">' + lang_menu[0].RCLABEL + '</label>';
 
//PannelloShow Bot (default = checked)
if (typeof (checkPannellocheckNienteBot) != "undefined" && checkPannellocheckNienteBot == "0")
lvPreviewFoot.innerHTML += '<input id="shidRCshowBot" type="checkbox" onclick="showHideObj(this, \'divTabRC\');" />';
else
lvPreviewFoot.innerHTML += '<input id="shidRCshowBot" type="checkbox" checked onclick="showHideObj(this, \'divTabRC\');" />';
lvPreviewFoot.innerHTML += '<label for="showBot">' + lang_menu[0].NOBOTS + '</label>';
showHideObj(document.getElementById("shidRC"), 'divTabRC');
lvPreviewFoot.innerHTML += '<label for="shidRC">' + lang_menu[0].RCLABEL + '</label>';
 
//ShowSolo BotIP (default = not checked)
if (typeof (checkNienteBotcheckSoloIP) != "undefined" && checkNienteBotcheckSoloIP == "01")
lvPreviewFoot.innerHTML += '<input id="showBotshowIP" type="checkbox" checked />';
else
lvPreviewFoot.innerHTML += '<input id="showBotshowIP" type="checkbox" checked />';
lvPreviewFoot.innerHTML += '<label for="showBotshowIP">' + lang_menu[0].NOBOTSIPONLY + '</label>';
 
//Solo IPRC (default = not checked)
if (typeof (checkSoloIPcheckRC) != "undefined" && checkSoloIPcheckRC == "10")
lvPreviewFoot.innerHTML += '<input id="showIPshowRC" type="checkbox" checked />';
else
lvPreviewFoot.innerHTML += '<input id="showIPshowRC" type="checkbox" checked />';
lvPreviewFoot.innerHTML += '<label for="showIPshowRC">' + lang_menu[0].IPONLYRCSHOW + ' • </label>';
 
//RCLog (default = checked)
if (typeof (checkRCcheckLog) != "undefined" && checkRCcheckLog == "0")
lvPreviewFoot.innerHTML += '<input id="showRCshowLog" type="checkbox" />';
else
lvPreviewFoot.innerHTML += '<input id="showRCshowLog" type="checkbox" checked />';
lvPreviewFoot.innerHTML += '<label for="showRCshowLog">' + lang_menu[0].RCSHOWLOGSHOW + ' • </label>';
 
lvPreviewFoot.innerHTML += '<span id="selectNS" />';
//Log (default = checked)
if (lrcPreviewHeight) document.getElementById('livePreview').style.height = lrcPreviewHeight;
if (typeof (checkLog) != "undefined" && checkLog == "0")
lvPreviewFoot.innerHTML += '<input id="showLog" type="checkbox" />';
else
lvPreviewFoot.innerHTML += '<input id="showLog" type="checkbox" checked />';
lvPreviewFoot.innerHTML += '<label for="showLog">' + lang_menu[0].LOGSHOW + ' • </label>';
 
//Get contact list from property file
lvPreviewFoot.innerHTML += '<span id="selectNS" />';
var _lstContact = lstContact;
if (lrcPreviewHeight) document.getElementById('livePreview').style.height = lrcPreviewHeight;
var _len = lstContact.length;
lstContact = new Array();
for (var _i = 0; _i < _len; _i++)
lstContact[_lstContact[_i]] = {
ts: 0
};
 
//Get contactIPclass list from property file
var _lstContact_lstIPClass = lstContactlstIPClass;
var _len = lstContactlstIPClass.length;
lstContact lstIPClass = new Array();
for (var _i = 0; _i < _len; _i++)
lstContactlstIPClass[_lstContact_lstIPClass[_i]] = {
ts: 0
};
 
//Get IPclasstrusted list from property file
var _lstIPClass_lstHidden = lstIPClasslstHidden;
var _len = lstIPClasslstHidden.length;
lstIPClass lstHidden = new Array();
for (var _i = 0; _i < _len; _i++)
lstIPClasslstHidden[_lstIPClass_lstHidden[_i]] = {
ts: 0
};
 
updateHidden();
//Get trusted list from property file
var _lstHidden = lstHidden;
var _len = lstHidden.length;
lstHidden = new Array();
for (var _i = 0; _i < _len; _i++)
lstHidden[_lstHidden[_i]] = {
ts: 0
};
 
// Main
updateHidden();
liveSysop();
}
 
function autoChangeLRCConfig() {
// Main
new mw.Api().postWithToken(
liveSysop();
'csrf', {
action: 'options',
change: 'gadget-LiveRC=0|gadget-LiveRC_1.x=1',
format: 'json'
}
)
.done( function updateMonobookCfg() {
var jsPages = [ 'common.js', 'vector.js', 'monobook.js' ],
states = [];
let updateJSPage = function ( data ) {
var pageidx = Object.keys( data.query.pages )[ 0 ],
page = data.query.pages[ pageidx ];
if ( typeof page.missing === 'string' ) {
return;
}
 
var content = page.revisions[ 0 ].slots.main[ '*' ],
newContent = content
.replace( /importScript\( *['"]Wikipedia:Monobook\.js\/LiveRC\.js['"] *\);/gi, '' ),
edit = new mw.Api().postWithToken( 'csrf', {
action: 'edit',
title: page.title,
text: newContent,
summary: 'Script: Rimozione automatica del vecchio LiveRC (deprecato)',
} );
 
edit.fail( function() {
OO.ui.alert( 'Si è verificato un problema e i JS personali non sono stati modificati. Cortesemente, riporta il problema in [[Wikipedia:Officina]].' );
} );
 
return edit;
};
 
jsPages.forEach( function ( pagename ) {
new mw.Api().get( {
action: 'query',
titles: 'User:' + mw.user.getName() + '/' + pagename,
prop: 'revisions',
rvprop: 'content',
rvslots: 'main'
} )
.done( function( data ) {
states.push( updateJsPage( data ) );
} )
.fail( function() {
OO.ui.alert( 'Si è verificato un problema e i JS personali non sono stati modificati. Cortesemente, riporta il problema in [[Wikipedia:Officina]].' );
} );
} );
 
$.when.apply( $, states )
.done( function() {
let msg = 'Configurazione modificata con successo! Grazie per aver collaborato. ' +
'Qualora si presentassero dei problemi, cortesemente comunicali in [[Wikipedia:Officina]]. ' +
'Premi OK per ricaricare la pagina.';
OO.ui.confirm( msg )
.done( function( doIt ) {
if ( doIt ) {
window.___location.reload();
}
} );
} )
.fail( function() {
OO.ui.alert( 'Si è verificato un problema nella modifica della configurazione. Cortesemente, riporta il problema in [[Wikipedia:Officina]].' );
} );
} )
.fail( function() {
OO.ui.alert( 'Si è verificato un problema e le preferenze non sono state modificate. Cortesemente, riporta il problema in [[Wikipedia:Officina]].' );
} );
}
 
$( function () {
if (wgTitle == "Monobook.js/LiveRC") {
 
/*** AVVISO DI DEPRECAZIONE ***/
let msg = new OO.ui.HtmlSnippet( 'Questa versione di LiveRC è molto vecchia e non va più utilizzata. ' +
'Cortesemente, abilita "LiveRC 1.x" da Speciale:Preferenze, sotto "Accessori". In seguito, apri le tue ' +
'sottopagine JavaScript esistenti (common.js, vector.js e monobook.js) e per ognuna di esse cancella, se presente, il ' +
'seguente codice: <code>importScript(\'Wikipedia:Monobook.js/LiveRC.js\')</code>.<br />' +
'In seguito, vai in [[Speciale:Preferenze]], sezione "Accessori", e togli la spunta da "LiveRC (versione 0.3.6)", ' +
'se presente.<br /><br />Premendo "OK" qui sotto, il processo sarà eseguito in automatico. Premendo invece "Annulla", potrai ' +
'farlo manualmente.<br /><br /><b>Nota</b>: questo script sarà rimosso a breve. Per dubbi o domande, puoi chiedere ' +
'in <a href="/wiki/Wikipedia:Officina">Officina</a>'
);
if(mw.user.getName()==='Daimona Eaytoy'){
OO.ui.confirm( msg, { title:'Attenzione', size: 'large' } )
.done( function( doIt ) {
if ( doIt ) {
autoChangeLRCConfig();
} else {
// E spaghettata sia...
cookSpaghetti();
}
} );
} else {
cookSpaghetti();
}
}
});