🚑 Fix parser crash if column order is different
This commit is contained in:
@ -1,15 +1,15 @@
|
||||
import * as cheerio from "cheerio";
|
||||
const titles = [
|
||||
"class",
|
||||
"date",
|
||||
"lesson",
|
||||
"teacher",
|
||||
"changedTeacher",
|
||||
"subject",
|
||||
"room",
|
||||
"type",
|
||||
"notes",
|
||||
];
|
||||
const titleTranslations = {
|
||||
"Klasse(n)": "class",
|
||||
Datum: "date",
|
||||
Stunde: "lesson",
|
||||
"(Lehrer)": "teacher",
|
||||
Vertreter: "changedTeacher",
|
||||
Fach: "subject",
|
||||
Raum: "room",
|
||||
Art: "type",
|
||||
Text: "notes",
|
||||
};
|
||||
|
||||
export function parseSubstitutionPlan(html) {
|
||||
const infos = {};
|
||||
@ -36,6 +36,14 @@ export function parseSubstitutionPlan(html) {
|
||||
infos.updatedAt = new Date(timestamp).getTime();
|
||||
|
||||
const data = [];
|
||||
|
||||
const titles = [];
|
||||
const titleElements = $("table.mon_list tr.list th");
|
||||
titleElements.each((index, titleElement) => {
|
||||
const title = $(titleElement).text();
|
||||
titles[index] = titleTranslations[title];
|
||||
});
|
||||
|
||||
const subsitutionTable = $("table.mon_list tr.list");
|
||||
// Loop through each table row
|
||||
subsitutionTable.each((_rowcnt, row) => {
|
||||
|
Reference in New Issue
Block a user