ref: f97d11df670597136e34f1078d9a2eb2cdbcd85b
parent: b5367ed18ac96f54595fbe6c17fe8a4a897020aa
author: Ben Harris <[email protected]>
date: Mon Aug 21 18:48:59 EDT 2023
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.
--- a/emccpre.js
+++ b/emccpre.js
@@ -85,14 +85,14 @@
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;