summaryrefslogtreecommitdiff
path: root/src/static/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/static/main.js')
-rw-r--r--src/static/main.js36
1 files changed, 7 insertions, 29 deletions
diff --git a/src/static/main.js b/src/static/main.js
index 7bea389..86cda7e 100644
--- a/src/static/main.js
+++ b/src/static/main.js
@@ -1,31 +1,9 @@
-const url = '/text';
-const parts = ["top", "program"];
-const elements = {};
-
-function get_element(part){
- elements[part] = document.getElementById(part);
-}
-
-const program_element = parts.forEach(get_element);
-
-function set_element_text(part, text){
- elements[part].innerHTML = text;
+async function update() {
+ const html = await (await fetch("/update")).text();
+ document.querySelector("#top").innerHTML = html.split("\n").slice(0, 1)[0];
+ document.querySelector("#program").innerHTML = html.split("\n").slice(1).join("\n");
}
-async function getEvents() {
- try {
- const response = await fetch(url);
- if (!response.ok) {
- throw new Error(`Response status: ${response.status}`);
- }
-
- const events = await response.json();
- console.log(events)
-
- } catch (error) {
- console.error(error.message);
- }
-}
-
-getEvents();
-
+setInterval(() => {
+ update()
+}, 5000);