aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-08 02:17:10 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-08 02:17:10 +0200
commit1ca1132787e13e99eaba70123ee8dd7c0cbab385 (patch)
tree354ca323009483812fa886782701835464f95ca7
parentAdd /remove POST endpoint. (diff)
downloadcalp-1ca1132787e13e99eaba70123ee8dd7c0cbab385.tar.gz
calp-1ca1132787e13e99eaba70123ee8dd7c0cbab385.tar.xz
Add HTML button for removing elements.
-rw-r--r--module/output/html.scm9
-rw-r--r--static/script.js25
2 files changed, 32 insertions, 2 deletions
diff --git a/module/output/html.scm b/module/output/html.scm
index 66b3ad69..93fc5375 100644
--- a/module/output/html.scm
+++ b/module/output/html.scm
@@ -164,8 +164,13 @@
,(btn "×"
title: "Stäng"
onclick: ""
- class: '("close-tooltip")
- ))
+ class: '("close-tooltip"))
+ ,(btn "🗑"
+ title: "Ta bort"
+ ;; Apparently an id gets recieved
+ ;; as the whole object in js.
+ onclick: (format #f "remove_event(~a)"
+ id)))
,(tabset
(append
diff --git a/static/script.js b/static/script.js
index 27a46ae0..678ff244 100644
--- a/static/script.js
+++ b/static/script.js
@@ -169,6 +169,31 @@ function create_event_finisher (callback) {
}
}
+// for debugging
+let last_xml;
+
+async function remove_event (element) {
+ console.log(element);
+ let xmltext = element.getElementsByClassName("xcal")[0].innerText;
+ let parser = new DOMParser();
+ let xml = parser.parseFromString(xmltext, "text/xml");
+
+ // for debugging
+ last_xml = xml;
+
+ let uid = xml.querySelector("uid").textContent.trim()
+
+ let data = new URLSearchParams();
+ data.append('uid', uid);
+
+ let response = await fetch ( '/remove', {
+ method: 'POST',
+ body: data
+ });
+
+ console.log(response);
+}
+
function time_to_date (time) {
return [ time.getFullYear(),
String(time.getMonth() + 1).padStart(2, '0'),