template.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. body {
  9. font-family: arial;
  10. margin: 0;
  11. padding: none;
  12. }
  13. .emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
  14. div.emscripten { text-align: center; }
  15. div.emscripten_border { border: 1px solid black; }
  16. /* the canvas *must not* have any border or padding, or mouse coords will be wrong */
  17. canvas.emscripten { border: 0px none; background-color: black; }
  18. @-webkit-keyframes rotation {
  19. from {-webkit-transform: rotate(0deg);}
  20. to {-webkit-transform: rotate(360deg);}
  21. }
  22. @-moz-keyframes rotation {
  23. from {-moz-transform: rotate(0deg);}
  24. to {-moz-transform: rotate(360deg);}
  25. }
  26. @-o-keyframes rotation {
  27. from {-o-transform: rotate(0deg);}
  28. to {-o-transform: rotate(360deg);}
  29. }
  30. @keyframes rotation {
  31. from {transform: rotate(0deg);}
  32. to {transform: rotate(360deg);}
  33. }
  34. #output {
  35. width: 100%;
  36. height: 200px;
  37. margin: 0 auto;
  38. margin-top: 10px;
  39. border-left: 0px;
  40. border-right: 0px;
  41. padding-left: 0px;
  42. padding-right: 0px;
  43. display: none;
  44. background-color: black;
  45. color: white;
  46. font-family: 'Lucida Console', Monaco, monospace;
  47. outline: none;
  48. }
  49. .source_code {
  50. }
  51. </style>
  52. <link rel="stylesheet" type="text/css" href="highlight.css">
  53. </head>
  54. <body>
  55. <div class="emscripten_border">
  56. <canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
  57. </div>
  58. <textarea id="output" rows="8"></textarea>
  59. <div class="source_code">@htmlified_source_code@</div>
  60. <script type='text/javascript'>
  61. var Module = {
  62. preRun: [],
  63. postRun: [],
  64. print: (function() {
  65. var element = document.getElementById('output');
  66. if (element) element.value = ''; // clear browser cache
  67. return function(text) {
  68. if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
  69. // These replacements are necessary if you render to raw HTML
  70. //text = text.replace(/&/g, "&amp;");
  71. //text = text.replace(/</g, "&lt;");
  72. //text = text.replace(/>/g, "&gt;");
  73. //text = text.replace('\n', '<br>', 'g');
  74. console.log(text);
  75. if (element) {
  76. element.value += text + "\n";
  77. element.scrollTop = element.scrollHeight; // focus on bottom
  78. }
  79. };
  80. })(),
  81. canvas: (() => {
  82. var canvas = document.getElementById('canvas');
  83. // As a default initial behavior, pop up an alert when webgl context is lost. To make your
  84. // application robust, you may want to override this behavior before shipping!
  85. // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
  86. canvas.addEventListener("webglcontextlost", (e) => { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
  87. return canvas;
  88. })(),
  89. setStatus: (text) => {},
  90. totalDependencies: 0,
  91. monitorRunDependencies: (left) => {
  92. this.totalDependencies = Math.max(this.totalDependencies, left);
  93. Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
  94. }
  95. };
  96. Module.setStatus('Downloading...');
  97. window.onerror = (event) => {
  98. // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
  99. Module.setStatus('Exception thrown, see JavaScript console');
  100. Module.setStatus = (text) => {
  101. if (text) console.error('[post-exception status] ' + text);
  102. };
  103. };
  104. </script>
  105. <script async type="text/javascript" src="index.js"></script>
  106. </body>
  107. </html>