aboutsummaryrefslogtreecommitdiff
path: root/static/lib.js
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-10-16 23:03:19 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-10-16 23:03:19 +0200
commitaafc838c0a1e4c08636c950d0d4fa9fe4018e046 (patch)
treec9335f31299cc2397d352c7ee73311f231560503 /static/lib.js
parentHTML add toggle for whole-day. (diff)
downloadcalp-aafc838c0a1e4c08636c950d0d4fa9fe4018e046.tar.gz
calp-aafc838c0a1e4c08636c950d0d4fa9fe4018e046.tar.xz
Minor JS cleanup.
Diffstat (limited to 'static/lib.js')
-rw-r--r--static/lib.js14
1 files changed, 14 insertions, 0 deletions
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";