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
// Modello di configurazione
// Messaggio di aiuto per la prima attivazione
// 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 (
if (CategorieOsservate.length > 0) {
categoryHandler(CategorieOsservate);
document.___location =
'?action=edit&
'&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) {
|