aboutsummaryrefslogtreecommitdiff
path: root/static/lib.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/lib.js')
-rw-r--r--static/lib.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/static/lib.js b/static/lib.js
index 3c11e23f..ab279353 100644
--- a/static/lib.js
+++ b/static/lib.js
@@ -3,6 +3,25 @@
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);
+};
+
+
+
+/* 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 ---------------------------- */
/*
@@ -131,4 +150,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";