summaryrefslogtreecommitdiff
path: root/elm/lib.js
diff options
context:
space:
mode:
Diffstat (limited to 'elm/lib.js')
-rw-r--r--elm/lib.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/elm/lib.js b/elm/lib.js
new file mode 100644
index 00000000..859cfc22
--- /dev/null
+++ b/elm/lib.js
@@ -0,0 +1,15 @@
+//order:0 - Before anything else that may use these functions.
+
+/* Load global page-wide variables from <script id="pagevars">...</script> and store them into window.pageVars */
+var e = document.getElementById('pagevars');
+window.pageVars = e ? JSON.parse(e.innerHTML) : {};
+
+
+// Utlity function to wrap the init() function of an Elm module.
+window.wrap_elm_init = function(mod, newinit) {
+ mod = mod.split('.').reduce(function(p, c) { return p ? p[c] : null }, window.Elm);
+ if(mod) {
+ var oldinit = mod.init;
+ mod.init = function(opt) { newinit(oldinit, opt) };
+ }
+};