Browse code

Toolchain setup scripts and skeleton of demo Makefile

Dario Rodriguez authored on 16/06/2023 20:22:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,109 @@
1
+<!doctype html>
2
+<html>
3
+<head>
4
+<meta charset="utf-8">
5
+<title>PROGRAMNAME</title>
6
+<style>
7
+html, body 
8
+{
9
+ height: 100%;
10
+}
11
+
12
+body {
13
+ background-color: #000;
14
+ margin: 0 0 0 0 !important;
15
+}
16
+
17
+#canvas {
18
+padding-right: 0;
19
+margin-left: auto;
20
+margin-right: auto;
21
+display: block;
22
+border: 0px none;
23
+width: 100vw;
24
+height: 100%;
25
+}
26
+</style>
27
+</head>
28
+<body>
29
+<div class="spinner" id='spinner'></div>
30
+<div class="emscripten" id="status">PROGRAMNAME: Downloading...</div>
31
+<progress value="0" max="100" id="progress" hidden=1></progress>
32
+<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
33
+
34
+    <script type='text/javascript'>
35
+      var statusElement = document.getElementById('status');
36
+      var progressElement = document.getElementById('progress');
37
+      var spinnerElement = document.getElementById('spinner');
38
+
39
+      var Module = {
40
+        preRun: [],
41
+        postRun: [],
42
+        print: (function() {
43
+          var element = document.getElementById('output');
44
+          if (element) element.value = ''; // clear browser cache
45
+          return function(text) {
46
+            if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
47
+            // These replacements are necessary if you render to raw HTML
48
+            //text = text.replace(/&/g, "&amp;");
49
+            //text = text.replace(/</g, "&lt;");
50
+            //text = text.replace(/>/g, "&gt;");
51
+            //text = text.replace('\n', '<br>', 'g');
52
+            console.log(text);
53
+            if (element) {
54
+              element.value += text + "\n";
55
+              element.scrollTop = element.scrollHeight; // focus on bottom
56
+            }
57
+          };
58
+        })(),
59
+        canvas: (function() {
60
+          var canvas = document.getElementById('canvas');
61
+
62
+          // As a default initial behavior, pop up an alert when webgl context is lost. To make your
63
+          // application robust, you may want to override this behavior before shipping!
64
+          // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
65
+          canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
66
+
67
+          return canvas;
68
+        })(),
69
+        setStatus: function(text) {
70
+          if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
71
+          if (text === Module.setStatus.last.text) return;
72
+          var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
73
+          var now = Date.now();
74
+          if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
75
+          Module.setStatus.last.time = now;
76
+          Module.setStatus.last.text = text;
77
+          if (m) {
78
+            text = m[1];
79
+            progressElement.value = parseInt(m[2])*100;
80
+            progressElement.max = parseInt(m[4])*100;
81
+            progressElement.hidden = false;
82
+            spinnerElement.hidden = false;
83
+          } else {
84
+            progressElement.value = null;
85
+            progressElement.max = null;
86
+            progressElement.hidden = true;
87
+            if (!text) spinnerElement.style.display = 'none';
88
+          }
89
+          statusElement.innerHTML = text;
90
+        },
91
+        totalDependencies: 0,
92
+        monitorRunDependencies: function(left) {
93
+          this.totalDependencies = Math.max(this.totalDependencies, left);
94
+          Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
95
+        }
96
+      };
97
+      Module.setStatus('Downloading...');
98
+      window.onerror = function(event) {
99
+        // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
100
+        Module.setStatus('Exception thrown, see JavaScript console');
101
+        spinnerElement.style.display = 'none';
102
+        Module.setStatus = function(text) {
103
+          if (text) console.error('[post-exception status] ' + text);
104
+        };
105
+      };
106
+    </script>
107
+    <script async type="text/javascript" src="PROGRAMNAME.js"></script>
108
+  </body>
109
+</html>