template.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. </style>
  113. <link rel="stylesheet" type="text/css" href="highlight.css">
  114. </head>
  115. <body>
  116. <div class="canvas-container">
  117. <canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
  118. </div>
  119. <div id="output-container">
  120. <textarea id="output" rows="8" spellcheck="false" readonly></textarea>
  121. </div>
  122. <div id="source-code" tabindex="1">
  123. <div id="source-code-contents">@htmlified_source_code@</div>
  124. </div>
  125. <script type='text/javascript'>
  126. var Module = {
  127. preRun: [],
  128. postRun: [],
  129. print: (function() {
  130. var element = document.getElementById('output');
  131. if (element) element.value = ''; // clear browser cache
  132. return function(text) {
  133. var elem = document.getElementById('output-container');
  134. if (elem.style['top'] == '') {
  135. elem.style['top'] = '50%';
  136. setTimeout(function() { elem.style['top'] = ''; }, 3000);
  137. }
  138. if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
  139. // These replacements are necessary if you render to raw HTML
  140. //text = text.replace(/&/g, "&amp;");
  141. //text = text.replace(/</g, "&lt;");
  142. //text = text.replace(/>/g, "&gt;");
  143. //text = text.replace('\n', '<br>', 'g');
  144. console.log(text);
  145. if (element) {
  146. element.value += text + "\n";
  147. element.scrollTop = element.scrollHeight; // focus on bottom
  148. }
  149. };
  150. })(),
  151. printErr: function(text) { Module.print(text) },
  152. canvas: (() => {
  153. var canvas = document.getElementById('canvas');
  154. // As a default initial behavior, pop up an alert when webgl context is lost. To make your
  155. // application robust, you may want to override this behavior before shipping!
  156. // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
  157. canvas.addEventListener("webglcontextlost", (e) => { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
  158. return canvas;
  159. })(),
  160. setStatus: (text) => {},
  161. totalDependencies: 0,
  162. monitorRunDependencies: (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 = (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. Module.setStatus = (text) => {
  172. if (text) console.error('[post-exception status] ' + text);
  173. };
  174. };
  175. </script>
  176. <script async type="text/javascript" src="@javascript_file@"></script>
  177. </body>
  178. </html>