Aggiungi nuove funzionalità e miglioramenti al GAIA Swissknife
This commit is contained in:
parent
5c03e3af71
commit
749080549e
1 changed files with 543 additions and 347 deletions
|
|
@ -7,375 +7,571 @@
|
||||||
// @version 0.4.4-beta
|
// @version 0.4.4-beta
|
||||||
// @description Aggiunge funzionalità alle pagine di GAIA
|
// @description Aggiunge funzionalità alle pagine di GAIA
|
||||||
// @match https://gaia.cri.it/*
|
// @match https://gaia.cri.it/*
|
||||||
// @grant none
|
// @require https://code.jquery.com/jquery-3.6.0.min.js
|
||||||
|
// @require https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js
|
||||||
|
// @resource DataTablesCSS https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css
|
||||||
|
// @grant GM_addStyle
|
||||||
|
// @grant GM_getResourceText
|
||||||
// @run-at document-idle
|
// @run-at document-idle
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
(function() {
|
GM_addStyle(GM_getResourceText("DataTablesCSS"));
|
||||||
|
|
||||||
|
(function($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
console.log("GAIA Swissknife: Inizializzazione in corso!");
|
||||||
|
|
||||||
// Recupera la versione dallo script se disponibile, altrimenti usa un valore di fallback
|
// Recupera la versione dallo script se disponibile, altrimenti usa un valore di fallback
|
||||||
const currentVersion = (typeof GM_info !== 'undefined' && GM_info.script && GM_info.script.version) ? GM_info.script.version : 'x.x';
|
const currentVersion = (typeof GM_info !== 'undefined' && GM_info.script && GM_info.script.version) ? GM_info.script.version : 'x.x';
|
||||||
|
|
||||||
// Controlla se jQuery è caricato, altrimenti lo carica
|
function applyStyleFixes() {
|
||||||
function ensureJQuery(callback) {
|
const url = window.location.href;
|
||||||
if (window.jQuery) {
|
|
||||||
callback(window.jQuery);
|
if (url.match(/\/profilo\/\d+\/curriculum\//)) {
|
||||||
} else {
|
console.log("GAIA Swissknife: Ricostruzione celle curriculum (versione pulita)...");
|
||||||
let script = document.createElement('script');
|
|
||||||
script.src = 'https://code.jquery.com/jquery-3.6.0.min.js';
|
$("td.piu-piccolo").each(function (cellIndex) {
|
||||||
script.onload = () => callback(window.jQuery);
|
const $td = $(this);
|
||||||
document.head.appendChild(script);
|
const rawNodes = Array.from(this.childNodes);
|
||||||
|
|
||||||
|
// 🔍 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
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(`\n📦 [Cella ${cellIndex + 1}] Analizzo ${nodes.length} nodi validi...`);
|
||||||
|
const newContent = $('<div></div>');
|
||||||
|
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
const node = nodes[i];
|
||||||
|
|
||||||
|
// Se è un'icona <i>, cerca il contenuto associato
|
||||||
|
if (node.nodeType === 1 && node.tagName === "I") {
|
||||||
|
const $icon = $(node).clone();
|
||||||
|
const $row = $('<div class="gaia-line"></div>').css({
|
||||||
|
"display": "flex",
|
||||||
|
"align-items": "baseline",
|
||||||
|
"gap": "5px",
|
||||||
|
"line-height": "1.4",
|
||||||
|
"margin-bottom": "2px"
|
||||||
|
});
|
||||||
|
|
||||||
|
$icon.css({
|
||||||
|
"margin-right": "4px",
|
||||||
|
"vertical-align": "middle"
|
||||||
|
});
|
||||||
|
|
||||||
|
$row.append($icon);
|
||||||
|
|
||||||
|
// 🔄 Trova il prossimo nodo utile: testo o <a>
|
||||||
|
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 = $('<span></span>').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 (nextNode.tagName === "A") {
|
||||||
|
// Gestione <a> (link)
|
||||||
|
let text = $el.text().trim();
|
||||||
|
|
||||||
|
if (!text) {
|
||||||
|
const href = $el.attr("href") || "";
|
||||||
|
const fallback = href.split("/").pop();
|
||||||
|
text = fallback || "(documento)";
|
||||||
|
$el.text(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
$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 = $el;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Gestione <span> (es. .monospace o altro)
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nextIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = nextIndex - 1; // Salta i nodi già processati
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureJQuery(($) => {
|
// Funzione per aggiungere il blocco di intestazione
|
||||||
console.log("GAIA Swissknife: jQuery caricato con successo!");
|
function ensureSwissknifeHeader() {
|
||||||
|
if ($('#sezione').length > 0 && $('#gaia-swissknife-header').length === 0) {
|
||||||
|
const headerHTML = `
|
||||||
|
<hr>
|
||||||
|
<li id="gaia-swissknife-header" class="dropdown-header grassetto piu-grande">
|
||||||
|
GAIA Swissknife v${currentVersion}
|
||||||
|
</li>
|
||||||
|
`;
|
||||||
|
$('#sezione').append(headerHTML);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function initScript() {
|
// Funzione per aggiungere i pulsanti per settare gli esiti degli esami
|
||||||
|
function addExamOutcomeButtons() {
|
||||||
|
console.log("GAIA Swissknife: esecuzione di addExamOutcomeButtons() ...");
|
||||||
|
// Verifica che ci siano i select che gestiscono gli esiti
|
||||||
|
if ($("select[id^='id_part_'][id$='-ammissione']").length > 0) {
|
||||||
|
// Cerca il menu laterale (ul#sezione) dove inserire il blocco
|
||||||
|
if ($('#sezione').length > 0) {
|
||||||
|
console.log("GAIA Swissknife: Elementi trovati, aggiungo i pulsanti nel menu laterale...");
|
||||||
|
|
||||||
// Funzione per aggiungere il blocco di intestazione
|
ensureSwissknifeHeader();
|
||||||
function ensureSwissknifeHeader() {
|
// Aggiungi i pulsanti per settare gli esiti
|
||||||
if ($('#sezione').length > 0 && $('#gaia-swissknife-header').length === 0) {
|
const buttonsHTML = `
|
||||||
const headerHTML = `
|
<li role="presentation">
|
||||||
<hr>
|
<button id="button_set_ampp" style="margin: 5px; padding: 8px; width: 97%; background-color: #007BFF; color: #FFF; border: none; border-radius: 4px; cursor: pointer;">
|
||||||
<li id="gaia-swissknife-header" class="dropdown-header grassetto piu-grande">
|
Ammessi, Positivo, Positivo
|
||||||
GAIA Swissknife v${currentVersion}
|
</button>
|
||||||
</li>
|
</li>
|
||||||
`;
|
<li role="presentation">
|
||||||
$('#sezione').append(headerHTML);
|
<button id="button_set_ampo" style="margin: 5px; padding: 8px; width: 97%; background-color: #28a745; color: #FFF; border: none; border-radius: 4px; cursor: pointer;">
|
||||||
}
|
Ammessi, Positivo, Non previsto
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li role="presentation">
|
||||||
|
<button id="button_set_amop" style="margin: 5px; padding: 8px; width: 97%; background-color:rgb(167, 40, 99); color: #FFF; border: none; border-radius: 4px; cursor: pointer;">
|
||||||
|
Ammessi, Non previsto, Positivo
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
`;
|
||||||
|
$('#sezione').append(buttonsHTML);
|
||||||
|
|
||||||
|
// Evento per il pulsante "Tutti Ammessi/Esito Positivo x2"
|
||||||
|
$('#button_set_ampp').click(() => {
|
||||||
|
$("select[id^='id_part_'][id$='-ammissione']").val("AM").trigger('change');
|
||||||
|
$("select[id^='id_part_'][id$='-esito_parte_1']").val("P").trigger('change');
|
||||||
|
$("select[id^='id_part_'][id$='-esito_parte_2']").val("P").trigger('change');
|
||||||
|
console.log("GAIA Swissknife: Valori impostati - Ammessi, Positivo, Positivo");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Evento per il pulsante "Ammessi, Positivo, Non previsto"
|
||||||
|
$('#button_set_ampo').click(() => {
|
||||||
|
$("select[id^='id_part_'][id$='-ammissione']").val("AM").trigger('change');
|
||||||
|
$("select[id^='id_part_'][id$='-esito_parte_1']").val("P").trigger('change');
|
||||||
|
$("select[id^='id_part_'][id$='-esito_parte_2']").val("O").trigger('change');
|
||||||
|
console.log("GAIA Swissknife: Valori impostati - Ammessi, Positivo, Non previsto");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Evento per il pulsante "Ammessi, Non previsto, Positivo"
|
||||||
|
$('#button_set_amop').click(() => {
|
||||||
|
$("select[id^='id_part_'][id$='-ammissione']").val("AM").trigger('change');
|
||||||
|
$("select[id^='id_part_'][id$='-esito_parte_1']").val("O").trigger('change');
|
||||||
|
$("select[id^='id_part_'][id$='-esito_parte_2']").val("P").trigger('change');
|
||||||
|
console.log("GAIA Swissknife: Valori impostati - Ammessi, Non previsto, Positivo");
|
||||||
|
});
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log("GAIA Swissknife: Elemento ul#sezione non trovato.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log("GAIA Swissknife: Nessun elemento trovato, i pulsanti non verranno mostrati.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Funzione per aggiungere il pulsante "Apri tutti i Curriculum"
|
||||||
|
function addOpenAllProfilesButton() {
|
||||||
|
if (!window.location.href.includes('/iscritti/')) return;
|
||||||
|
|
||||||
|
const openButton = $(`
|
||||||
|
<button id="open_all_profiles" style="margin: 5px; padding: 8px; width: 97%; background-color:rgba(234, 0, 255, 0.65); color: #FFF; border: none; border-radius: 4px; cursor: pointer;">
|
||||||
|
Apri tutti i Curriculum
|
||||||
|
</button>
|
||||||
|
`);
|
||||||
|
|
||||||
|
openButton.on('click', () => {
|
||||||
|
const iframe = document.querySelector('iframe.embed-responsive-item');
|
||||||
|
if (!iframe) {
|
||||||
|
alert("Impossibile trovare l'iframe con la lista.");
|
||||||
|
console.log("GAIA Swissknife: iframe non trovato.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Funzione per aggiungere i pulsanti per settare gli esiti degli esami
|
// Verifica che il contenuto sia accessibile (same-origin)
|
||||||
function addExamOutcomeButtons() {
|
let iframeDoc;
|
||||||
console.log("GAIA Swissknife: esecuzione di addExamOutcomeButtons() ...");
|
try {
|
||||||
// Verifica che ci siano i select che gestiscono gli esiti
|
iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
|
||||||
if ($("select[id^='id_part_'][id$='-ammissione']").length > 0) {
|
} catch (err) {
|
||||||
// Cerca il menu laterale (ul#sezione) dove inserire il blocco
|
alert("Accesso all'iframe bloccato per motivi di sicurezza (cross-origin).");
|
||||||
if ($('#sezione').length > 0) {
|
console.error("GAIA Swissknife: accesso iframe negato.", err);
|
||||||
console.log("GAIA Swissknife: Elementi trovati, aggiungo i pulsanti nel menu laterale...");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ensureSwissknifeHeader();
|
const $iframeLinks = $(iframeDoc).find("a[href^='/profilo/'][href*='?fpc']");
|
||||||
// Aggiungi i pulsanti per settare gli esiti
|
if ($iframeLinks.length === 0) {
|
||||||
const buttonsHTML = `
|
alert("Nessun profilo trovato all'interno dell'iframe.");
|
||||||
<li role="presentation">
|
console.log("GAIA Swissknife: Nessun link profilo nell'iframe.");
|
||||||
<button id="button_set_ampp" style="margin: 5px; padding: 8px; width: 97%; background-color: #007BFF; color: #FFF; border: none; border-radius: 4px; cursor: pointer;">
|
return;
|
||||||
Ammessi, Positivo, Positivo
|
}
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li role="presentation">
|
|
||||||
<button id="button_set_ampo" style="margin: 5px; padding: 8px; width: 97%; background-color: #28a745; color: #FFF; border: none; border-radius: 4px; cursor: pointer;">
|
|
||||||
Ammessi, Positivo, Non previsto
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li role="presentation">
|
|
||||||
<button id="button_set_amop" style="margin: 5px; padding: 8px; width: 97%; background-color:rgb(167, 40, 99); color: #FFF; border: none; border-radius: 4px; cursor: pointer;">
|
|
||||||
Ammessi, Non previsto, Positivo
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
`;
|
|
||||||
$('#sezione').append(buttonsHTML);
|
|
||||||
|
|
||||||
// Evento per il pulsante "Tutti Ammessi/Esito Positivo x2"
|
const profileLinks = $iframeLinks.map(function() {
|
||||||
$('#button_set_ampp').click(() => {
|
const href = $(this).attr('href');
|
||||||
$("select[id^='id_part_'][id$='-ammissione']").val("AM").trigger('change');
|
const match = href.match(/\/profilo\/(\d+)\//);
|
||||||
$("select[id^='id_part_'][id$='-esito_parte_1']").val("P").trigger('change');
|
if (match && match[1]) {
|
||||||
$("select[id^='id_part_'][id$='-esito_parte_2']").val("P").trigger('change');
|
const id = match[1];
|
||||||
console.log("GAIA Swissknife: Valori impostati - Ammessi, Positivo, Positivo");
|
return `https://gaia.cri.it/profilo/${id}/curriculum/?us`;
|
||||||
});
|
}
|
||||||
|
return null;
|
||||||
|
}).get().filter(Boolean);
|
||||||
|
|
||||||
// Evento per il pulsante "Ammessi, Positivo, Non previsto"
|
// Mostra le URL in console sempre
|
||||||
$('#button_set_ampo').click(() => {
|
console.log("GAIA Swissknife: Profili trovati:");
|
||||||
$("select[id^='id_part_'][id$='-ammissione']").val("AM").trigger('change');
|
profileLinks.forEach(link => console.log(link));
|
||||||
$("select[id^='id_part_'][id$='-esito_parte_1']").val("P").trigger('change');
|
|
||||||
$("select[id^='id_part_'][id$='-esito_parte_2']").val("O").trigger('change');
|
|
||||||
console.log("GAIA Swissknife: Valori impostati - Ammessi, Positivo, Non previsto");
|
|
||||||
});
|
|
||||||
|
|
||||||
// Evento per il pulsante "Ammessi, Non previsto, Positivo"
|
if (!confirm(`Vuoi aprire ${profileLinks.length} profili in nuove schede?`)) return;
|
||||||
$('#button_set_amop').click(() => {
|
|
||||||
$("select[id^='id_part_'][id$='-ammissione']").val("AM").trigger('change');
|
|
||||||
$("select[id^='id_part_'][id$='-esito_parte_1']").val("O").trigger('change');
|
|
||||||
$("select[id^='id_part_'][id$='-esito_parte_2']").val("P").trigger('change');
|
|
||||||
console.log("GAIA Swissknife: Valori impostati - Ammessi, Non previsto, Positivo");
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
profileLinks.forEach(link => {
|
||||||
console.log("GAIA Swissknife: Elemento ul#sezione non trovato.");
|
window.open(link, '_blank');
|
||||||
}
|
});
|
||||||
|
|
||||||
|
console.log(`GAIA Swissknife: Aperte ${profileLinks.length} schede da iframe.`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Inserimento del pulsante nel menu laterale o in floating
|
||||||
|
if ($('#sezione').length > 0) {
|
||||||
|
ensureSwissknifeHeader();
|
||||||
|
|
||||||
|
$('#sezione').append(
|
||||||
|
$('<li role="presentation"></li>').append(openButton)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
openButton.css({
|
||||||
|
position: 'fixed',
|
||||||
|
top: '10px',
|
||||||
|
right: '10px',
|
||||||
|
zIndex: 9999
|
||||||
|
}).appendTo('body');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Funzione per evidenziare le righe con "Respinto" NON STA FUNZIONANDO
|
||||||
|
function highlightRejectedCourses() {
|
||||||
|
if (!window.location.href.match(/\/profilo\/\d+\/curriculum\//)) return;
|
||||||
|
|
||||||
|
console.log(`GAIA Swissknife: Qualifiche Rifiutate, rilevazione avviata..`);
|
||||||
|
|
||||||
|
const $table = $(".table.table-striped");
|
||||||
|
if (!$table.length || !$.fn.DataTable.isDataTable($table)) return;
|
||||||
|
|
||||||
|
const api = $table.DataTable();
|
||||||
|
|
||||||
|
function applyRejectionStyle() {
|
||||||
|
api.rows({ search: "applied" }).every(function (rowIdx, tableLoop, rowLoop) {
|
||||||
|
const $row = $(this.node());
|
||||||
|
const hasRespinto = $row.text().includes("Respinto");
|
||||||
|
|
||||||
|
if (hasRespinto) {
|
||||||
|
const nomeCorso = $row.find("p.grassetto").text().trim() || "Corso non trovato";
|
||||||
|
console.log(`🟥 Respinto trovato nella riga ${rowIdx + 1}: ${nomeCorso}`);
|
||||||
|
|
||||||
|
$row.css({
|
||||||
|
"box-shadow": "inset 8px 0 0 0 #dc3545",
|
||||||
|
"background-color": "#fbe9ea"
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log("GAIA Swissknife: Nessun elemento trovato, i pulsanti non verranno mostrati.");
|
$row.css({
|
||||||
|
"box-shadow": "",
|
||||||
|
"background-color": ""
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Funzione per aggiungere il pulsante "Apri tutti i Curriculum"
|
|
||||||
function addOpenAllProfilesButton() {
|
|
||||||
if (!window.location.href.includes('/iscritti/')) return;
|
|
||||||
|
|
||||||
const openButton = $(`
|
|
||||||
<button id="open_all_profiles" style="margin: 5px; padding: 8px; width: 97%; background-color:rgba(234, 0, 255, 0.65); color: #FFF; border: none; border-radius: 4px; cursor: pointer;">
|
|
||||||
Apri tutti i Curriculum
|
|
||||||
</button>
|
|
||||||
`);
|
|
||||||
|
|
||||||
openButton.on('click', () => {
|
|
||||||
const iframe = document.querySelector('iframe.embed-responsive-item');
|
|
||||||
if (!iframe) {
|
|
||||||
alert("Impossibile trovare l'iframe con la lista.");
|
|
||||||
console.log("GAIA Swissknife: iframe non trovato.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verifica che il contenuto sia accessibile (same-origin)
|
|
||||||
let iframeDoc;
|
|
||||||
try {
|
|
||||||
iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
|
|
||||||
} catch (err) {
|
|
||||||
alert("Accesso all'iframe bloccato per motivi di sicurezza (cross-origin).");
|
|
||||||
console.error("GAIA Swissknife: accesso iframe negato.", err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const $iframeLinks = $(iframeDoc).find("a[href^='/profilo/'][href*='?fpc']");
|
|
||||||
if ($iframeLinks.length === 0) {
|
|
||||||
alert("Nessun profilo trovato all'interno dell'iframe.");
|
|
||||||
console.log("GAIA Swissknife: Nessun link profilo nell'iframe.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const profileLinks = $iframeLinks.map(function() {
|
|
||||||
const href = $(this).attr('href');
|
|
||||||
const match = href.match(/\/profilo\/(\d+)\//);
|
|
||||||
if (match && match[1]) {
|
|
||||||
const id = match[1];
|
|
||||||
return `https://gaia.cri.it/profilo/${id}/curriculum/?us`;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}).get().filter(Boolean);
|
|
||||||
|
|
||||||
// Mostra le URL in console sempre
|
|
||||||
console.log("GAIA Swissknife: Profili trovati:");
|
|
||||||
profileLinks.forEach(link => console.log(link));
|
|
||||||
|
|
||||||
if (!confirm(`Vuoi aprire ${profileLinks.length} profili in nuove schede?`)) return;
|
|
||||||
|
|
||||||
profileLinks.forEach(link => {
|
|
||||||
window.open(link, '_blank');
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(`GAIA Swissknife: Aperte ${profileLinks.length} schede da iframe.`);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Inserimento del pulsante nel menu laterale o in floating
|
|
||||||
if ($('#sezione').length > 0) {
|
|
||||||
ensureSwissknifeHeader();
|
|
||||||
|
|
||||||
$('#sezione').append(
|
|
||||||
$('<li role="presentation"></li>').append(openButton)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
openButton.css({
|
|
||||||
position: 'fixed',
|
|
||||||
top: '10px',
|
|
||||||
right: '10px',
|
|
||||||
zIndex: 9999
|
|
||||||
}).appendTo('body');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Funzione per evidenziare le righe con "Respinto"
|
|
||||||
function highlightRejectedCourses() {
|
|
||||||
if (!window.location.href.match(/\/profilo\/\d+\/curriculum\//)) return;
|
|
||||||
|
|
||||||
console.log("GAIA Swissknife: Cerco righe con 'Respinto'...");
|
|
||||||
|
|
||||||
$("tr").each(function() {
|
|
||||||
const row = $(this);
|
|
||||||
if (row.text().trim().includes("Respinto")) {
|
|
||||||
row.css("background-color", "#f8d7da");
|
|
||||||
row.css("border-left", "4px solid #dc3545"); // opzionale: bordo rosso
|
|
||||||
console.log("GAIA Swissknife: Riga evidenziata ->", row.text().trim().substring(0, 100));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Funzione per aggiungere il tool per i profili delle richieste iscrizioni
|
|
||||||
function addAuthorizationProfileTool() {
|
|
||||||
if (!window.location.href.includes("/autorizzazioni/")) return;
|
|
||||||
|
|
||||||
// Crea la finestra modale
|
|
||||||
const $modal = $(`
|
|
||||||
<div id="gaia-auth-tool" style="
|
|
||||||
position: fixed;
|
|
||||||
top: 20px;
|
|
||||||
right: 20px;
|
|
||||||
width: 320px;
|
|
||||||
background: white;
|
|
||||||
border: 2px solid #007BFF;
|
|
||||||
border-radius: 8px;
|
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
|
||||||
z-index: 9999;
|
|
||||||
overflow: hidden;
|
|
||||||
">
|
|
||||||
<div id="gaia-auth-header" style="
|
|
||||||
background-color: #007BFF;
|
|
||||||
color: white;
|
|
||||||
padding: 8px 10px;
|
|
||||||
font-weight: bold;
|
|
||||||
cursor: move;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
">
|
|
||||||
<span>🛠 GAIA Swissknife – Curriculum</span>
|
|
||||||
<button id="gaia-auth-toggle" title="Riduci/Espandi" style="
|
|
||||||
background: transparent;
|
|
||||||
border: none;
|
|
||||||
color: white;
|
|
||||||
font-weight: bold;
|
|
||||||
font-size: 16px;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 0;
|
|
||||||
margin-left: 10px;
|
|
||||||
">−</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="gaia-auth-body" style="padding: 15px;">
|
|
||||||
<input type="text" id="gaia-auth-query" placeholder="Codice corso es. TOS/2025/..." style="width: 100%; padding: 5px; margin-bottom: 10px; border-radius: 4px; border: 1px solid #ccc;">
|
|
||||||
<button id="gaia-auth-btn" style="width: 100%; padding: 8px; background-color: #007BFF; color: white; border: none; border-radius: 4px; cursor: pointer;">Recupera Profili</button>
|
|
||||||
<div id="gaia-auth-openall-container" style="display: none; margin-top: 10px;">
|
|
||||||
<button id="gaia-auth-openall" style="width: 100%; padding: 6px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">
|
|
||||||
Apri tutti i Curriculum
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div id="gaia-auth-results" style="margin-top: 10px; max-height: 200px; overflow-y: auto; border-top: 1px solid #ddd; padding-top: 10px;"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
|
|
||||||
|
|
||||||
$('body').append($modal);
|
|
||||||
|
|
||||||
let isCollapsed = false;
|
|
||||||
|
|
||||||
$('#gaia-auth-toggle').on('click', function (e) {
|
|
||||||
isCollapsed = !isCollapsed;
|
|
||||||
$('#gaia-auth-body').slideToggle(200);
|
|
||||||
$(this).text(isCollapsed ? '+' : '−'); // Cambia icona da - a +
|
|
||||||
e.stopPropagation(); // Previene conflitti con il drag
|
|
||||||
});
|
|
||||||
|
|
||||||
// Trascinabilità
|
|
||||||
let isDragging = false;
|
|
||||||
let dragOffsetX = 0, dragOffsetY = 0;
|
|
||||||
|
|
||||||
$('#gaia-auth-header')
|
|
||||||
.on('mousedown', function (e) {
|
|
||||||
const modal = document.getElementById('gaia-auth-tool');
|
|
||||||
const rect = modal.getBoundingClientRect();
|
|
||||||
|
|
||||||
isDragging = true;
|
|
||||||
dragOffsetX = e.clientX - rect.left;
|
|
||||||
dragOffsetY = e.clientY - rect.top;
|
|
||||||
|
|
||||||
e.preventDefault(); // previene selezione testo
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document)
|
|
||||||
.on('mousemove', function (e) {
|
|
||||||
if (!isDragging) return;
|
|
||||||
|
|
||||||
const winW = window.innerWidth;
|
|
||||||
const winH = window.innerHeight;
|
|
||||||
const $modal = $('#gaia-auth-tool');
|
|
||||||
|
|
||||||
let newLeft = e.clientX - dragOffsetX;
|
|
||||||
let newTop = e.clientY - dragOffsetY;
|
|
||||||
|
|
||||||
// Limiti per evitare di trascinare fuori
|
|
||||||
newLeft = Math.max(0, Math.min(newLeft, winW - $modal.outerWidth()));
|
|
||||||
newTop = Math.max(0, Math.min(newTop, winH - $modal.outerHeight()));
|
|
||||||
|
|
||||||
$modal.css({ left: newLeft + 'px', top: newTop + 'px', right: 'auto' });
|
|
||||||
})
|
|
||||||
.on('mouseup', function () {
|
|
||||||
isDragging = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#gaia-auth-btn').on('click', function () {
|
|
||||||
const query = $('#gaia-auth-query').val().trim().toLowerCase();
|
|
||||||
const $results = $('#gaia-auth-results');
|
|
||||||
$results.empty(); // Pulisce la lista ogni volta
|
|
||||||
$('#gaia-auth-openall-container').hide(); // Nasconde il pulsante "Apri tutti i Curriculum"
|
|
||||||
|
|
||||||
let collectedLinks = []; // memorizza i link trovati
|
|
||||||
|
|
||||||
if (!query) {
|
|
||||||
alert("Inserisci un codice corso per cercare.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ripulisce eventuali evidenziazioni precedenti
|
|
||||||
$(".panel.panel-default").css("background-color", "");
|
|
||||||
|
|
||||||
let found = 0;
|
|
||||||
|
|
||||||
$(".panel.panel-default").each(function () {
|
|
||||||
const $panel = $(this);
|
|
||||||
const text = $panel.text().toLowerCase();
|
|
||||||
|
|
||||||
if (text.includes(query)) {
|
|
||||||
found++;
|
|
||||||
|
|
||||||
// Evidenzia
|
|
||||||
$panel.css("background-color", "#d4edda");
|
|
||||||
|
|
||||||
// Cerca il link al profilo
|
|
||||||
const $profileLink = $panel.find("a[href^='/profilo/']").first();
|
|
||||||
if ($profileLink.length > 0) {
|
|
||||||
const href = $profileLink.attr('href'); // es. /profilo/220378/
|
|
||||||
const match = href.match(/\/profilo\/(\d+)\//);
|
|
||||||
const nome = $profileLink.text().trim();
|
|
||||||
|
|
||||||
if (match && match[1]) {
|
|
||||||
const id = match[1];
|
|
||||||
const fullLink = `https://gaia.cri.it/profilo/${id}/curriculum/?us`;
|
|
||||||
|
|
||||||
collectedLinks.push(fullLink);
|
|
||||||
|
|
||||||
const $entry = $(`
|
|
||||||
<div style="margin-bottom: 5px;">
|
|
||||||
<a href="${fullLink}" target="_blank">${nome}</a>
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
$results.append($entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (collectedLinks.length > 0) {
|
|
||||||
$('#gaia-auth-openall-container').show();
|
|
||||||
$('#gaia-auth-openall').off('click').on('click', () => {
|
|
||||||
collectedLinks.forEach(link => window.open(link, '_blank'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found === 0) {
|
|
||||||
$results.append(`<div style="color: red;">Nessun risultato trovato.</div>`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(() => {
|
|
||||||
addExamOutcomeButtons();
|
|
||||||
addOpenAllProfilesButton();
|
|
||||||
highlightRejectedCourses();
|
|
||||||
addAuthorizationProfileTool();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initScript();
|
applyRejectionStyle();
|
||||||
|
$table.on("draw.dt", applyRejectionStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Funzione per aggiungere il tool per i profili delle richieste iscrizioni
|
||||||
|
function addAuthorizationProfileTool() {
|
||||||
|
if (!window.location.href.includes("/autorizzazioni/")) return;
|
||||||
|
|
||||||
|
// Crea la finestra modale
|
||||||
|
const $modal = $(`
|
||||||
|
<div id="gaia-auth-tool" style="
|
||||||
|
position: fixed;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
width: 320px;
|
||||||
|
background: white;
|
||||||
|
border: 2px solid #007BFF;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
||||||
|
z-index: 9999;
|
||||||
|
overflow: hidden;
|
||||||
|
">
|
||||||
|
<div id="gaia-auth-header" style="
|
||||||
|
background-color: #007BFF;
|
||||||
|
color: white;
|
||||||
|
padding: 8px 10px;
|
||||||
|
font-weight: bold;
|
||||||
|
cursor: move;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
">
|
||||||
|
<span>🛠 GAIA Swissknife – Curriculum</span>
|
||||||
|
<button id="gaia-auth-toggle" title="Riduci/Espandi" style="
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 16px;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 0;
|
||||||
|
margin-left: 10px;
|
||||||
|
">−</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="gaia-auth-body" style="padding: 15px;">
|
||||||
|
<input type="text" id="gaia-auth-query" placeholder="Codice corso es. TOS/2025/..." style="width: 100%; padding: 5px; margin-bottom: 10px; border-radius: 4px; border: 1px solid #ccc;">
|
||||||
|
<button id="gaia-auth-btn" style="width: 100%; padding: 8px; background-color: #007BFF; color: white; border: none; border-radius: 4px; cursor: pointer;">Recupera Profili</button>
|
||||||
|
<div id="gaia-auth-openall-container" style="display: none; margin-top: 10px;">
|
||||||
|
<button id="gaia-auth-openall" style="width: 100%; padding: 6px; background-color: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">
|
||||||
|
Apri tutti i Curriculum
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div id="gaia-auth-results" style="margin-top: 10px; max-height: 200px; overflow-y: auto; border-top: 1px solid #ddd; padding-top: 10px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
|
||||||
|
|
||||||
|
$('body').append($modal);
|
||||||
|
|
||||||
|
let isCollapsed = false;
|
||||||
|
|
||||||
|
$('#gaia-auth-toggle').on('click', function (e) {
|
||||||
|
isCollapsed = !isCollapsed;
|
||||||
|
$('#gaia-auth-body').slideToggle(200);
|
||||||
|
$(this).text(isCollapsed ? '+' : '−'); // Cambia icona da - a +
|
||||||
|
e.stopPropagation(); // Previene conflitti con il drag
|
||||||
|
});
|
||||||
|
|
||||||
|
// Trascinabilità
|
||||||
|
let isDragging = false;
|
||||||
|
let dragOffsetX = 0, dragOffsetY = 0;
|
||||||
|
|
||||||
|
$('#gaia-auth-header')
|
||||||
|
.on('mousedown', function (e) {
|
||||||
|
const modal = document.getElementById('gaia-auth-tool');
|
||||||
|
const rect = modal.getBoundingClientRect();
|
||||||
|
|
||||||
|
isDragging = true;
|
||||||
|
dragOffsetX = e.clientX - rect.left;
|
||||||
|
dragOffsetY = e.clientY - rect.top;
|
||||||
|
|
||||||
|
e.preventDefault(); // previene selezione testo
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document)
|
||||||
|
.on('mousemove', function (e) {
|
||||||
|
if (!isDragging) return;
|
||||||
|
|
||||||
|
const winW = window.innerWidth;
|
||||||
|
const winH = window.innerHeight;
|
||||||
|
const $modal = $('#gaia-auth-tool');
|
||||||
|
|
||||||
|
let newLeft = e.clientX - dragOffsetX;
|
||||||
|
let newTop = e.clientY - dragOffsetY;
|
||||||
|
|
||||||
|
// Limiti per evitare di trascinare fuori
|
||||||
|
newLeft = Math.max(0, Math.min(newLeft, winW - $modal.outerWidth()));
|
||||||
|
newTop = Math.max(0, Math.min(newTop, winH - $modal.outerHeight()));
|
||||||
|
|
||||||
|
$modal.css({ left: newLeft + 'px', top: newTop + 'px', right: 'auto' });
|
||||||
|
})
|
||||||
|
.on('mouseup', function () {
|
||||||
|
isDragging = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#gaia-auth-btn').on('click', function () {
|
||||||
|
const query = $('#gaia-auth-query').val().trim().toLowerCase();
|
||||||
|
const $results = $('#gaia-auth-results');
|
||||||
|
$results.empty(); // Pulisce la lista ogni volta
|
||||||
|
$('#gaia-auth-openall-container').hide(); // Nasconde il pulsante "Apri tutti i Curriculum"
|
||||||
|
|
||||||
|
let collectedLinks = []; // memorizza i link trovati
|
||||||
|
|
||||||
|
if (!query) {
|
||||||
|
alert("Inserisci un codice corso per cercare.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ripulisce eventuali evidenziazioni precedenti
|
||||||
|
$(".panel.panel-default").css("background-color", "");
|
||||||
|
|
||||||
|
let found = 0;
|
||||||
|
|
||||||
|
$(".panel.panel-default").each(function () {
|
||||||
|
const $panel = $(this);
|
||||||
|
const text = $panel.text().toLowerCase();
|
||||||
|
|
||||||
|
if (text.includes(query)) {
|
||||||
|
found++;
|
||||||
|
|
||||||
|
// Evidenzia
|
||||||
|
$panel.css("background-color", "#d4edda");
|
||||||
|
|
||||||
|
// Cerca il link al profilo
|
||||||
|
const $profileLink = $panel.find("a[href^='/profilo/']").first();
|
||||||
|
if ($profileLink.length > 0) {
|
||||||
|
const href = $profileLink.attr('href'); // es. /profilo/220378/
|
||||||
|
const match = href.match(/\/profilo\/(\d+)\//);
|
||||||
|
const nome = $profileLink.text().trim();
|
||||||
|
|
||||||
|
if (match && match[1]) {
|
||||||
|
const id = match[1];
|
||||||
|
const fullLink = `https://gaia.cri.it/profilo/${id}/curriculum/?us`;
|
||||||
|
|
||||||
|
collectedLinks.push(fullLink);
|
||||||
|
|
||||||
|
const $entry = $(`
|
||||||
|
<div style="margin-bottom: 5px;">
|
||||||
|
<a href="${fullLink}" target="_blank">${nome}</a>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
$results.append($entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (collectedLinks.length > 0) {
|
||||||
|
$('#gaia-auth-openall-container').show();
|
||||||
|
$('#gaia-auth-openall').off('click').on('click', () => {
|
||||||
|
collectedLinks.forEach(link => window.open(link, '_blank'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found === 0) {
|
||||||
|
$results.append(`<div style="color: red;">Nessun risultato trovato.</div>`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function enhanceCurriculumTable() {
|
||||||
|
if (!window.location.href.match(/\/profilo\/\d+\/curriculum\//)) return;
|
||||||
|
|
||||||
|
const palette = {
|
||||||
|
"Qualifica CRI": "#e6f0ff", // blu chiaro
|
||||||
|
"Altra Qualifica": "#e6fff0", // verde chiaro
|
||||||
|
"Esperienze Professionali": "#fff3e6", // arancione chiaro
|
||||||
|
"Competenza Personale": "#e6faff", // ciano chiaro
|
||||||
|
"Patente Civile": "#f0f0f0", // grigio chiaro
|
||||||
|
"Patente CRI": "#f3e6ff" // lilla chiaro
|
||||||
|
};
|
||||||
|
|
||||||
|
const $table = $(".table.table-striped");
|
||||||
|
const $tbody = $table.find("tbody");
|
||||||
|
if (!$table.length || !$tbody.length) return;
|
||||||
|
|
||||||
|
console.log("GAIA Swissknife: DataTable + Colorazione permanente per tipologia...");
|
||||||
|
|
||||||
|
$table.DataTable({
|
||||||
|
paging: false,
|
||||||
|
order: [[0, 'asc'], [1, 'asc']],
|
||||||
|
columnDefs: [
|
||||||
|
{ orderable: false, targets: 3 }
|
||||||
|
],
|
||||||
|
language: {
|
||||||
|
search: "Filtra qualifiche:",
|
||||||
|
zeroRecords: "Nessuna qualifica trovata",
|
||||||
|
info: "Mostrate _TOTAL_ qualifiche",
|
||||||
|
infoEmpty: "Nessuna qualifica disponibile",
|
||||||
|
infoFiltered: "(filtrate da _MAX_ totali)"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function applyColoring() {
|
||||||
|
const tableApi = $table.DataTable();
|
||||||
|
tableApi.rows().every(function () {
|
||||||
|
const $row = $(this.node());
|
||||||
|
const $tipoCell = $row.find("td").eq(0);
|
||||||
|
const tipo = $tipoCell.text().trim();
|
||||||
|
|
||||||
|
if (palette[tipo]) {
|
||||||
|
$tipoCell.css("background-color", palette[tipo]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
applyColoring();
|
||||||
|
|
||||||
|
$table.on('draw.dt', function () {
|
||||||
|
// mantiene le celle pulite
|
||||||
|
applyStyleFixes();
|
||||||
|
// ricolora dopo ogni ricerca/ordinamento
|
||||||
|
applyColoring();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(() => {
|
||||||
|
applyStyleFixes();
|
||||||
|
addExamOutcomeButtons();
|
||||||
|
addOpenAllProfilesButton();
|
||||||
|
highlightRejectedCourses();
|
||||||
|
addAuthorizationProfileTool();
|
||||||
|
enhanceCurriculumTable();
|
||||||
|
console.log("GAIA Swissknife: Funzioni caricate con successo!");
|
||||||
});
|
});
|
||||||
})();
|
})(jQuery.noConflict(true));
|
||||||
Loading…
Add table
Add a link
Reference in a new issue