From aafc838c0a1e4c08636c950d0d4fa9fe4018e046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 16 Oct 2020 23:03:19 +0200 Subject: Minor JS cleanup. --- static/lib.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'static/lib.js') diff --git a/static/lib.js b/static/lib.js index 3c11e23f..79e48f1e 100644 --- a/static/lib.js +++ b/static/lib.js @@ -131,4 +131,18 @@ function format_date(date, str) { Object.prototype.format = function () { return this; } /* any number of arguments */ Date.prototype.format = function (str) { return format_date (this, str); } +/* + * Finds the first element of the DOMTokenList whichs value matches + * the supplied regexp. Returns a pair of the index and the value. + */ +DOMTokenList.prototype.find = function (regexp) { + let entries = this.entries(); + let entry; + while (! (entry = entries.next()).done) { + if (entry.value[1].match(regexp)) { + return entry.value; + } + } +} + const xcal = "urn:ietf:params:xml:ns:icalendar-2.0"; -- cgit v1.2.3 From cf5a85a73a188cf2608e61bee4a442e975b1a672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 26 Oct 2020 18:10:01 +0100 Subject: Fields for extra properties update correctly! --- static/lib.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'static/lib.js') diff --git a/static/lib.js b/static/lib.js index 79e48f1e..46236411 100644 --- a/static/lib.js +++ b/static/lib.js @@ -3,6 +3,15 @@ General procedures which in theory could be used anywhere. */ +HTMLElement.prototype._addEventListener = HTMLElement.prototype.addEventListener; +HTMLElement.prototype.addEventListener = function (name, proc) { + if (! this.listeners) this.listeners = {}; + if (! this.listeners[name]) this.listeners[name] = []; + this.listeners[name].push(proc); + return this._addEventListener(name, proc); +}; + + /* ----- Date Extensions ---------------------------- */ /* -- cgit v1.2.3 From ffca898a875caa66156b8525d517b87c9b9f5327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 26 Oct 2020 18:14:42 +0100 Subject: Cleanup and move input_list to own file. --- static/lib.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'static/lib.js') diff --git a/static/lib.js b/static/lib.js index 46236411..ab279353 100644 --- a/static/lib.js +++ b/static/lib.js @@ -12,6 +12,16 @@ HTMLElement.prototype.addEventListener = function (name, proc) { }; + +/* list of lists -> list of tuples */ +function zip(...args) { + // console.log(args); + if (args === []) return []; + return [...Array(Math.min(...args.map(x => x.length))).keys()] + .map((_, i) => args.map(lst => lst[i])); +} + + /* ----- Date Extensions ---------------------------- */ /* -- cgit v1.2.3