Utente:Valepert/notifications.js

Questa pagina definisce alcuni parametri di aspetto e comportamento generale di tutte le pagine. Per personalizzarli vedi Aiuto:Stile utente.


Nota: dopo aver salvato è necessario pulire la cache del proprio browser per vedere i cambiamenti (per le pagine globali è comunque necessario attendere qualche minuto). Per Mozilla / Firefox / Safari: fare clic su Ricarica tenendo premuto il tasto delle maiuscole, oppure premere Ctrl-F5 o Ctrl-R (Command-R su Mac); per Chrome: premere Ctrl-Shift-R (Command-Shift-R su un Mac); per Konqueror: premere il pulsante Ricarica o il tasto F5; per Opera può essere necessario svuotare completamente la cache dal menù Strumenti → Preferenze; per Internet Explorer: mantenere premuto il tasto Ctrl mentre si preme il pulsante Aggiorna o premere Ctrl-F5.

var notcontinue;

// see https://www.mediawiki.org/wiki/Echo_(Notifications)/Developer_guide#Notification_categories
cats = { "reverted": "Annullamento", "edit-user-talk": "Messaggio", "page-linked": "Collegamento", "mention": "Menzione", "edit-thank": "Ringraziamento" }

function notifications() {
result = $.ajax({
  // see https://www.mediawiki.org/wiki/Echo_(Notifications)/API & http://www.mediawiki.org/wiki/Manual:Interface/JavaScript
  url: mw.config.get('wgServer') + mw.config.get('wgScriptPath') + "/api.php?" + "action=query&meta=notifications" + "&format=json" + (notcontinue ? "&notcontinue=" + notcontinue : ""),
  async: false,
  dataType: 'json',
  success: function (response) {
    // notcontinue = response.responseJSON.query.notifications.continue;
    return (response)
  }
});
notcontinue = result.responseJSON.query.notifications.continue;
return result.responseJSON.query.notifications.list;
}

function echo_notification() {
notlist = notifications()
for (msg in notlist) { console.log(cats[notlist[msg].type], notlist[msg].agent.name, notlist[msg].title.text, notlist[msg].timestamp.date, Date(notlist[msg].timestamp.mw)) }
$("#notifications").attr("alt", notcontinue)
$("#notifications").attr("title", notcontinue)
}

$(".mw-echo-notifications-badge").parent().append(" <a id=\"notifications\" href=\"javascript:echo_notification()\">(?)</a>")