mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
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.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user