on master help sign in
Generate HTML that accounts for Elm.Main.init()
commit9e9f4ff37ce968dad291c68036e10a92211560ec authorEvan Czaplicki <evancz@users.noreply.github.com> dateWed 30 May 2018, 13:29 (8 years ago) parent3d86d3c
1 file changed+6−17
builder/src/Generate/Html.hs+6−17
builder/src/Generate/Html.hs+6−17
@@ -28,26 +28,15 @@ sandwich moduleName javascript =
2828</head>
2929
3030<body>
31−<div id="embed"></div>
31+<div id="elm-f0111bc4e658d0f98db96260c16f7e49"></div>
3232<script>
3333|] <> javascript <> [r|
3434
35−// It is too complicated to figure out which kind of Program you created
36−// based on only the code. So here we check for different possibilities.
37−//
38−// When you embed compiled Elm into HTML yourself, you should not copy/paste
39−// from here. Do just the part that makes sense for your application!
40−//
41−var app =
42− Elm.|] <> name <> [r|.fullscreen
43− ? Elm.|] <> name <> [r|.fullscreen()
44− :
45− Elm.|] <> name <> [r|.embed
46− ? Elm.|] <> name <> [r|.embed(document.getElementById('embed'))
47− :
48− Elm.|] <> name <> [r|.worker
49− ? (document.getElementById('embed').innerText = 'This is a headless program, meaning there is nothing to show here. I started the program anyway though, and you can access it as `app` in the developer console.', Elm.|] <> name <> [r|.worker())
50− : (document.getElementById('embed').innerText = 'I cannot figure out what kind of program this is supposed to be. Perhaps someone on Slack can help?', undefined);
35+var app = Elm.|] <> name <> [r|.init({ node: document.getElementById("elm-f0111bc4e658d0f98db96260c16f7e49") });
36+if (document.getElementById("elm-f0111bc4e658d0f98db96260c16f7e49"))
37+{
38+ document.getElementById("elm-f0111bc4e658d0f98db96260c16f7e49").innerText = 'This is a headless program, meaning there is nothing to show here.\n\nI started the program anyway though, and you can access it as `app` in the developer console.';
39+}
5140</script>
5241</body>
5342</html>|]