aboutsummaryrefslogtreecommitdiff
path: root/static/script.js
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-12-18 23:18:47 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-12-18 23:18:47 +0100
commit0e1eb02c1a6d596bd1e620b9c9bb13e6c125f5cb (patch)
treefef88b7581e8e3f2b41f739137ad42859e67915c /static/script.js
parentAdd convert entry-point. (diff)
downloadcalp-0e1eb02c1a6d596bd1e620b9c9bb13e6c125f5cb.tar.gz
calp-0e1eb02c1a6d596bd1e620b9c9bb13e6c125f5cb.tar.xz
Start work on jcal system.
Diffstat (limited to '')
-rw-r--r--static/script.js71
1 files changed, 9 insertions, 62 deletions
diff --git a/static/script.js b/static/script.js
index 3a3148b5..596caf6d 100644
--- a/static/script.js
+++ b/static/script.js
@@ -382,7 +382,9 @@ window.onload = function () {
*/
function get_property(el, field, default_value) {
if (! el.properties) {
+ /* TODO only have construction once */
el.properties = {};
+ el.properties.ical_properties = new Set()
}
if (! el.properties["_slot_" + field]) {
@@ -423,6 +425,7 @@ function get_property(el, field, default_value) {
function bind_properties (el, wide_event=false) {
el.properties = {}
+ el.properties.ical_properties = new Set()
let popup = popup_from_event(el);
// let children = el.getElementsByTagName("properties")[0].children;
@@ -523,6 +526,9 @@ function bind_properties (el, wide_event=false) {
}]);
}
+ for (let property of property_names) {
+ el.properties.ical_properties.add(property)
+ }
/* icalendar properties */
for (let child of el.querySelector("vevent > properties").children) {
@@ -531,29 +537,15 @@ function bind_properties (el, wide_event=false) {
let field = child.tagName;
let lst = get_property(el, field);
+ el.properties.ical_properties.add(field)
/* Bind vcomponent fields for this event */
for (let s of el.querySelectorAll(`${field} > :not(parameters)`)) {
- lst.push([s, (s, v) => {
- if (v instanceof Date) {
- if (v.isWholeDay) {
- let str = v.format('~Y-~m-~d');
- child.innerHTML = `<date>${str}</date>`;
- } else {
- let str = v.format('~Y-~m-~dT~H:~M:00~Z');
- child.innerHTML = `<date-time>${str}</date-time>`;
- }
- } else if (v instanceof RRule) {
- child.innerHTML = v.asXcal();
- } else {
- /* assume that type already is correct */
- s.innerHTML = v;
- }
- }]);
-
/* Binds value from XML-tree to javascript object
[parsedate]
+
+ TODO capture xcal type here, to enable us to output it to jcal later.
*/
switch (field) {
case 'rrule':
@@ -565,29 +557,6 @@ function bind_properties (el, wide_event=false) {
}
}
- /* Dynamicly add or remove the <location/> and <description/> elements
- from the <vevent><properties/> list.
-
- TODO generalize this to all fields, /especially/ those which are
- dynamicly added.
- */
- for (let field of ['location', 'description', 'categories']) {
- get_property(el, field).push(
- [el.querySelector('vevent > properties'),
- (s, v) => {
- let slot = s.querySelector(field);
- if (v === '' && slot) {
- slot.remove();
- } else {
- if (! slot) {
- /* finns det verkligen inget bättre sätt... */
- s.innerHTML += `<${field}><text/></${field}>`;
- }
- s.querySelector(`${field} > text`).innerHTML = v;
- }
- }]);
- }
-
/* set up graphical display changes */
let container = el.closest(".event-container");
if (container === null) {
@@ -617,28 +586,6 @@ function bind_properties (el, wide_event=false) {
}
- /* Update XML on rrule field change */
- if (el.properties.rrule) {
- for (let f of el.properties.rrule.fields) {
- el.properties.rrule.addListener(
- f, v => {
- console.log(v);
- let recur = el.querySelector('rrule recur');
- let field = recur.querySelector(f);
- if (field) {
- if (! v) {
- field.remove();
- } else {
- field.innerHTML = v;
- }
- } else {
- if (v) recur.innerHTML += `<${f}>${v}</${f}>`;
- }
- });
- }
- }
-
-
/* ---------- Calendar ------------------------------ */
if (! el.dataset.calendar) {