diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-08-21 22:48:59 +0100 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-08-21 23:06:39 +0100 |
| commit | f97d11df670597136e34f1078d9a2eb2cdbcd85b (patch) | |
| tree | daa7da01d66d64a204d8020f020fabc286505b2e | |
| parent | b5367ed18ac96f54595fbe6c17fe8a4a897020aa (diff) | |
| download | puzzles-f97d11df670597136e34f1078d9a2eb2cdbcd85b.zip puzzles-f97d11df670597136e34f1078d9a2eb2cdbcd85b.tar.gz puzzles-f97d11df670597136e34f1078d9a2eb2cdbcd85b.tar.bz2 puzzles-f97d11df670597136e34f1078d9a2eb2cdbcd85b.tar.xz | |
js: allow for multiple environment blocks in HTML
Not that I actually need it, but it's just as easy to load multiple
environment <script>s from the DOM as it is to load one, so we may as
well do that. Since only one element can have id="environment", we do
this by matching class="environment" as well.
| -rw-r--r-- | emccpre.js | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -85,14 +85,14 @@ var colours = []; var Module = { 'preRun': function() { - // Merge environment variables from HTML script element. + // Merge environment variables from HTML script elements. // This means you can add something like this to the HTML: // <script id="environment" type="application/json"> // { "LOOPY_DEFAULT": "20x10t11dh" } // </script> - var envscript = document.getElementById("environment"); - var k, v; - if (envscript !== null) + var envscript, k, v; + for (envscript of document.querySelectorAll( + "script#environment, script.environment")) for ([k, v] of Object.entries(JSON.parse(envscript.textContent))) ENV[k] = v; |