template.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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>@project_name@ Example: @category_name@/@example_name@</title>
  7. <style>
  8. html, body {
  9. width: 100vw;
  10. height: 100vh;
  11. overflow: hidden;
  12. font-family: 'Liberation Sans', sans-serif;
  13. }
  14. .canvas-container {
  15. position: absolute;
  16. top: 0;
  17. left: 0;
  18. right: 0;
  19. bottom: 0;
  20. display: flex;
  21. align-items: center;
  22. justify-content: center;
  23. background: black;
  24. }
  25. #canvas {
  26. box-shadow: 0 0 0.5rem #7787;
  27. }
  28. #output-container {
  29. position: absolute;
  30. top: 100%;
  31. left: 0;
  32. right: 0;
  33. bottom: 0;
  34. background-color: black;
  35. border: none;
  36. border-top: 1px solid #778;
  37. margin: 0;
  38. padding: 1rem;
  39. transition: top 0.25s;
  40. }
  41. #output-container::before {
  42. position: absolute;
  43. bottom: 100%;
  44. right: 1rem;
  45. content: 'Console';
  46. font-size: 1.5rem;
  47. color: white;
  48. background: black;
  49. border: 1px solid #778;
  50. border-bottom: none;
  51. padding: 0.75rem 1.5rem;
  52. border-radius: 0.5rem 0.5rem 0 0;
  53. }
  54. #output-container:hover,
  55. #output-container:focus-within {
  56. top: 50%;
  57. }
  58. #output-container:focus-within {
  59. border-top: 2px solid orange;
  60. }
  61. #output-container:focus-within::before {
  62. border: 2px solid orange;
  63. border-bottom: none;
  64. }
  65. #output {
  66. width: 100%;
  67. height: 100%;
  68. padding: 0;
  69. margin: 0;
  70. border: none;
  71. background: black;
  72. color: white;
  73. outline: none;
  74. resize: none;
  75. font-family: 'Lucida Console', Monaco, monospace;
  76. }
  77. #source-code {
  78. position: absolute;
  79. top: 100%;
  80. left: 0;
  81. right: 0;
  82. bottom: 0;
  83. background: #e0eaee;
  84. padding: 1rem;
  85. transition: top 0.25s;
  86. }
  87. #source-code::before {
  88. position: absolute;
  89. bottom: 100%;
  90. left: 1rem;
  91. content: 'Source code';
  92. font-size: 1.5rem;
  93. background: linear-gradient(to bottom, #789, #e0eaee);
  94. padding: 0.75rem 1.5rem;
  95. border-radius: 0.5rem 0.5rem 0 0;
  96. }
  97. #source-code:hover,
  98. #source-code:focus-within {
  99. top: 50%;
  100. }
  101. #source-code:focus-within {
  102. border-top: 2px solid orange;
  103. }
  104. #source-code:focus-within::before {
  105. border: 2px solid orange;
  106. border-bottom: none;
  107. }
  108. #source-code-contents {
  109. height: 100%;
  110. overflow: scroll;
  111. }
  112. #example-description {
  113. color: white;
  114. text-align: center;
  115. position: relative; /* required for proper positioning */
  116. }
  117. </style>
  118. <link rel="stylesheet" type="text/css" href="highlight.css">
  119. </head>
  120. <body>
  121. <div class="canvas-container">
  122. <canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
  123. </div>
  124. <div id="example-description">
  125. @description@
  126. </div>
  127. <div id="output-container">
  128. <textarea id="output" rows="8" spellcheck="false" readonly></textarea>
  129. </div>
  130. <div id="source-code" tabindex="1">
  131. <div id="source-code-contents">@htmlified_source_code@</div>
  132. </div>
  133. <script type='text/javascript'>
  134. var Module = {
  135. preRun: [],
  136. postRun: [],
  137. print: (function() {
  138. var element = document.getElementById('output');
  139. if (element) element.value = ''; // clear browser cache
  140. return function(text) {
  141. var elem = document.getElementById('output-container');
  142. if (elem.style['top'] == '') {
  143. elem.style['top'] = '50%';
  144. setTimeout(function() { elem.style['top'] = ''; }, 3000);
  145. }
  146. if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
  147. // These replacements are necessary if you render to raw HTML
  148. //text = text.replace(/&/g, "&amp;");
  149. //text = text.replace(/</g, "&lt;");
  150. //text = text.replace(/>/g, "&gt;");
  151. //text = text.replace('\n', '<br>', 'g');
  152. console.log(text);
  153. if (element) {
  154. element.value += text + "\n";
  155. element.scrollTop = element.scrollHeight; // focus on bottom
  156. }
  157. };
  158. })(),
  159. printErr: function(text) { Module.print(text) },
  160. canvas: (() => {
  161. var canvas = document.getElementById('canvas');
  162. // As a default initial behavior, pop up an alert when webgl context is lost. To make your
  163. // application robust, you may want to override this behavior before shipping!
  164. // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
  165. canvas.addEventListener("webglcontextlost", (e) => { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
  166. return canvas;
  167. })(),
  168. setStatus: (text) => {},
  169. totalDependencies: 0,
  170. monitorRunDependencies: (left) => {
  171. this.totalDependencies = Math.max(this.totalDependencies, left);
  172. Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
  173. }
  174. };
  175. Module.setStatus('Downloading...');
  176. window.onerror = (event) => {
  177. // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
  178. Module.setStatus('Exception thrown, see JavaScript console');
  179. Module.setStatus = (text) => {
  180. if (text) console.error('[post-exception status] ' + text);
  181. };
  182. };
  183. </script>
  184. <script async type="text/javascript" src="@javascript_file@"></script>
  185. </body>
  186. </html>