const ParseTools = require("./ParseTools"); const parser = (text) => { if(!ParseTools.isFilled(text)) return null; const data = { original: text, changes: false, note: null, planned: text, actual: text, }; const hasBold = text.includes(" "); const hasDel = text.includes(""); if(hasBold) { data.actual = text.split(" ")[1].split("")[0]; if(hasDel) data.actual = data.actual.substring(1); } if(hasDel) { data.planned = text.split("")[1].split("")[0]; data.changes = true; if(text.substring(text.search("") + 6) !== "") { // If it has reasoning/note if(!hasBold) { data.actual = null; data.note = text.substring(text.search("") + 6); } else data.note = text.substring(text.search("") + 5); data.note = data.note.trim(); if(data.note === "") data.note = null; } else data.actual = null; } else data.planned = data.actual; return data; } class TimetableDay { #data = []; anyChanges = false; constructor(data) { data.forEach((part, i) => { this.#data[i] = parser(part); if(this.#data[i]?.changes) this.anyChanges = true; }); this.teacher = this.#data[0]; this.subject = this.#data[1]; this.room = this.#data[2]; this.exam = this.#data[3]; } } module.exports = TimetableDay;