diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..919ed2f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# 🧰 GAIA Swissknife – Changelog + +## v1.1.0 – 2025-04-09 +- Refactoring in funzioni modulari +- Ricostruzione celle curriculum estratta in funzione esterna +- Sidebar autorizzazioni: aggregazione e deduplicazione +- Modale "richieste iscrizione": input → select automatica + riepilogo corsi +- Correzione troncamento nomi file PDF nella prima riga +- Link changelog previsto, ma disattivato per coerenza multi-pagina + +## v1.0.0 – 2025-04-04 +- Versione stabile iniziale +- Trasformazione tabella curriculum in DataTable +- Evidenziazione "Respinto" +- Funzioni operative: ammissioni, apertura schede, messaggi... diff --git a/tampermonkey-script/GAIA-Swissknife.user.js b/tampermonkey-script/GAIA-Swissknife.user.js index 6fc8d4c..67d1999 100644 --- a/tampermonkey-script/GAIA-Swissknife.user.js +++ b/tampermonkey-script/GAIA-Swissknife.user.js @@ -3,8 +3,9 @@ // @namespace https://gitlab.luigidacunto.com/consultant/gaia-swissknife // @updateURL https://luigidacunto.com/scripts/gaia-swissknife/tampermonkey-script/GAIA-Swissknife.user.js // @downloadURL https://luigidacunto.com/scripts/gaia-swissknife/tampermonkey-script/GAIA-Swissknife.user.js +// @changelogURL https://luigidacunto.com/scripts/gaia-swissknife/tampermonkey-script/CHANGELOG.md // @author Luigi D'Acunto -// @version 1.0.0 +// @version 1.1.0 // @description Aggiunge funzionalità alle pagine di GAIA // @match https://gaia.cri.it/* // @require https://code.jquery.com/jquery-3.6.0.min.js @@ -30,6 +31,7 @@ GM_addStyle(GM_getResourceText("DataTablesCSS")); // Funzione per aggiungere il blocco di intestazione function ensureSwissknifeHeader() { + console.log("GAIA Swissknife: Aggiungo intestazione GAIA Swissknife..."); if ($('#sezione').length > 0 && $('#gaia-swissknife-header').length === 0) { const headerHTML = `
@@ -41,135 +43,183 @@ GM_addStyle(GM_getResourceText("DataTablesCSS")); } } - // Funzione per applicare le correzioni di stile alle celle del curriculum - function applyStyleFixes() { - const url = window.location.href; + // Funzione per correggere i filtri della sidebar delle autorizzazioni + function fixAutorizzazioniSidebarFilters() { + const $ul = $("#sezione-2"); + if (!$ul.length) return; - if (url.match(/\/profilo\/\d+\/curriculum\//)) { - console.log("GAIA Swissknife: Ricostruzione celle curriculum (versione pulita)..."); + const voci = {}; - $("td.piu-piccolo").each(function (cellIndex) { - const $td = $(this); - const rawNodes = Array.from(this.childNodes); + // Scansiona tutti i link + $ul.find("li[role='presentation'] a").each(function () { + const $a = $(this); + const text = $a.clone().children().remove().end().text().trim(); + const badge = parseInt($a.find(".badge").text().trim(), 10); + const href = $a.attr("href"); - // 🔍 Filtro nodi significativi: elimina tutti i nodi vuoti o whitespace - const nodes = rawNodes.filter(n => { - if (n.nodeType === 3) return n.nodeValue.trim() !== ""; - return true; // elementi HTML validi - }); + if (!text || isNaN(badge)) return; - console.log(`\n📦 [Cella ${cellIndex + 1}] Analizzo ${nodes.length} nodi validi...`); - const newContent = $('
'); + if (!voci[text]) { + voci[text] = { + count: 0, + href: href + }; + } - for (let i = 0; i < nodes.length; i++) { - const node = nodes[i]; + voci[text].count += badge; + }); - // Se è un'icona , cerca il contenuto associato - if (node.nodeType === 1 && node.tagName === "I") { - const $icon = $(node).clone(); - const $row = $('
').css({ - "display": "flex", - "align-items": "baseline", - "gap": "5px", - "line-height": "1.4", - "margin-bottom": "2px" - }); + $ul.find("li[role='presentation']").remove(); - $icon.css({ - "margin-right": "4px", - "vertical-align": "middle" - }); + Object.entries(voci).forEach(([tipo, info]) => { + const $li = $(` +
  • + + ${tipo} + ${info.count} + +
  • + `); + $ul.append($li); + }); + } + // Funzione per ricostruire le celle con i dettagli delle qualifiche nel curriculum in modo pulito + function rebuildCurriculumDetailCells() { + $("td.piu-piccolo").each(function (cellIndex) { + const $td = $(this); + const rawNodes = Array.from(this.childNodes); - $row.append($icon); + const nodes = rawNodes.filter(n => { + if (n.nodeType === 3) return n.nodeValue.trim() !== ""; + return true; + }); - // 🔄 Trova il prossimo nodo utile: testo o - let content = null; - let nextIndex = i + 1; + console.log(`\n📦 [Cella ${cellIndex + 1}] Analizzo ${nodes.length} nodi validi...`); + const newContent = $('
    '); - while (nextIndex < nodes.length) { - const nextNode = nodes[nextIndex]; + for (let i = 0; i < nodes.length; i++) { + const node = nodes[i]; - if (nextNode.nodeType === 3) { - const text = nextNode.nodeValue.trim(); - if (text) { - content = $('').text(text); - if (text.length > 40) { - content.css({ - "display": "inline-block", - "max-width": "200px", - "white-space": "nowrap", - "overflow": "hidden", - "text-overflow": "ellipsis", - "vertical-align": "middle" - }).attr("title", text); - } - break; - } - } else if (nextNode.nodeType === 1) { - const $el = $(nextNode); + if (node.nodeType === 1 && node.tagName === "I") { + const $icon = $(node).clone(); + const $row = $('
    ').css({ + "display": "flex", + "align-items": "baseline", + "gap": "5px", + "line-height": "1.4", + "margin-bottom": "2px" + }); - if (nextNode.tagName === "A") { - // Gestione
    (link) - let text = $el.text().trim(); + $icon.css({ + "margin-right": "4px", + "vertical-align": "middle" + }); - if (!text) { - const href = $el.attr("href") || ""; - const fallback = href.split("/").pop(); - text = fallback || "(documento)"; - $el.text(text); - } + $row.append($icon); - $el.css({ + let content = null; + let nextIndex = i + 1; + + while (nextIndex < nodes.length) { + const nextNode = nodes[nextIndex]; + + if (nextNode.nodeType === 3) { + const text = nextNode.nodeValue.trim(); + if (text) { + content = $('').text(text); + if (text.length > 40) { + content.css({ "display": "inline-block", "max-width": "200px", "white-space": "nowrap", "overflow": "hidden", "text-overflow": "ellipsis", - "vertical-align": "middle", - "color": "#a94442" + "vertical-align": "middle" }).attr("title", text); + } + break; + } + } else if (nextNode.nodeType === 1) { + const $el = $(nextNode); - content = $el; - break; + if (nextNode.tagName === "A") { + let text = $el.text().trim(); + + if (!text) { + const href = $el.attr("href") || ""; + const fallback = href.split("/").pop(); + text = fallback || "(documento)"; + $el.text(text); } - // ✅ Gestione (es. .monospace o altro) - else if (nextNode.tagName === "SPAN") { - const text = $el.text().trim(); - if (text) { - content = $el.clone(); + $el.css({ + "display": "inline-block", + "max-width": "200px", + "white-space": "nowrap", + "overflow": "hidden", + "text-overflow": "ellipsis", + "vertical-align": "middle", + "color": "#a94442" + }).attr("title", text); - content.css({ - "display": "inline-block", - "max-width": "200px", - "white-space": "nowrap", - "overflow": "hidden", - "text-overflow": "ellipsis", - "vertical-align": "middle" - }).attr("title", text); - break; - } - } + content = $el; + break; } - nextIndex++; + else if (nextNode.tagName === "SPAN") { + const text = $el.text().trim(); + if (text) { + content = $el.clone(); + + content.css({ + "display": "inline-block", + "max-width": "200px", + "white-space": "nowrap", + "overflow": "hidden", + "text-overflow": "ellipsis", + "vertical-align": "middle" + }).attr("title", text); + break; + } + } } - i = nextIndex - 1; // Salta i nodi già processati + nextIndex++; + } - if (content) { - $row.append(content); - newContent.append($row); - console.log(`✅ Riga generata: ${$icon.attr("class")} + contenuto`); - } else { - console.warn(`⚠️ Riga ignorata: icona "${$icon.attr("class")}" senza contenuto`); - } + i = nextIndex - 1; + + if (content) { + $row.append(content); + newContent.append($row); + console.log(`✅ Riga generata: ${$icon.attr("class")} + contenuto`); + } else { + console.warn(`⚠️ Riga ignorata: icona "${$icon.attr("class")}" senza contenuto`); } } + } - $td.empty().append(newContent); - }); + $td.empty().append(newContent); + }); + } + + + // Funzione per applicare le correzioni di stile alle celle del curriculum + function applyStyleFixes() { + const url = window.location.href; + + // Correzione per le celle del curriculum + if (url.match(/\/profilo\/\d+\/curriculum\//)) { + console.log("GAIA Swissknife: Ricostruzione celle curriculum in modo ordinato..."); + rebuildCurriculumDetailCells(); } + + // Correzione per menu laterale autorizzazioni + if (url.includes("/autorizzazioni")) { + console.log("GAIA Swissknife: Correzione menu laterale autorizzazioni..."); + fixAutorizzazioniSidebarFilters(); + } + } // Funzione per aggiungere i pulsanti per settare gli esiti degli esami @@ -393,6 +443,14 @@ GM_addStyle(GM_getResourceText("DataTablesCSS"));
    +
    + 📋 Richieste trovate:
    + ${corsiUnici.map(c => { + const count = richieste.filter(r => r.codice === c).length; + const plural = count === 1 ? "richiesta" : "richieste"; + return `• ${c} – ${count} ${plural}`; + }).join("
    ")} +