2024-10-02 14:46:43 +02:00
|
|
|
const C = document.createElement;
|
|
|
|
// const G = document.getElementById;
|
|
|
|
|
|
|
|
const ordNrRegex = /.*pOrgNr=([0-9]+).*/gm;
|
|
|
|
const personalIDRegex = /.*pStPersonNr=([0-9]+).*/gm;
|
|
|
|
|
|
|
|
function appendLink() {
|
2024-10-02 19:22:48 +02:00
|
|
|
if (document.getElementById("kf-trombi_row")) return;
|
2024-10-02 14:46:43 +02:00
|
|
|
|
|
|
|
var row_header = document.createElement("th");
|
|
|
|
row_header.textContent = "Trombi";
|
|
|
|
|
|
|
|
var link = document.createElement("a");
|
|
|
|
link.textContent = "Toggle";
|
|
|
|
link.href="#";
|
|
|
|
link.addEventListener("click", toggleTrombi);
|
|
|
|
|
|
|
|
var slider = document.createElement("input");
|
2024-10-02 19:22:48 +02:00
|
|
|
slider.id = "kf-trombi_columns_slider";
|
2024-10-02 14:46:43 +02:00
|
|
|
slider.type = "range";
|
|
|
|
slider.value = 5;
|
|
|
|
slider.min = 3;
|
|
|
|
slider.max = 8;
|
|
|
|
|
|
|
|
var column_nr = document.createElement("span");
|
2024-10-02 19:22:48 +02:00
|
|
|
column_nr.id = "kf-trombi_column_nr";
|
2024-10-02 14:46:43 +02:00
|
|
|
column_nr.textContent = slider.value;
|
|
|
|
var column_label = document.createElement("span");
|
|
|
|
column_label.textContent = " columns";
|
|
|
|
|
|
|
|
slider.addEventListener("input", (event) => {
|
|
|
|
column_nr.textContent = slider.value;
|
2024-10-02 19:22:48 +02:00
|
|
|
const trombi = document.getElementById("kf-trombi_trombi");
|
|
|
|
trombi.classList.remove( "kf-trombi_trombi_3", "kf-trombi_trombi_4", "kf-trombi_trombi_5", "kf-trombi_trombi_6", "kf-trombi_trombi_7", "kf-trombi_trombi_8" );
|
|
|
|
trombi.classList.add(`kf-trombi_trombi_${slider.value}`);
|
2024-10-02 14:46:43 +02:00
|
|
|
})
|
|
|
|
|
2024-10-04 10:46:04 +02:00
|
|
|
enhanced_checkbox = document.createElement("input");
|
|
|
|
enhanced_checkbox.id = "kf-trombi_enhanced_checkbox";
|
|
|
|
enhanced_checkbox.type = "checkbox";
|
|
|
|
enhanced_checkbox.checked = true;
|
|
|
|
|
|
|
|
var enhance_label = document.createElement("label");
|
|
|
|
enhance_label.textContent = " enhance";
|
|
|
|
enhance_label.htmlFor = "kf-trombi_enhanced_checkbox";
|
|
|
|
|
|
|
|
enhanced_checkbox.addEventListener("input", (event) => {
|
|
|
|
const trombi = document.getElementById("kf-trombi_trombi");
|
|
|
|
trombi.classList.toggle('kf-trombi_enhanced');
|
|
|
|
})
|
|
|
|
|
2024-10-02 14:46:43 +02:00
|
|
|
var row_links = document.createElement("td");
|
2024-10-04 10:46:04 +02:00
|
|
|
row_links.append(link, slider, column_nr, column_label, enhanced_checkbox, enhance_label);
|
2024-10-02 14:46:43 +02:00
|
|
|
|
|
|
|
var tr = document.createElement("tr");
|
|
|
|
tr.classList.add("coNavdocument.getElementByIdroup");
|
|
|
|
tr.append(row_header, row_links);
|
2024-10-02 19:22:48 +02:00
|
|
|
tr.id = "kf-trombi_row";
|
2024-10-02 14:46:43 +02:00
|
|
|
|
|
|
|
const nav = document.getElementById("idPageNavi");
|
|
|
|
nav.tBodies[0].append(tr);
|
|
|
|
}
|
|
|
|
|
|
|
|
function extractIDs(url) {
|
|
|
|
return {
|
|
|
|
org: url.replace(ordNrRegex, "$1"),
|
|
|
|
perso: url.replace(personalIDRegex, "$1"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function generateCard(student, col) {
|
2024-10-02 14:59:50 +02:00
|
|
|
const url = `/kfu_online/pl/ui/$ctx/wbstudkart.wbShowImage?pOrgNr=${student.ids.org}&pStPersonNr=${student.ids.perso}&pType=U`
|
2024-10-02 14:46:43 +02:00
|
|
|
|
|
|
|
const d = document.createElement("div");
|
2024-10-02 19:56:31 +02:00
|
|
|
d.classList.add("kf-trombi_card");
|
2024-10-02 14:46:43 +02:00
|
|
|
|
|
|
|
const img = document.createElement("img");
|
2024-10-02 19:22:48 +02:00
|
|
|
img.classList.add("kf-trombi_trombi_img");
|
2024-10-02 14:46:43 +02:00
|
|
|
img.src = url;
|
|
|
|
|
|
|
|
const name_div = document.createElement("div");
|
|
|
|
name_div.textContent = `${student.firstname} ${student.lastname}`;
|
|
|
|
|
|
|
|
d.append(img, name_div);
|
|
|
|
return d;
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleTrombi() {
|
2024-10-02 19:22:48 +02:00
|
|
|
const trombi = document.getElementById("kf-trombi_trombi");
|
2024-10-02 14:46:43 +02:00
|
|
|
const form = document.getElementById("idTNListe");
|
|
|
|
trombi.classList.toggle("hidden");
|
|
|
|
form.classList.toggle("hidden");
|
|
|
|
}
|
|
|
|
|
|
|
|
function generateTrombi() {
|
2024-10-02 19:22:48 +02:00
|
|
|
var trombi = document.getElementById("kf-trombi_trombi");
|
2024-10-02 14:46:43 +02:00
|
|
|
if (trombi) { trombi.remove(); }
|
2024-10-02 19:22:48 +02:00
|
|
|
const slider = document.getElementById("kf-trombi_columns_slider");
|
2024-10-02 14:46:43 +02:00
|
|
|
trombi = document.createElement("div");
|
2024-10-02 19:22:48 +02:00
|
|
|
trombi.id = "kf-trombi_trombi";
|
2024-10-02 14:46:43 +02:00
|
|
|
trombi.classList.add("hidden");
|
2024-10-02 19:22:48 +02:00
|
|
|
trombi.classList.add(`kf-trombi_trombi_${slider.value}`);
|
2024-10-04 10:46:04 +02:00
|
|
|
trombi.classList.add("kf-trombi_enhanced");
|
2024-10-02 14:46:43 +02:00
|
|
|
const form = document.getElementById("idTNListe");
|
|
|
|
|
|
|
|
const table_body = document.getElementById("idTNVWTable").tBodies[0];
|
|
|
|
|
|
|
|
const student_list = [];
|
|
|
|
for (let row of table_body.children) {
|
|
|
|
student_list.push({
|
|
|
|
lastname: row.children[1].textContent,
|
|
|
|
firstname: row.children[2].textContent,
|
|
|
|
ids: extractIDs(row.children[1].children[1].href)
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
student_list.forEach((student, idx) => {
|
|
|
|
trombi.append(generateCard(student, 1 + idx % 5));
|
|
|
|
});
|
|
|
|
|
|
|
|
form.after(trombi);
|
|
|
|
}
|
|
|
|
|
2024-10-04 10:46:31 +02:00
|
|
|
// reset
|
|
|
|
if (document.getElementById("kf-trombi_trombi")) {
|
|
|
|
document.getElementById("idTNListe").classList.remove("hidden");
|
|
|
|
document.getElementById("kf-trombi_trombi").remove();
|
|
|
|
document.getElementById("kf-trombi_row").remove();
|
|
|
|
}
|
|
|
|
|
2024-10-02 14:46:43 +02:00
|
|
|
appendLink();
|
|
|
|
generateTrombi();
|
|
|
|
|