aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-24 17:09:46 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-24 17:09:46 +0200
commitf6c5931e59bead7732e989fbde201aaa29d3005f (patch)
tree3181bbac38297fa77336381216c9d3d491a02ac9
parent/insert endpoint actually saves the events. (diff)
downloadcalp-f6c5931e59bead7732e989fbde201aaa29d3005f.tar.gz
calp-f6c5931e59bead7732e989fbde201aaa29d3005f.tar.xz
Frontend feedback on event creation.
-rw-r--r--static/script.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/static/script.js b/static/script.js
index 822b60c2..6cd6668d 100644
--- a/static/script.js
+++ b/static/script.js
@@ -1,5 +1,7 @@
'use strict';
+let parser = new DOMParser();
+
/* ----- Date Extensions ---------------------------- */
/*
@@ -314,9 +316,39 @@ async function create_event (event) {
});
console.log(response);
+ if (response.status < 200 || response.status >= 300) {
+ alert(`HTTP error ${response.status}\n${response.statusText}`)
+ }
let body = await response.text();
console.log(body);
+
+ /* servere is assumed to return an XML document on the form
+ <properties>
+ **xcal property** ...
+ </properties>
+ parse that, and update our own vevent with the data.
+ */
+
+ let properties = parser
+ .parseFromString(body, 'text/xml')
+ .children[0];
+
+ let child;
+ while ((child = properties.firstChild)) {
+ let target = event.querySelector(
+ "vevent properties " + child.tagName);
+ if (target) {
+ target.replaceWith(child);
+ } else {
+ event.querySelector("vevent properties")
+ .appendChild(child);
+ }
+ }
+
+ event.classList.remove("generated");
+ event.classList.add("CAL_Calendar");
+ toggle_child_popup(event);
}
function place_in_edit_mode (event) {