xref: /aosp_15_r20/external/swiftshader/third_party/marl/examples/shell.emscripten.html (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1<!doctype html>
2<html lang="en-us">
3<head>
4    <meta charset="utf-8">
5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6    <title>Emscripten-Generated Code</title>
7    <style>
8      body {
9        font-family: arial;
10        margin: 0;
11        padding: none;
12      }
13
14      .emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
15      div.emscripten { text-align: center; }
16      div.emscripten_border { border: 1px solid black; }
17
18      #emscripten_logo {
19        display: inline-block;
20        margin: 0;
21      }
22
23      .spinner {
24        height: 30px;
25        width: 30px;
26        margin: 0;
27        margin-top: 20px;
28        margin-left: 20px;
29        display: inline-block;
30        vertical-align: top;
31
32        -webkit-animation: rotation .8s linear infinite;
33        -moz-animation: rotation .8s linear infinite;
34        -o-animation: rotation .8s linear infinite;
35        animation: rotation 0.8s linear infinite;
36
37        border-left: 5px solid rgb(235, 235, 235);
38        border-right: 5px solid rgb(235, 235, 235);
39        border-bottom: 5px solid rgb(235, 235, 235);
40        border-top: 5px solid rgb(120, 120, 120);
41
42        border-radius: 100%;
43        background-color: rgb(189, 215, 46);
44      }
45
46      @-webkit-keyframes rotation {
47        from {-webkit-transform: rotate(0deg);}
48        to {-webkit-transform: rotate(360deg);}
49      }
50      @-moz-keyframes rotation {
51        from {-moz-transform: rotate(0deg);}
52        to {-moz-transform: rotate(360deg);}
53      }
54      @-o-keyframes rotation {
55        from {-o-transform: rotate(0deg);}
56        to {-o-transform: rotate(360deg);}
57      }
58      @keyframes rotation {
59        from {transform: rotate(0deg);}
60        to {transform: rotate(360deg);}
61      }
62
63      #status {
64        display: inline-block;
65        vertical-align: top;
66        margin-top: 30px;
67        margin-left: 20px;
68        font-weight: bold;
69        color: rgb(120, 120, 120);
70      }
71
72      #progress {
73        height: 20px;
74        width: 300px;
75      }
76
77      #controls {
78        display: inline-block;
79        float: right;
80        vertical-align: top;
81        margin-top: 30px;
82        margin-right: 20px;
83      }
84
85      #output {
86        width: 100%;
87        height: 200px;
88        margin: 0 auto;
89        margin-top: 10px;
90        border-left: 0px;
91        border-right: 0px;
92        padding-left: 0px;
93        padding-right: 0px;
94        display: block;
95        background-color: black;
96        color: white;
97        font-family: 'Lucida Console', Monaco, monospace;
98        outline: none;
99      }
100    </style>
101</head>
102<body>
103
104<div class="spinner" id='spinner'></div>
105<div class="emscripten" id="status">Downloading...</div>
106
107<div class="emscripten">
108    <progress value="0" max="100" id="progress" hidden=1></progress>
109</div>
110
111
112<textarea id="output" rows="8"></textarea>
113
114<script type='text/javascript'>
115      var statusElement = document.getElementById('status');
116      var progressElement = document.getElementById('progress');
117      var spinnerElement = document.getElementById('spinner');
118
119      var Module = {
120        preRun: [],
121        postRun: [],
122        print: (function() {
123          var element = document.getElementById('output');
124          if (element) element.value = ''; // clear browser cache
125          return function(text) {
126            if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
127            // These replacements are necessary if you render to raw HTML
128            //text = text.replace(/&/g, "&amp;");
129            //text = text.replace(/</g, "&lt;");
130            //text = text.replace(/>/g, "&gt;");
131            //text = text.replace('\n', '<br>', 'g');
132            console.log(text);
133            if (element) {
134              element.value += text + "\n";
135              element.scrollTop = element.scrollHeight; // focus on bottom
136            }
137          };
138        })(),
139        setStatus: function(text) {
140          if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
141          if (text === Module.setStatus.last.text) return;
142          var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
143          var now = Date.now();
144          if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
145          Module.setStatus.last.time = now;
146          Module.setStatus.last.text = text;
147          if (m) {
148            text = m[1];
149            progressElement.value = parseInt(m[2])*100;
150            progressElement.max = parseInt(m[4])*100;
151            progressElement.hidden = false;
152            spinnerElement.hidden = false;
153          } else {
154            progressElement.value = null;
155            progressElement.max = null;
156            progressElement.hidden = true;
157            if (!text) spinnerElement.style.display = 'none';
158          }
159          statusElement.innerHTML = text;
160        },
161        totalDependencies: 0,
162        monitorRunDependencies: function(left) {
163          this.totalDependencies = Math.max(this.totalDependencies, left);
164          Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
165        }
166      };
167      Module.setStatus('Downloading...');
168      window.onerror = function(event) {
169        // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
170        Module.setStatus('Exception thrown, see JavaScript console');
171        spinnerElement.style.display = 'none';
172        Module.setStatus = function(text) {
173          if (text) console.error('[post-exception status] ' + text);
174        };
175      };
176    </script>
177{{{ SCRIPT }}}
178</body>
179</html>
180