summaryrefslogtreecommitdiff
path: root/elm/lib.js
blob: 859cfc220e3f649a74254f1f6ed063e21caf7f1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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) };
    }
};