This commit is contained in:
Gaspard Jankowiak 2024-10-02 14:46:43 +02:00
commit 5c55b6f921
5 changed files with 275 additions and 0 deletions

19
directory.css Normal file
View file

@ -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;}
}

111
directory.js Normal file
View file

@ -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();

BIN
icons/icon-48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

119
icons/icon.svg Normal file
View file

@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="48"
height="48"
viewBox="0 0 12.7 12.7"
version="1.1"
id="svg1"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)"
sodipodi:docname="border.svg"
inkscape:export-filename="icon-48.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="1.0770412"
inkscape:cx="238.61667"
inkscape:cy="131.37844"
inkscape:window-width="2560"
inkscape:window-height="1413"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1">
<rect
x="0"
y="32.474262"
width="45.281854"
height="12.678828"
id="rect1" />
</defs>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
transform="matrix(0.2907302,0,0,0.2907302,1.2586092,-0.4136854)"
id="text1"
style="font-size:8px;font-family:tex;-inkscape-font-specification:tex;white-space:pre;shape-inside:url(#rect1);display:inline;fill:#000000;stroke-width:0.755906;stroke-linecap:round;stroke-linejoin:round"><tspan
x="0"
y="39.753611"
id="tspan2">KFRombi</tspan></text>
<ellipse
style="fill:#000000;stroke-width:0.266185;stroke-linecap:round;stroke-linejoin:round"
id="path1"
cx="6.6160941"
cy="5.2686148"
rx="3.5493381"
ry="3.8652532" />
<path
sodipodi:type="star"
style="fill:#ffffff;fill-opacity:1;stroke-width:0.2;stroke-linecap:round;stroke-linejoin:round"
id="path2"
inkscape:flatsided="false"
sodipodi:sides="8"
sodipodi:cx="5.4926267"
sodipodi:cy="5.0868015"
sodipodi:r1="1.1985368"
sodipodi:r2="0.68863398"
sodipodi:arg1="-0.12226288"
sodipodi:arg2="0.36970345"
inkscape:rounded="0"
inkscape:randomized="0"
d="M 6.6822166,4.9406298 6.1347328,5.3356318 6.4371528,5.8246096 5.7707147,5.7167887 5.6387984,6.2763914 5.2437964,5.7289076 4.7548186,6.0313277 4.8626395,5.3648895 4.3030368,5.2329733 4.8505206,4.8379713 4.5481005,4.3489935 5.2145387,4.4568144 5.3464549,3.8972116 5.7414569,4.4446954 6.2304347,4.1422754 6.1226138,4.8087135 Z"
transform="translate(-0.61028141,-0.58743968)" />
<path
sodipodi:type="star"
style="fill:#ffffff;fill-opacity:1;stroke-width:0.2;stroke-linecap:round;stroke-linejoin:round"
id="path3"
inkscape:flatsided="false"
sodipodi:sides="8"
sodipodi:cx="5.4926267"
sodipodi:cy="5.0868015"
sodipodi:r1="1.1985368"
sodipodi:r2="0.68863398"
sodipodi:arg1="-0.12226288"
sodipodi:arg2="0.36970345"
inkscape:rounded="0"
inkscape:randomized="0"
d="M 6.6822166,4.9406298 6.1347328,5.3356318 6.4371528,5.8246096 5.7707147,5.7167887 5.6387984,6.2763914 5.2437964,5.7289076 4.7548186,6.0313277 4.8626395,5.3648895 4.3030368,5.2329733 4.8505206,4.8379713 4.5481005,4.3489935 5.2145387,4.4568144 5.3464549,3.8972116 5.7414569,4.4446954 6.2304347,4.1422754 6.1226138,4.8087135 Z"
transform="translate(2.6524998,-0.71195834)" />
<path
style="fill:#ffffff;fill-opacity:1;stroke-width:0.2;stroke-linecap:round;stroke-linejoin:round"
id="path4"
sodipodi:type="arc"
sodipodi:cx="6.6160941"
sodipodi:cy="7.5143247"
sodipodi:rx="1.5538439"
sodipodi:ry="0.69132471"
sodipodi:start="0"
sodipodi:end="3.2134157"
sodipodi:arc-type="slice"
d="M 8.169938,7.5143247 A 1.5538439,0.69132471 0 0 1 7.3605798,8.1211326 1.5538439,0.69132471 0 0 1 5.7756539,8.0957985 1.5538439,0.69132471 0 0 1 5.0662563,7.4647143 l 1.5498378,0.04961 z" />
<rect
style="fill:#ffffff;fill-opacity:1;stroke-width:0.2;stroke-linecap:round;stroke-linejoin:round"
id="rect4"
width="0.33944243"
height="0.55598503"
x="6.6160941"
y="5.9792342"
ry="0.14385796" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.5 KiB

26
manifest.json Normal file
View file

@ -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"]
}
]
}