Studien-Semester-Select: parit\u00e4ts- und umfangsgerecht (WS ungerade, SS gerade; BSc 1-6, MSc 1-4) aus CIS-Endpoint

This commit is contained in:
Nicolas Gruber
2026-10-19 12:13:51 +02:00
parent d97164cddc
commit 567bcb40ee
7 changed files with 104 additions and 43 deletions
+26 -1
View File
@@ -380,7 +380,32 @@ function decodeMat() {
box.classList.add("show");
}
/* ================= Verband-Selects dynamisch ================= */
/* ================= Seminar- + Verband-Selects dynamisch ================= */
async function reloadSemesters() {
const sel = $("#sem-select");
const stgSel = $("#stg-select");
if (!sel || !stgSel) return;
const kz = stgSel.value;
const planSem = (($('select[name="semester"]') || {}).value || "").toUpperCase();
try {
const r = await fetch(`/api/semesters_for_stg?kz=${encodeURIComponent(kz)}`);
if (!r.ok) throw new Error("bad status");
let data = await r.json();
let arr = (Array.isArray(data) ? data : Object.values(data))
.map(Number).filter(n => Number.isInteger(n) && n > 0);
if (planSem.startsWith("WS")) arr = arr.filter(n => n % 2 === 1);
else if (planSem.startsWith("SS")) arr = arr.filter(n => n % 2 === 0);
arr = [...new Set(arr)].sort((a, b) => a - b);
if (arr.length) {
const current = sel.value;
sel.innerHTML = arr.map(n =>
`<option value="${n}"${n === Number(current) ? " selected" : ""}>${n}</option>`).join("");
if (current && !arr.includes(Number(current))) sel.selectedIndex = 0;
}
} catch (e) { /* Keep static options */ }
reloadVerbands();
}
async function reloadVerbands() {
const sel = $("#ver-select");
if (!sel) return;