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