template.html 7.2 KB

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