aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-01-12 21:05:13 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-01-12 21:05:13 +0100
commit0cefcb7ea6306d92faa0aee12a46761e92118b41 (patch)
tree4bc590dd46ea53b1a64a760aff43fbc706156e76 /static
parentjcal_to_xcal now works. (diff)
downloadcalp-0cefcb7ea6306d92faa0aee12a46761e92118b41.tar.gz
calp-0cefcb7ea6306d92faa0aee12a46761e92118b41.tar.xz
Can create event with new interface.
Diffstat (limited to 'static')
-rw-r--r--static/server_connect.js43
1 files changed, 29 insertions, 14 deletions
diff --git a/static/server_connect.js b/static/server_connect.js
index 6c4e4496..e86fc36e 100644
--- a/static/server_connect.js
+++ b/static/server_connect.js
@@ -32,11 +32,13 @@ async function create_event (event) {
data.append("cal", calendar);
// data.append("data", xml);
+ console.log(event);
+
+ let properties = [];
+
for (let prop of event.properties.ical_properties) {
let v = event.properties[prop];
if (v !== undefined) {
- [prop, {}, /*type*/, v];
- /* TODO , here */
let type = 'text';
let value;
@@ -49,7 +51,7 @@ async function create_event (event) {
} else {
type = 'date-time';
/* TODO TZ */
- value = v.format("~Y-~m~dT~H:~M:~S");
+ value = v.format("~Y-~m-~dT~H:~M:~S");
}
} else if (v === true || v === false) {
type = 'boolean';
@@ -58,33 +60,46 @@ async function create_event (event) {
/* TODO float or integer */
type = 'integer';
value = v;
+ } else if (v instanceof RRule) {
+ type = 'recur';
+ value = v.asJcal();
}
/* TODO period */
- /* TODO recur */
else {
/* text types */
+ value = v;
}
+ properties.push([prop, {}, type, value]);
}
}
let jcal =
['vcalendar',
- ['vevent',
- [
- ['summary', {}, 'text', 'Example summary'],
- ],
- []
- ]
+ [
+ /*
+ 'prodid' and 'version' are technically both required (RFC 5545,
+ 3.6 Calendar Components).
+ */
+ ],
+ [
+ /* vtimezone goes here */
+ ['vevent', properties, [/* alarms go here */]],]
];
+ console.log(jcal);
+ console.log(properties);
+
let doc = jcal_to_xcal(jcal);
console.log(doc);
+ let str = doc.childNodes[0].outerHTML;
+ console.log(str);
+ data.append("data", str);
- console.log(event.properties);
+ // console.log(event.properties);
- return;
+ // return;
let response = await fetch ( '/insert', {
method: 'POST',
@@ -108,12 +123,12 @@ async function create_event (event) {
*/
let parser = new DOMParser();
- let properties = parser
+ let return_properties = parser
.parseFromString(body, 'text/xml')
.children[0];
let child;
- while ((child = properties.firstChild)) {
+ while ((child = return_properties.firstChild)) {
let target = event.querySelector(
"vevent properties " + child.tagName);
if (target) {