template.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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: fixed;
  66. bottom: 0;
  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: fixed;
  113. bottom: 0;
  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. }
  121. #source-code:hover,
  122. #source-code:focus-within {
  123. top: 50%;
  124. }
  125. #source-code:focus-within {
  126. border-top: 2px solid orange;
  127. }
  128. #source-code:focus-within::before {
  129. border: 2px solid orange;
  130. border-bottom: none;
  131. }
  132. #source-code-contents {
  133. height: 100%;
  134. overflow: scroll;
  135. }
  136. @media (prefers-color-scheme: dark) {
  137. main > #sidebar {
  138. border-color: rgba(48, 54, 61, 0.7);
  139. }
  140. }
  141. @media only screen and (max-width: 992px) {
  142. main {
  143. flex-direction: column;
  144. }
  145. main > #sidebar {
  146. border: none;
  147. }
  148. }
  149. </style>
  150. <link rel="stylesheet" type="text/css" href="highlight.css">
  151. </head>
  152. <body>
  153. <header>
  154. <a href="/">SDL Examples</a>
  155. </header>
  156. <main>
  157. <div id="content">
  158. <nav class="breadcrumb">
  159. <ul>
  160. <li><a href="/@project_name@">@project_name@</a></li>
  161. <li><a href="/@project_name@/@category_name@">@category_name@</a></li>
  162. <li><a href="/@project_name@/@category_name@/@example_name@">@example_name@</a></li>
  163. </ul>
  164. </nav>
  165. <h1>@project_name@ example: @category_name@/@example_name@</h1>
  166. <div id="example-description">@description@</div>
  167. <div class="canvas-container">
  168. <canvas
  169. id="canvas"
  170. oncontextmenu="event.preventDefault()"
  171. tabindex="-1"
  172. ></canvas>
  173. </div>
  174. </div>
  175. <div id="sidebar">
  176. <h3>Other examples:</h3>
  177. @other_examples_html@
  178. </div>
  179. </main>
  180. <div id="output-container">
  181. <textarea id="output" rows="8" spellcheck="false" readonly></textarea>
  182. </div>
  183. <div id="source-code" tabindex="1">
  184. <div id="source-code-contents">@htmlified_source_code@</div>
  185. </div>
  186. <script type='text/javascript'>
  187. var Module = {
  188. preRun: [],
  189. postRun: [],
  190. print: (function() {
  191. var element = document.getElementById('output');
  192. if (element) element.value = ''; // clear browser cache
  193. return function(text) {
  194. var elem = document.getElementById('output-container');
  195. if (elem.style['top'] == '') {
  196. elem.style['top'] = '50%';
  197. setTimeout(function() { elem.style['top'] = ''; }, 3000);
  198. }
  199. if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
  200. // These replacements are necessary if you render to raw HTML
  201. //text = text.replace(/&/g, "&amp;");
  202. //text = text.replace(/</g, "&lt;");
  203. //text = text.replace(/>/g, "&gt;");
  204. //text = text.replace('\n', '<br>', 'g');
  205. console.log(text);
  206. if (element) {
  207. element.value += text + "\n";
  208. element.scrollTop = element.scrollHeight; // focus on bottom
  209. }
  210. };
  211. })(),
  212. printErr: function(text) { Module.print(text) },
  213. canvas: (() => {
  214. var canvas = document.getElementById('canvas');
  215. // As a default initial behavior, pop up an alert when webgl context is lost. To make your
  216. // application robust, you may want to override this behavior before shipping!
  217. // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
  218. canvas.addEventListener("webglcontextlost", (e) => { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
  219. return canvas;
  220. })(),
  221. setStatus: (text) => {},
  222. totalDependencies: 0,
  223. monitorRunDependencies: (left) => {
  224. this.totalDependencies = Math.max(this.totalDependencies, left);
  225. Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
  226. }
  227. };
  228. Module.setStatus('Downloading...');
  229. window.onerror = (event) => {
  230. // TODO: do not warn on ok events like simulating an infinite loop or exitStatus
  231. Module.setStatus('Exception thrown, see JavaScript console');
  232. Module.setStatus = (text) => {
  233. if (text) console.error('[post-exception status] ' + text);
  234. };
  235. };
  236. </script>
  237. <script async type="text/javascript" src="@javascript_file@"></script>
  238. </body>
  239. </html>