versione 1 completata
This commit is contained in:
parent
440941d71a
commit
54466f6e38
1 changed files with 96 additions and 141 deletions
|
|
@ -234,7 +234,7 @@ GM_addStyle(GM_getResourceText("DataTablesCSS"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Funzione per aggiungere il pulsante "Apri tutti i Curriculum" sezione iscritti
|
// Funzione per aggiungere il pulsante "Apri tutti i Curriculum" sezione iscritti di un corso
|
||||||
function addOpenAllProfilesButton() {
|
function addOpenAllProfilesButton() {
|
||||||
if (!window.location.href.includes('/iscritti/')) return;
|
if (!window.location.href.includes('/iscritti/')) return;
|
||||||
|
|
||||||
|
|
@ -352,170 +352,125 @@ GM_addStyle(GM_getResourceText("DataTablesCSS"));
|
||||||
function addAuthorizationProfileTool() {
|
function addAuthorizationProfileTool() {
|
||||||
if (!window.location.href.includes("/autorizzazioni/")) return;
|
if (!window.location.href.includes("/autorizzazioni/")) return;
|
||||||
|
|
||||||
// Crea la finestra modale
|
console.log("GAIA Swissknife: Attivo tool per gestione richieste iscrizione...");
|
||||||
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>
|
|
||||||
|
|
||||||
|
const richieste = [];
|
||||||
|
|
||||||
|
$(".panel.panel-default").each(function () {
|
||||||
|
const $panel = $(this);
|
||||||
|
const $corsoLink = $panel.find("a[href^='/aspirante/corso-base/']");
|
||||||
|
|
||||||
|
if ($corsoLink.length === 0) return; // blocco non relativo a richiesta corso
|
||||||
|
|
||||||
|
const corsoText = $corsoLink.text().trim();
|
||||||
|
const match = corsoText.match(/([A-Z]{3,}\/\d{4}\/[A-Z]+\/\d+)/);
|
||||||
|
if (!match) return;
|
||||||
|
|
||||||
|
const codiceCorso = match[1];
|
||||||
|
const $profileLink = $panel.find("a[href^='/profilo/']").first();
|
||||||
|
const nome = $profileLink.text().trim();
|
||||||
|
const href = $profileLink.attr("href");
|
||||||
|
const idMatch = href.match(/\/profilo\/(\d+)\//);
|
||||||
|
|
||||||
|
if (idMatch && idMatch[1]) {
|
||||||
|
richieste.push({
|
||||||
|
codice: codiceCorso,
|
||||||
|
nome,
|
||||||
|
id: idMatch[1],
|
||||||
|
$panel
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const corsiUnici = [...new Set(richieste.map(r => r.codice))];
|
||||||
|
if (corsiUnici.length === 0) return;
|
||||||
|
|
||||||
|
// === CREAZIONE 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 – Richieste iscrizione</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;">
|
<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;">
|
<label for="gaia-auth-select">Seleziona un corso:</label>
|
||||||
|
<select id="gaia-auth-select" style="width: 100%; padding: 5px; margin-bottom: 10px;">
|
||||||
|
<option value="">-- Seleziona --</option>
|
||||||
|
${corsiUnici.map(c => `<option value="${c}">${c}</option>`).join("")}
|
||||||
|
</select>
|
||||||
<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>
|
<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;">
|
<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;">
|
<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>
|
||||||
Apri tutti i Curriculum
|
|
||||||
</button>
|
|
||||||
</div>
|
</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 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>
|
||||||
</div>
|
</div>
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
|
||||||
$('body').append($modal);
|
$('body').append($modal);
|
||||||
|
|
||||||
|
// Riduci / Espandi
|
||||||
let isCollapsed = false;
|
let isCollapsed = false;
|
||||||
|
|
||||||
$('#gaia-auth-toggle').on('click', function (e) {
|
$('#gaia-auth-toggle').on('click', function (e) {
|
||||||
isCollapsed = !isCollapsed;
|
isCollapsed = !isCollapsed;
|
||||||
$('#gaia-auth-body').slideToggle(200);
|
$('#gaia-auth-body').slideToggle(200);
|
||||||
$(this).text(isCollapsed ? '+' : '−'); // Cambia icona da - a +
|
$(this).text(isCollapsed ? '+' : '−');
|
||||||
e.stopPropagation(); // Previene conflitti con il drag
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Trascinabilità
|
// Modal mobile
|
||||||
let isDragging = false;
|
let isDragging = false, dragOffsetX = 0, dragOffsetY = 0;
|
||||||
let dragOffsetX = 0, dragOffsetY = 0;
|
$('#gaia-auth-header').on('mousedown', function (e) {
|
||||||
|
const rect = document.getElementById('gaia-auth-tool').getBoundingClientRect();
|
||||||
$('#gaia-auth-header')
|
|
||||||
.on('mousedown', function (e) {
|
|
||||||
const modal = document.getElementById('gaia-auth-tool');
|
|
||||||
const rect = modal.getBoundingClientRect();
|
|
||||||
|
|
||||||
isDragging = true;
|
isDragging = true;
|
||||||
dragOffsetX = e.clientX - rect.left;
|
dragOffsetX = e.clientX - rect.left;
|
||||||
dragOffsetY = e.clientY - rect.top;
|
dragOffsetY = e.clientY - rect.top;
|
||||||
|
e.preventDefault();
|
||||||
e.preventDefault(); // previene selezione testo
|
|
||||||
});
|
});
|
||||||
|
$(document).on('mousemove', function (e) {
|
||||||
$(document)
|
|
||||||
.on('mousemove', function (e) {
|
|
||||||
if (!isDragging) return;
|
if (!isDragging) return;
|
||||||
|
|
||||||
const winW = window.innerWidth;
|
|
||||||
const winH = window.innerHeight;
|
|
||||||
const $modal = $('#gaia-auth-tool');
|
const $modal = $('#gaia-auth-tool');
|
||||||
|
let left = e.clientX - dragOffsetX;
|
||||||
|
let top = e.clientY - dragOffsetY;
|
||||||
|
left = Math.max(0, Math.min(left, window.innerWidth - $modal.outerWidth()));
|
||||||
|
top = Math.max(0, Math.min(top, window.innerHeight - $modal.outerHeight()));
|
||||||
|
$modal.css({ left: left + 'px', top: top + 'px', right: 'auto' });
|
||||||
|
}).on('mouseup', () => isDragging = false);
|
||||||
|
|
||||||
let newLeft = e.clientX - dragOffsetX;
|
// Recupera profili
|
||||||
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 () {
|
$('#gaia-auth-btn').on('click', function () {
|
||||||
const query = $('#gaia-auth-query').val().trim().toLowerCase();
|
const codiceSelezionato = $('#gaia-auth-select').val();
|
||||||
const $results = $('#gaia-auth-results');
|
const $results = $('#gaia-auth-results').empty();
|
||||||
$results.empty(); // Pulisce la lista ogni volta
|
$('#gaia-auth-openall-container').hide();
|
||||||
$('#gaia-auth-openall-container').hide(); // Nasconde il pulsante "Apri tutti i Curriculum"
|
|
||||||
|
|
||||||
let collectedLinks = []; // memorizza i link trovati
|
if (!codiceSelezionato) {
|
||||||
|
alert("Seleziona un codice corso.");
|
||||||
if (!query) {
|
|
||||||
alert("Inserisci un codice corso per cercare.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ripulisce eventuali evidenziazioni precedenti
|
// Reset evidenziazione
|
||||||
$(".panel.panel-default").css("background-color", "");
|
$(".panel.panel-default").css("background-color", "");
|
||||||
|
|
||||||
let found = 0;
|
const trovati = richieste.filter(r => r.codice === codiceSelezionato);
|
||||||
|
if (trovati.length === 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>`);
|
$results.append(`<div style="color: red;">Nessun risultato trovato.</div>`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trovati.forEach(r => {
|
||||||
|
r.$panel.css("background-color", "#d4edda");
|
||||||
|
const link = `https://gaia.cri.it/profilo/${r.id}/curriculum/?us`;
|
||||||
|
$results.append(`<div><a href="${link}" target="_blank">${r.nome}</a></div>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#gaia-auth-openall-container').show();
|
||||||
|
$('#gaia-auth-openall').off('click').on('click', function () {
|
||||||
|
trovati.forEach(r => window.open(`https://gaia.cri.it/profilo/${r.id}/curriculum/?us`, '_blank'));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Funzione per migliorare la tabella del curriculum
|
||||||
function enhanceCurriculumTable() {
|
function enhanceCurriculumTable() {
|
||||||
if (!window.location.href.match(/\/profilo\/\d+\/curriculum\//)) return;
|
if (!window.location.href.match(/\/profilo\/\d+\/curriculum\//)) return;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue