template.html 8.1 KB

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