import {DomOutput} from "./lib/DomIO.js";
|
import {calculateHomeworkTime} from "./study.js";
|
|
const OUTPUT_ELEMENT_ID = "text-output";
|
let terminal = new DomOutput(OUTPUT_ELEMENT_ID);
|
|
document.addEventListener("DOMContentLoaded",() =>{
|
document.getElementById("run").addEventListener("click", main);
|
});
|
|
/** JSON-Version */
|
function main() {
|
const inputElementId = "argv";
|
let inputContent = document.getElementById(inputElementId).value;
|
try {
|
let lectures = JSON.parse(inputContent);
|
let lecturesInformation = []
|
for(let lecture of lectures ) {
|
let homework = calculateHomeworkTime(lecture.ects, lecture.sws/2);
|
let newLecture = Object.assign({},lecture);
|
newLecture.homework = homework;
|
lecturesInformation.push(newLecture);
|
}
|
printLectureInformation(lecturesInformation);
|
}catch (e) {
|
//Error by parsing user input, => tell user what was wrong.
|
terminal.print(e);
|
}
|
}
|
|
function printLectureInformation(lecturesInformation) {
|
terminal.clear();
|
let table = `<table><tr>
|
<th class="name">Vorlesung</th><th class="effort">Aufwand pro Woche in Stunden</th>
|
</tr>\n`;
|
for(let l of lecturesInformation) {
|
table += `<tr><td class="name">${l.name}</td> <td class="effort">${l.homework}</td></tr>\n`
|
}
|
table += "</table>";
|
terminal.printh(table);
|
}
|