git.iko.soy/typeable/elm-ui
on master help sign in
rename index.html to run.html to better capture what it does
commit7e387f08c6e5d16050d4a0b5445e31bfbbf100d0 authorMatthew Griffith <mdg.griffith@gmail.com> dateFri 5 Jul 2019, 11:48 (7 years ago) parent7b6fc3e
2 files changed+40−2
benchmarks/runtime/index.js+2−2 benchmarks/runtime/template/run.html+38
benchmarks/runtime/index.js+2−2
@@ -102,11 +102,11 @@ async function write_results(allResults) {
102102 for (var i = 0; i < instances.length; i++) {
103103 var item = instances[i]
104104 write_entrypoint(item)
105− var template = fs.readFileSync("./runtime/template/index.html")
105+ var template = fs.readFileSync("./runtime/template/run.html")
106106 // we embed the compiled js to avoid having to start a server to read the app.
107107 await compileToString(["./tmp/Main.elm"], { optimize: true }).then(function (compiled_elm_code) {
108108 const compiled = eval(`\`${template}\``)
109− fs.writeFileSync("./tmp/index.html", compiled)
109+ fs.writeFileSync("./tmp/run.html", compiled)
110110 });
111111
112112 const page = await browser.newPage();
benchmarks/runtime/template/run.htmlnew file+38
@@ -0,0 +1,38 @@
1+<!DOCTYPE HTML>
2+<html>
3+<head>
4+ <meta charset="UTF-8">
5+ <title>Main</title>
6+ <script>
7+ ${compiled_elm_code}
8+ </script>
9+</head>
10+
11+<body>
12+ <div id="elm"></div>
13+ <script>
14+ var app = Elm.Main.init({
15+ node: document.getElementById('elm')
16+ });
17+
18+ window.metrics = []
19+ app.ports.elmToWorld.subscribe(function(fromElm){
20+ window.metrics = fromElm
21+ })
22+
23+ function elmRefresh(){
24+ app.ports.worldToElm.send({tag: "Refresh"})
25+ }
26+ function elmStartAnim(){
27+ app.ports.worldToElm.send({tag: "StartAnim"})
28+ }
29+ function elmStopAnim(){
30+ app.ports.worldToElm.send({tag: "StopAnim"})
31+ }
32+ window.elmRefresh = elmRefresh;
33+ window.elmStartAnim = elmStartAnim;
34+ window.elmStopAnim = elmStopAnim;
35+
36+ </script>
37+</body>
38+</html>