interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / ext / wasm / fiddle / index.c-pp.html

405 lines · 13958 bytes Raw Blame History
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 <title>SQLite3 Fiddle</title>
7 <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
8//#if jqterm
9 <!--
10 To add a terminal-style view using jquery.terminal[^1],
11 uncomment the following two HTML lines and ensure that these
12 files are on the web server.
13
14 jquery.terminal.bundle.min.js is a concatenation of jquery.min.js from
15 [^2] and jquery.terminal.min.js from [^1].
16 jquery.terminal.min.css is from [^1]. Alterntely, jquery-VERSION.min.js
17 can be found in jquery.terminal's source tree.
18
19 Fiddle automatically enables support for this if it's installed.
20
21 In the canonical build process, if the JQTERM env var is set
22 to a dir containing a clone of [^1] then this block gets
23 enabled and a copy of [^1] is integrated automatically.
24
25 [^1]: https://github.com/jcubic/jquery.terminal
26 [^2]: https://jquery.com
27 -->
28 <script src="jqterm/jquery.terminal.bundle.min.js"></script>
29 <link rel="stylesheet" href="jqterm/jquery.terminal.min.css">
30//#/if
31 <style>
32 /* The following styles are for app-level use. */
33 :root {
34 --sqlite-blue: #044a64;
35 --textarea-color1: #000 /*044a64 is nice too*/;
36 --textarea-color2: white;
37 --size: 1.25 /* used by jqterm to calculate font size and the default is too tiny.*/;
38 }
39 textarea {
40 font-family: monospace;
41 flex: 1 1 auto;
42 background-color: var(--textarea-color1);
43 color: var(--textarea-color2);
44 }
45 textarea#input {
46 color: var(--textarea-color1);
47 background-color: var(--textarea-color2);
48 }
49 header {
50 display: flex;
51 justify-content: space-between;
52 align-items: center;
53 background-color: var(--sqlite-blue);
54 color: white;
55 font-size: 120%;
56 font-weight: bold;
57 border-radius: 0.25em;
58 padding: 0.2em 0.5em;
59 }
60 header > .powered-by {
61 font-size: 80%;
62 }
63 header a, header a:visited, header a:hover {
64 color: inherit;
65 }
66 #main-wrapper {
67 display: flex;
68 flex-direction: column-reverse;
69 flex: 1 1 auto;
70 margin: 0.5em 0;
71 overflow: hidden;
72 }
73 #main-wrapper.side-by-side {
74 flex-direction: row;
75 }
76 #main-wrapper.side-by-side > fieldset {
77 margin-left: 0.25em;
78 margin-right: 0.25em;
79 }
80 #main-wrapper:not(.side-by-side) > fieldset {
81 margin-bottom: 0.25em;
82 }
83 #main-wrapper.swapio {
84 flex-direction: column;
85 }
86 #main-wrapper.side-by-side.swapio {
87 flex-direction: row-reverse;
88 }
89 .zone-wrapper{
90 display: flex;
91 margin: 0;
92 flex: 1 1 0%;
93 border-radius: 0.5em;
94 min-width: inherit/*important: resolves inability to scroll fieldset child element!*/;
95 padding: 0.35em 0 0 0;
96 }
97 .zone-wrapper textarea {
98 border-radius: 0.5em;
99 flex: 1 1 auto;
100 /*min/max width resolve an inexplicable margin on the RHS. The -1em
101 is for the padding, else we overlap the parent boundaries.*/
102 /*min-width: calc(100% - 1em);
103 max-width: calc(100% - 1em);
104 padding: 0 0.5em;*/
105 }
106
107 .zone-wrapper.input { flex: 10 1 auto; }
108 .zone-wrapper.output { flex: 20 1 auto; }
109 .zone-wrapper > div {
110 display:flex;
111 flex: 1 1 0%;
112 }
113 .zone-wrapper.output {}
114 .button-bar {
115 display: flex;
116 flex-wrap: wrap;
117 align-items: center;
118 align-content: space-between;
119 justify-content: flex-start;
120 }
121 .button-bar > * {
122 margin: 0.05em 0.5em 0.05em 0;
123 flex: 0 1 auto;
124 align-self: auto;
125 }
126 label[for] {
127 cursor: pointer;
128 }
129 .error {
130 color: red;
131 background-color: yellow;
132 }
133 .hidden, .initially-hidden {
134 position: absolute !important;
135 opacity: 0 !important;
136 pointer-events: none !important;
137 display: none !important;
138 }
139 fieldset {
140 border-radius: 0.5em;
141 border: 1px inset;
142 padding: 0.25em;
143 }
144 fieldset.options {
145 font-size: 80%;
146 margin-top: 0.5em;
147 }
148 fieldset:not(.options) > legend {
149 font-size: 80%;
150 }
151 fieldset.options > div {
152 display: flex;
153 flex-wrap: wrap;
154 }
155 fieldset button {
156 font-size: inherit;
157 }
158 fieldset.collapsible > legend > .fieldset-toggle::after {
159 content: " [hide]";
160 position: relative;
161 }
162 fieldset.collapsible.collapsed > legend > .fieldset-toggle::after {
163 content: " [show]";
164 position: relative;
165 }
166 span.labeled-input {
167 padding: 0.25em;
168 margin: 0.05em 0.25em;
169 border-radius: 0.25em;
170 white-space: nowrap;
171 background: #0002;
172 display: flex;
173 align-items: center;
174 }
175 span.labeled-input > *:nth-child(2) {
176 margin-left: 0.3em;
177 }
178 .center { text-align: center; }
179 body.terminal-mode {
180 max-height: calc(100% - 2em);
181 display: flex;
182 flex-direction: column;
183 align-items: stretch;
184 }
185 #view-terminal {}
186 .app-view {
187 flex: 20 1 auto;
188 }
189 #view-split {
190 display: flex;
191 flex-direction: column-reverse;
192 }
193 #view-about {
194 flex: auto;
195 overflow: auto;
196 }
197 #view-about h1:first-child {
198 display: flex;
199 }
200 #view-about h1:first-child > button {
201 align-self: center;
202 margin-left: 1em;
203 }
204
205 /* emcscript-related styling, used during the module load/intialization processes... */
206 .emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
207 div.emscripten { text-align: center; }
208 div.emscripten_border { border: 1px solid black; }
209 #module-spinner { overflow: visible; }
210 #module-spinner > * {
211 margin-top: 1em;
212 }
213 .spinner {
214 height: 50px;
215 width: 50px;
216 margin: 0px auto;
217 animation: rotation 0.8s linear infinite;
218 border-left: 10px solid rgb(0,150,240);
219 border-right: 10px solid rgb(0,150,240);
220 border-bottom: 10px solid rgb(0,150,240);
221 border-top: 10px solid rgb(100,0,200);
222 border-radius: 100%;
223 background-color: rgb(200,100,250);
224 }
225 @keyframes rotation {
226 from {transform: rotate(0deg);}
227 to {transform: rotate(360deg);}
228 }
229 </style>
230 </head>
231 <body>
232 <header id='titlebar'>
233 <span>SQLite3 Fiddle</span>
234 <span id='titlebar-buttons'>
235 <span class='powered-by'>Powered by
236 <a href='https://sqlite.org'>SQLite3</a></span>
237 </span>
238 </header>
239 <!-- emscripten bits -->
240 <figure id="module-spinner">
241 <div class="spinner"></div>
242 <div class='center'><strong>Initializing app...</strong></div>
243 <div class='center'>
244 On a slow internet connection this may take a moment. If this
245 message displays for "a long time", intialization may have
246 failed and the JavaScript console may contain clues as to why.
247 </div>
248 </figure>
249 <div class="emscripten" id="module-status">Downloading...</div>
250 <div class="emscripten">
251 <progress value="0" max="100" id="module-progress" hidden='1'></progress>
252 </div><!-- /emscripten bits -->
253
254 <div id='view-terminal' class='app-view hidden initially-hidden'>
255 This is a placeholder for a terminal-like view which is not in
256 the default build.
257 </div>
258
259 <div id='view-split' class='app-view initially-hidden'>
260 <div id='main-wrapper' class=''>
261 <fieldset class='zone-wrapper input'>
262 <legend><div class='button-bar'>
263 <button id='btn-shell-exec'>Run</button>
264 <button id='btn-clear'>Clear Input</button>
265 <!--button data-cmd='.help'>Help</button-->
266 <select id='select-examples'></select>
267 </div></legend>
268 <div><textarea id="input"
269 placeholder="Shell input. Ctrl-enter/shift-enter runs it.">
270-- ==================================================
271-- Use ctrl-enter or shift-enter to execute sqlite3
272-- shell commands and SQL.
273-- If a subset of the text is currently selected,
274-- only that part is executed.
275-- ==================================================
276.nullvalue NULL
277.headers on
278</textarea></div>
279 </fieldset>
280 <fieldset class='zone-wrapper output'>
281 <legend><div class='button-bar'>
282 <button id='btn-clear-output'>Clear Output</button>
283 <button id='btn-interrupt' class='hidden' disabled>Interrupt</button>
284 <!-- interruption cannot work in the current configuration
285 because we cannot send an interrupt message when work
286 is currently underway. At that point the Worker is
287 tied up and will not receive the message. -->
288 </div></legend>
289 <div><textarea id="output" readonly
290 placeholder="Shell output."></textarea></div>
291 </fieldset>
292 </div><!-- #main-wrapper -->
293 </div> <!-- #view-split -->
294
295<div class='hidden app-view' id='view-about'>
296 <h1>About SQLite Fiddle <button id='btn-about-close'>close</button></h1>
297
298 <p>Fiddle is a JavaScript application wrapping a <a href='https://webassembly.org'>WebAssembly</a>
299 build of <a href="https://sqlite.org/cli.html">the SQLite CLI shell</a>, slightly
300 modified to account for browser-based user input. Aside from the different layout,
301 it works just like the CLI shell. This copy was built with SQLite version
302 <a id='sqlite-version-link'></a>.
303 </p>
304
305 <p>This app is provided in the hope that it may prove interesting or useful
306 but it is not an officially-supported deliverable of the SQLite project.
307 It is subject to any number of changes or outright removal at any time.
308 That said, for as long as it's online we do respond to support requests
309 in <a href="https://sqlite.org/forum">the SQLite forum</a>.
310 </p>
311
312 <p>This app runs on your device. After loading, it does not interact
313 with the remote server at all. Similarly, this app does not use any
314 HTTP cookies.</p>
315
316 <p>Fiddle databases are transient in-memory databases unless they
317 specifically use a persistent storage option (if available, help
318 text in the SQL result output area will indicate how to use
319 persistent storage when this app starts up).
320 </p>
321
322 <h1>Usage Summary</h1>
323
324 <ul>
325 <li class='hidden unhide-if-terminal-available'>In
326 <a href="https://github.com/jcubic/jquery.terminal">"terminal
327 mode"</a> it accepts input just like the CLI shell does.</li>
328 <li>In split-view mode:
329 <ul>
330 <li>Input can be executed with either the Run
331 button or tapping one of Ctrl-enter or Shift-enter from within
332 the text input field. If a portion of the input field is
333 selected, only that portion will be run.
334 </li>
335 <li>The various toggle checkboxes can be used to tweak the layout
336 and behaviors. Those toggles are persistent if the JS environment
337 allows it.
338 </li>
339 </ul>
340 </li>
341 <li class='remove-if-terminal-available'>"Terminal mode" is
342 not available in this deployment.
343 </li>
344 <li>Databases can be imported and exported using the buttons in
345 the Options toolbar. No specific limit for imported database
346 sizes is imposed, but large databases may cause it to fail with
347 an out-of-memory error.</li>
348 <!--li></li-->
349 </ul>
350
351</div><!-- #view-about -->
352
353<fieldset class='options'>
354 <legend>Options</legend>
355 <div class=''>
356 <span class='labeled-input'>
357 <input type='file' id='load-db' class='hidden'/>
358 <button id='btn-load-db'>Load DB...</button>
359 </span>
360 <span class='labeled-input'>
361 <button id='btn-export'>Download DB</button>
362 </span>
363 <span class='labeled-input'>
364 <button id='btn-reset'>Reset DB</button>
365 </span>
366 <span id='terminal-button-placeholder' class='hidden'></span>
367 <span class='labeled-input'>
368 <button id='btn-about'>About...</button>
369 </span>
370 <span class='labeled-input hide-in-terminal'>
371 <input type='checkbox' id='opt-cb-sbs'
372 data-csstgt='#main-wrapper'
373 data-cssclass='side-by-side'
374 data-config='sideBySide'
375 >
376 <label for='opt-cb-sbs'>Side-by-side</label>
377 </span>
378 <span class='labeled-input hide-in-terminal'>
379 <input type='checkbox' id='opt-cb-swapio'
380 data-csstgt='#main-wrapper'
381 data-cssclass='swapio'
382 data-config='swapInOut'
383 >
384 <label for='opt-cb-swapio'>Swap in/out</label>
385 </span>
386 <span class='labeled-input hide-in-terminal'>
387 <input type='checkbox' id='opt-cb-autoscroll'
388 data-config='autoScrollOutput'
389 >
390 <label for='opt-cb-autoscroll'>Auto-scroll output</label>
391 </span>
392 <span class='labeled-input hide-in-terminal'>
393 <input type='checkbox' id='opt-cb-autoclear'
394 data-config='autoClearOutput'>
395 <label for='opt-cb-autoclear'>Auto-clear output</label>
396 </span>
397 <span class='labeled-input'>
398 <span id='opt-wasm-info'>WASM: ???</span>
399 </span>
400 </div>
401</fieldset><!-- .options -->
402
403<script src="fiddle.js"></script>
404 </body>
405</html>