From 5c55b6f921e6e217cf04682ac6aa297c3da6d9ff Mon Sep 17 00:00:00 2001 From: Gaspard Jankowiak Date: Wed, 2 Oct 2024 14:46:43 +0200 Subject: [PATCH] import --- directory.css | 19 ++++++++ directory.js | 111 ++++++++++++++++++++++++++++++++++++++++++ icons/icon-48.png | Bin 0 -> 1546 bytes icons/icon.svg | 119 ++++++++++++++++++++++++++++++++++++++++++++++ manifest.json | 26 ++++++++++ 5 files changed, 275 insertions(+) create mode 100644 directory.css create mode 100644 directory.js create mode 100644 icons/icon-48.png create mode 100644 icons/icon.svg create mode 100644 manifest.json diff --git a/directory.css b/directory.css new file mode 100644 index 0000000..097f5f1 --- /dev/null +++ b/directory.css @@ -0,0 +1,19 @@ +#_kfrombi_columns_slider{display: inline-block; vertical-align: middle;} + +#_kfrombi_trombi { display: grid; grid-row-gap: 2em; font-size: 1.2em; text-align: center; } + +._kfrombi_trombi_3 { grid-template-columns: repeat(3, 1fr); } +._kfrombi_trombi_4 { grid-template-columns: repeat(4, 1fr); } +._kfrombi_trombi_5 { grid-template-columns: repeat(5, 1fr); } +._kfrombi_trombi_6 { grid-template-columns: repeat(6, 1fr); } +._kfrombi_trombi_7 { grid-template-columns: repeat(7, 1fr); } +._kfrombi_trombi_8 { grid-template-columns: repeat(8, 1fr); } + +.hidden { display: none; } +._kfrombi_trombi_img { + filter: grayscale(100%) contrast(150%); +} + +@media print { + .headerHeading, #idPageNavi {display: none;} +} diff --git a/directory.js b/directory.js new file mode 100644 index 0000000..2cc6cd4 --- /dev/null +++ b/directory.js @@ -0,0 +1,111 @@ +const C = document.createElement; +// const G = document.getElementById; + +const ordNrRegex = /.*pOrgNr=([0-9]+).*/gm; +const personalIDRegex = /.*pStPersonNr=([0-9]+).*/gm; + +function appendLink() { + if (document.getElementById("_kfrombi_row")) return; + + 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"); + slider.id = "_kfrombi_columns_slider"; + slider.type = "range"; + slider.value = 5; + slider.min = 3; + slider.max = 8; + + var column_nr = document.createElement("span"); + column_nr.id = "_kfrombi_column_nr"; + column_nr.textContent = slider.value; + var column_label = document.createElement("span"); + column_label.textContent = " columns"; + + slider.addEventListener("input", (event) => { + column_nr.textContent = slider.value; + const trombi = document.getElementById("_kfrombi_trombi"); + trombi.classList.remove( "_kfrombi_trombi_3", "_kfrombi_trombi_4", "_kfrombi_trombi_5", "_kfrombi_trombi_6", "_kfrombi_trombi_7", "_kfrombi_trombi_8" ); + trombi.classList.add(`_kfrombi_trombi_${slider.value}`); + }) + + var row_links = document.createElement("td"); + row_links.append(link, slider, column_nr, column_label); + + var tr = document.createElement("tr"); + tr.classList.add("coNavdocument.getElementByIdroup"); + tr.append(row_header, row_links); + tr.id = "_kfrombi_row"; + + 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) { + const url = `https://online.uni-graz.at/kfu_online/pl/ui/$ctx/wbstudkart.wbShowImage?pOrgNr=${student.ids.org}&pStPersonNr=${student.ids.perso}&pType=U` + + const d = document.createElement("div"); + d.style.gridColumn = "auto"; + + const img = document.createElement("img"); + img.classList.add("_kfrombi_trombi_img"); + 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() { + const trombi = document.getElementById("_kfrombi_trombi"); + const form = document.getElementById("idTNListe"); + trombi.classList.toggle("hidden"); + form.classList.toggle("hidden"); +} + +function generateTrombi() { + var trombi = document.getElementById("_kfrombi_trombi"); + if (trombi) { trombi.remove(); } + const slider = document.getElementById("_kfrombi_columns_slider"); + trombi = document.createElement("div"); + trombi.id = "_kfrombi_trombi"; + trombi.classList.add("hidden"); + trombi.classList.add(`_kfrombi_trombi_${slider.value}`); + 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); +} + +appendLink(); +generateTrombi(); + diff --git a/icons/icon-48.png b/icons/icon-48.png new file mode 100644 index 0000000000000000000000000000000000000000..af430287163fdb35be69b8404b6a45f1ed01acdb GIT binary patch literal 1546 zcmV+l2KD)gP)pF8FWQhbW?9;ba!ELWdL_~cP?peYja~^aAhuUa%Y?FJQ@H11(!)g zK~!jg?U`F_R8Sa<)XZvt{0V#}>5qar zlT;AJiRM$l0YIbZkFIUenEe(A{QMk&r|JP<{)7?$9tO_k0Y0h2z?umm0IUOIV*sDj z7_jb=5&#ysqc>LYNj(oNx+DaEDL{V#!6&sJnBoUZzU#m%z|7=BMMVW=Wo5oP*tl_H zy5gBY+KP;l=jfloGjgj}uU1!AmjKn))~c$iD(wi*nl(%1<>d;6LP{hOYG`OsOG}Gd zTU)($XMw5XmO{YGfC7PlIy*bHZQC}5!(mC%?%lg}?%X+5R8*uTuxiyRNz$oPrzAPbQB9TyMXQxU^N|N?Nz~u2DFgFQk z%a$z~7#J7(;Fb1Og)ntX;cSeSLi++HBgiDP6?ojR%2xualCJ5=EoYi@?O= zaV=iFIAa?1^z>XrHWrJiudh$V#l@+%D{{f)_cc1r`%qh3%h1ped-m)Bpu4-9j*bo* z8yhor5Q#*ntE;28x0i4@Oj%hO&CSh}mzSrSR_27rX9S+aGfFizHJUMFhRjUia9B&1 zE**8TDk>@xpin5J_3PJXvuz%a6uK{y!)eo|skF4TkgM_ouqGF1!=3@|)AoVKp9 zvC;QR4IIzO%4YUv#n|_D+70a+e%tww*K-9A_>Tbm zABA4vPH*|HUAqW{Ld4^7B9RD*M1sM=!L)t!_xID@-kw_gJ+Lh2{0IMYz%v&@z)3v0 zTVG$V!NEa|CXq-)4Gj&cd4C3&=^IDB1Y8o!a6Ul(2U1m4rOlf+YybZJI)41PqS2_L z(Ws6cJEoqV9<{Z#sj{*%75rJ??z}LJg@8+94$j2O_l7jQZY@H4K>fn${zm{|$17`P3%)-65_{0e+4>3qR_r6XWw z^)K*X`qwrz`;6A?fE#?J_N7j{{G*ojeCT zEr;osz_YF{0@eU;;hYowU}j75B>>z7)TES^0`syp%6dOwW{&`KB)#Akos`t(secC8 zE9q@By9am-_}a`C0?z?|1KTAXF|$^jo$N!v2f$=t1@N(?Znw+Z&FoR&cc24jfJ?Gr z%(j(S0<__r10`j$nceSd^5Wt;GrJWh8sC}ORNzfu6Yvi3o@=)fmj8U{WD7G?wP1(`{{0^SGqnb|LrjsmA8ZBH7Q*#clMuoKvC zW;f$}N!{Sqn@f7gZQ|Xe#nbql;{IMwj$dS1=YXWMX7&=$Wo8Xo>||!I0-cf?%n+a literal 0 HcmV?d00001 diff --git a/icons/icon.svg b/icons/icon.svg new file mode 100644 index 0000000..bb2a3ab --- /dev/null +++ b/icons/icon.svg @@ -0,0 +1,119 @@ + + + + + + + + + + KFRombi + + + + + + + diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..5298b1f --- /dev/null +++ b/manifest.json @@ -0,0 +1,26 @@ +{ + "manifest_version": 2, + "name": "KFRombi", + "version": "0.1", + + "browser_specific_settings": { + "gecko": { + "id": "kfrombi@math.janko.fr" + } + }, + + "description": "Generates a directory of students with photos from online.uni-graz.at", + + "icons": { + "48": "icons/icon-48.png" + }, + + "content_scripts": [ + { + "matches": ["https://online.uni-graz.at/kfu_online/pl/ui/$ctx/wblvgrp.anmeldungen*"], + "js": ["directory.js"], + "css": ["directory.css"] + } + ] + +}