aboutsummaryrefslogtreecommitdiff
path: root/src/main.js
diff options
context:
space:
mode:
authordavidpkj <davidpenkow1@gmail.com>2024-04-13 12:28:41 +0200
committerdavidpkj <davidpenkow1@gmail.com>2024-04-13 12:28:41 +0200
commit59b700299f860f0854c37906eaa5a5850cc45f59 (patch)
treebaf0e3010bf38da42382e49bbc480c8dc6e65b51 /src/main.js
parentb291ddc44b9df8754c68f865383d206d9092c5a4 (diff)
univis stuff & docs
Diffstat (limited to 'src/main.js')
-rw-r--r--src/main.js49
1 files changed, 26 insertions, 23 deletions
diff --git a/src/main.js b/src/main.js
index 5b326d7..c3cbec9 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,10 +1,10 @@
import * as fs from "fs"
import * as html_to_pdf from "html-pdf-node"
-import * as v from './variables.js'
+import { c } from './files.js'
let hinweise = "<ul>";
-for (let hinweis of v.hinweise) {
+for (let hinweis of c.hinweise) {
hinweise += `<li>${hinweis}</li>`;
}
hinweise += `</ul>`;
@@ -133,14 +133,19 @@ function main() {
let tage = structuredClone(ctage);
let tage_runtimes = structuredClone(ctage);
- for (let eintrag of v.eintraege) {
- for (let termin of eintrag.termine) {
- tage[termin.wochentag].push({
- "name": eintrag.name,
- "raum": termin.raum,
- "von": termin.von,
- "bis": termin.bis,
- })
+ for (let eintrag of c.eintraege) {
+ let eintragName = Object.keys(eintrag)[0];
+ eintrag = eintrag[eintragName]
+
+ for (let veranstaltung in eintrag) {
+ for (let termin of eintrag[veranstaltung]) {
+ tage[termin[0]].push({
+ "name": `${eintragName.toString()} / ${veranstaltung.toString()}`,
+ "raum": termin[3],
+ "von": termin[1].replace("h", ":"),
+ "bis": termin[2].replace("h", ":"),
+ })
+ }
}
}
@@ -167,7 +172,7 @@ function main() {
let el = tage_runtimes[day][0];
- if (el.name == "BLOCKED" && el.raum == "BLOCKED") {
+ if (el.name.includes("BLOCKED") && el.raum == "BLOCKED") {
res += `<td rowspan="${el.runtime}" class="block"></td>`;
} else {
let name = el.name == "BUFFER" ? "" : `<div><span>${el.name}</span>`;
@@ -183,31 +188,29 @@ function main() {
res += "</tr>"
}
- // console.log(res)
-
return res
}
let html = `
-${v.style}
-<p>Persönlicher Stundenplan von ${v.student} für das ${v.semester}. Stand: ${date}.</p>
+${c.style}
+<p>Persönlicher Stundenplan von ${c.student} für das ${c.semester}. Stand: ${date}.</p>
<table>
<tr>
- <th> Uhrzeit </th>
- <th class="tag"> Montag </th>
- <th class="tag"> Dienstag </th>
- <th class="tag"> Mittwoch </th>
- <th class="tag"> Donnerstag </th>
- <th class="tag"> Freitag </th>
+ <th>Uhrzeit</th>
+ <th class="tag">Montag</th>
+ <th class="tag">Dienstag</th>
+ <th class="tag">Mittwoch</th>
+ <th class="tag">Donnerstag</th>
+ <th class="tag">Freitag</th>
</tr>
${main()}
</table>
<br>
-<u> Hinweise: </u>
+<em>Hinweise:</em>
${hinweise}
`;
html_to_pdf.generatePdf({content: html}, options).then(pdfBuffer => {
// fs.writeFileSync("test.html", html)
- fs.writeFileSync(v.filename, pdfBuffer);
+ fs.writeFileSync(c.filename, pdfBuffer);
});