diff options
Diffstat (limited to '')
-rw-r--r-- | static/lib.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/static/lib.js b/static/lib.js index 1d42100c..100f4161 100644 --- a/static/lib.js +++ b/static/lib.js @@ -129,6 +129,24 @@ function asList(thing) { } +function boolean (value) { + switch (typeof value) { + case 'string': + switch (value) { + case 'true': return true; + case 'false': return false; + case '': return false; + default: return true; + } + case 'boolean': + return value; + default: + return !! value; + } +} + + + /* internal */ function datepad(thing, width=2) { return (thing + "").padStart(width, "0"); @@ -159,7 +177,8 @@ function format_date(date, str) { } return outstr; } -Object.prototype.format = function () { return "" + this; } /* any number of arguments */ + +Object.prototype.format = function (/* any number of arguments */) { return "" + this; } Date.prototype.format = function (str) { return format_date (this, str); } /* @@ -176,4 +195,11 @@ DOMTokenList.prototype.find = function (regexp) { } } +/* HTMLCollection is the result of a querySelectorAll */ +HTMLCollection.prototype.forEach = function (proc) { + for (let el of this) { + proc(el); + } +} + const xcal = "urn:ietf:params:xml:ns:icalendar-2.0"; |