144 lines
7.3 KiB
JavaScript
144 lines
7.3 KiB
JavaScript
// Dati finti per il prototipo dell'interfaccia GrumpyDove Mobile.
|
|
// Struttura ispirata a Eudora: account in cima, cartelle annidate sotto,
|
|
// conteggio dei non letti che risale fino all'account.
|
|
// ES5 puro: si puo' caricare con node per i test.
|
|
|
|
var ACCOUNTS = [
|
|
{ name: "carlo@example.org", unread: 9 },
|
|
{ name: "progetti@example.net", unread: 2 }
|
|
];
|
|
|
|
// depth = livello di annidamento nella vista ad albero
|
|
var MAILBOXES = [
|
|
{ name: "carlo@example.org", depth: 0, unread: 9, kind: "account", mailbox: "" },
|
|
{ name: "In", depth: 1, unread: 7, kind: "in", mailbox: "in" },
|
|
{ name: "Out", depth: 1, unread: 0, kind: "out", mailbox: "out" },
|
|
{ name: "Draft", depth: 1, unread: 2, kind: "draft", mailbox: "draft" },
|
|
{ name: "Junk", depth: 1, unread: 3, kind: "junk", mailbox: "junk" },
|
|
{ name: "Trash", depth: 1, unread: 0, kind: "trash", mailbox: "trash" },
|
|
{ name: "Liste", depth: 1, unread: 0, kind: "folder", mailbox: "liste" },
|
|
{ name: "Sailfish", depth: 2, unread: 0, kind: "folder", mailbox: "liste-sailfish" },
|
|
{ name: "progetti@example.net", depth: 0, unread: 2, kind: "account", mailbox: "" },
|
|
{ name: "In", depth: 1, unread: 2, kind: "in", mailbox: "p-in" },
|
|
{ name: "Out", depth: 1, unread: 0, kind: "out", mailbox: "p-out" },
|
|
{ name: "Trash", depth: 1, unread: 0, kind: "trash", mailbox: "p-trash" }
|
|
];
|
|
|
|
var MESSAGES = {
|
|
"in": [
|
|
{ sender: "Anna Rossi", address: "anna.rossi@example.com",
|
|
subject: "Cena di sabato",
|
|
date: "11/11 09:12", unread: true, junk: false, attachment: false,
|
|
body: "Ciao,\n\nsabato siamo in sei, pensavo alle otto. Porto io il dolce.\nSe ti serve una mano per il resto dimmi pure.\n\nA presto,\nAnna" },
|
|
{ sender: "Comune di Example", address: "protocollo@example.gov.it",
|
|
subject: "Avviso scadenza TARI 2026",
|
|
date: "11/11 07:40", unread: true, junk: false, attachment: true,
|
|
body: "Si informa che il termine per il versamento della seconda rata e' fissato al 16 dicembre 2026.\n\nIl modulo precompilato e' in allegato." },
|
|
{ sender: "Banca Example", address: "avvisi@example.bank",
|
|
subject: "Movimenti del mese di ottobre",
|
|
date: "10/11 18:03", unread: true, junk: false, attachment: true,
|
|
body: "Gentile cliente,\n\nl'estratto conto di ottobre e' disponibile nell'area riservata.\n\nNon rispondere a questo messaggio." },
|
|
{ sender: "Luca Bianchi", address: "luca@example.net",
|
|
subject: "Re: preventivo tettoia",
|
|
date: "10/11 14:22", unread: false, junk: false, attachment: false,
|
|
body: "Va bene, la misura da tre metri mi torna.\nPasso in settimana a vedere il posto, ti confermo il giorno." },
|
|
{ sender: "Newsletter Example", address: "news@example.org",
|
|
subject: "Le novita' di novembre",
|
|
date: "09/11 11:00", unread: false, junk: true, attachment: false,
|
|
body: "Scopri le offerte del mese. Se non vuoi piu' ricevere queste comunicazioni, disiscriviti qui." },
|
|
{ sender: "Giulia Verdi", address: "giulia@example.com",
|
|
subject: "Foto della gita",
|
|
date: "08/11 21:47", unread: false, junk: false, attachment: true,
|
|
body: "Ecco le foto, sono venute bene quelle sul molo.\n\nFammi sapere se le vuoi a piena risoluzione." },
|
|
{ sender: "Assistenza Example", address: "support@example.io",
|
|
subject: "Il tuo ticket #4412 e' stato chiuso",
|
|
date: "07/11 16:31", unread: false, junk: false, attachment: false,
|
|
body: "Il problema segnalato e' stato risolto. Se si ripresenta rispondi a questa email entro 14 giorni." },
|
|
{ sender: "Paolo Neri", address: "paolo.neri@example.org",
|
|
subject: "Prenotazione campo giovedi'",
|
|
date: "06/11 20:15", unread: true, junk: false, attachment: false,
|
|
body: "Ho prenotato per giovedi' alle 21. Siamo in quattro, se vuoi unirti c'e' posto." }
|
|
],
|
|
"junk": [
|
|
{ sender: "Vincite Facili", address: "promo@example.xyz",
|
|
subject: "HAI VINTO un buono spesa!",
|
|
date: "11/11 03:11", unread: true, junk: true, attachment: false,
|
|
body: "Clicca qui per riscattare il tuo premio entro 24 ore." },
|
|
{ sender: "Pharma Deal", address: "info@example.xyz",
|
|
subject: "Offerta riservata",
|
|
date: "10/11 04:02", unread: true, junk: true, attachment: false,
|
|
body: "Sconti fino all'80% solo per te." },
|
|
{ sender: "Crypto Daily", address: "news@example.xyz",
|
|
subject: "Il titolo che triplichera'",
|
|
date: "09/11 02:45", unread: true, junk: true, attachment: false,
|
|
body: "Non perdere questa occasione irripetibile." }
|
|
],
|
|
"out": [
|
|
{ sender: "Carlo", address: "carlo@example.org",
|
|
subject: "Re: Cena di sabato",
|
|
date: "10/11 19:30", unread: false, junk: false, attachment: false,
|
|
body: "Perfetto per le otto, ci sono.\nPorto il vino." },
|
|
{ sender: "Carlo", address: "carlo@example.org",
|
|
subject: "Documenti per la pratica",
|
|
date: "08/11 10:04", unread: false, junk: false, attachment: true,
|
|
body: "In allegato i documenti firmati.\n\nCarlo" }
|
|
],
|
|
"draft": [
|
|
{ sender: "Bozza", address: "",
|
|
subject: "Risposta al Comune",
|
|
date: "11/11 08:02", unread: true, junk: false, attachment: false,
|
|
body: "Buongiorno,\n\nin merito all'avviso ricevuto chiedo chiarimenti su..." },
|
|
{ sender: "Bozza", address: "",
|
|
subject: "Lista per la spesa",
|
|
date: "09/11 22:10", unread: true, junk: false, attachment: false,
|
|
body: "latte, pane, caffe', pastiglie" }
|
|
],
|
|
"trash": [],
|
|
"liste": [
|
|
{ sender: "Sailfish Community", address: "list@example.org",
|
|
subject: "[SFOS] Rilascio 5.1 e SDK",
|
|
date: "05/11 12:00", unread: false, junk: false, attachment: false,
|
|
body: "E' disponibile il nuovo rilascio con note e immagini." }
|
|
],
|
|
"liste-sailfish": [
|
|
{ sender: "Mailing list", address: "dev@example.org",
|
|
subject: "[Dev] QML e paginazione a tap",
|
|
date: "04/11 09:30", unread: false, junk: false, attachment: false,
|
|
body: "Qualcuno ha gia' provato il pattern del tap destro/sinistro?" }
|
|
],
|
|
"p-in": [
|
|
{ sender: "Maria Conte", address: "maria@example.net",
|
|
subject: "Bozza articolo per il blog",
|
|
date: "11/11 08:50", unread: true, junk: false, attachment: true,
|
|
body: "Ti mando la bozza, manca la parte finale sulle fonti.\n\nDimmi cosa ne pensi." },
|
|
{ sender: "Dario Sala", address: "dario@example.net",
|
|
subject: "Fattura 2026/114",
|
|
date: "10/11 15:10", unread: true, junk: false, attachment: true,
|
|
body: "In allegato la fattura del mese." }
|
|
],
|
|
"p-out": [],
|
|
"p-trash": []
|
|
};
|
|
|
|
// Non letti per cartella: serve alla lista cartelle e alla copertina.
|
|
function unreadOf(mailbox) {
|
|
var list = MESSAGES[mailbox] || [];
|
|
var n = 0;
|
|
for (var i = 0; i < list.length; i++) {
|
|
if (list[i].unread) n++;
|
|
}
|
|
return n;
|
|
}
|
|
|
|
function totalUnread() {
|
|
var n = 0;
|
|
for (var i = 0; i < MAILBOXES.length; i++) {
|
|
if (MAILBOXES[i].kind === "account") n += MAILBOXES[i].unread;
|
|
}
|
|
return n;
|
|
}
|
|
|
|
function messagesOf(mailbox) {
|
|
return MESSAGES[mailbox] || [];
|
|
}
|