template.html 7.2 KB

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