MediaWiki:Gadget-CatWatch.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
correzioni da parte di Rotpunkt
jslint compliant
Riga 14:
* @author [[Utente:Rotpunkt]]
*/
/*jslint unparam: true, evil: true */
/*global CategorieOsservate: false, alert: false, confirm: false, document: false, mediaWiki: false, jQuery: false */
 
(function (mw, $) {
Line 19 ⟶ 21:
 
// Massimo numero di pagine monitorate per categoria (max 500)
var maxPagesInCategory = 100;,
// Configurazione utente
var userConfig = 'Utente:' + mw.config.get('wgUserName') + '/CategorieOsservate.js';,
// Modello di configurazione
var configModel = 'MediaWiki:Gadget-CatWatch.js/CategorieOsservateTemplate.js';,
// Messaggio di aiuto per la prima attivazione
var msgHelp = '[Gadget-CatWatch] Non hai ancora una lista di categorie da controllare. Vuoi crearne una?';
 
// Ritorna la variabile CategorieOsservate nel CategorieOsservate.js dell'utente
Line 39 ⟶ 41:
cache: false
})
.done(function (data) {
try {
eval(data);
} catch (e) {
alert('[Gadget-CatWatch] Errore in ' + userConfig);
return;
}
if (typeof CategorieOsservate !== 'undefined') {
if (CategorieOsservate.length > 0) {
categoryHandler(CategorieOsservate);
} else if (confirm(msgHelp)) }
document.___location} =else if mw.config.get('wgScript'confirm(msgHelp)) +{
document.___location = mw.config.get('?action=edit&title=wgScript'+ userConfig) +
'?action=edit&preloadtitle=' + configModel;userConfig +
'&preload=' + configModel;
})
}
})
.fail(function (jqXHR, textStatus, errorThrown) {
if (mw.util.getParamValue('debug')) {
alert('[Gadget-CatWatch] Errore nel leggere ' +
userConfig + ': ' + errorThrown);
});
});
}
 
Line 77 ⟶ 82:
dataType: 'json'
})
.done(function (data) {
pageHandler(data.query.categorymembers);
});
}
 
Line 90 ⟶ 95:
minutes = date.getMinutes();
months = [
'gen', 'feb', 'mar', 'apr', 'mag', 'giu',
'lug', 'ago', 'set', 'ott', 'nov', 'dic'
];
Line 100 ⟶ 105:
};
}
 
// Crea un nuovo elemento di OsservatiSpeciali
function createWatchlistEl(title, time, category) {
Line 132 ⟶ 137:
// retrocompatibilità con il vecchio CatWatch: con la vista raggruppata
// visualizzava le pagine del CatWatch al fondo del giorno
if (ret[date].length === 0) {
ret[date].push({
time: '23:59',
el: $(this).next('div').find('table:last-child()')
});
}
});
return ret;
Line 144 ⟶ 150:
function watchlistAdd(watchlist, page, category) {
var ts, el, daypages, prepended = false;
 
ts = parseTimestamp(page.timestamp);
daypages = watchlist[ts.date];
Line 150 ⟶ 156:
el = createWatchlistEl(page.title, ts.time, category);
// per tutte le pagine di quel giorno cerca quella col time antecedente
$.each(daypages, function (i, entry) {
if (ts.time > entry.time) {
entry.el.before(el);
Line 167 ⟶ 173:
$(document).ready(function () {
// Se la pagina corrente è Speciale:OsservatiSpeciali
if (mw.config.get('wgPageName') === 'Speciale:OsservatiSpeciali') {
// scarica la lista delle categorie da monitorare.
getUserConfig(function (categories) {