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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SQLite3 Fiddle</title>
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">
<!--
To add a terminal-style view using jquery.terminal[^1],
uncomment the following two HTML lines and ensure that these
files are on the web server.
jquery-bundle.min.js is a concatenation of jquery.min.js from
[^2] and jquery.terminal.min.js from [^1].
jquery.terminal.min.css is from [^1].
[^1]: https://github.com/jcubic/jquery.terminal
[^2]: https://jquery.com
-->
<!--script src="jqterm/jqterm-bundle.min.js"></script>
<link rel="stylesheet" href="jqterm/jquery.terminal.min.css"-->
<style>
/* The following styles are for app-level use. */
:root {
--sqlite-blue: #044a64;
--textarea-color1: #000 /*044a64 is nice too*/;
--textarea-color2: white;
--size: 1.25 /* used by jqterm to calculate font size and the default is too tiny.*/;
}
textarea {
font-family: monospace;
flex: 1 1 auto;
background-color: var(--textarea-color1);
color: var(--textarea-color2);
}
textarea#input {
color: var(--textarea-color1);
background-color: var(--textarea-color2);
}
header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: var(--sqlite-blue);
color: white;
font-size: 120%;
font-weight: bold;
border-radius: 0.25em;
padding: 0.2em 0.5em;
}
header > .powered-by {
font-size: 80%;
}
header a, header a:visited, header a:hover {
color: inherit;
}
#main-wrapper {
display: flex;
flex-direction: column-reverse;
flex: 1 1 auto;
margin: 0.5em 0;
overflow: hidden;
}
#main-wrapper.side-by-side {
flex-direction: row;
}
#main-wrapper.side-by-side > fieldset {
margin-left: 0.25em;
margin-right: 0.25em;
}
#main-wrapper:not(.side-by-side) > fieldset {
margin-bottom: 0.25em;
}
#main-wrapper.swapio {
flex-direction: column;
}
#main-wrapper.side-by-side.swapio {
flex-direction: row-reverse;
}
.zone-wrapper{
display: flex;
margin: 0;
flex: 1 1 0%;
border-radius: 0.5em;
min-width: inherit/*important: resolves inability to scroll fieldset child element!*/;
padding: 0.35em 0 0 0;
}
.zone-wrapper textarea {
border-radius: 0.5em;
flex: 1 1 auto;
/*min/max width resolve an inexplicable margin on the RHS. The -1em
is for the padding, else we overlap the parent boundaries.*/
/*min-width: calc(100% - 1em);
max-width: calc(100% - 1em);
padding: 0 0.5em;*/
}
.zone-wrapper.input { flex: 10 1 auto; }
.zone-wrapper.output { flex: 20 1 auto; }
.zone-wrapper > div {
display:flex;
flex: 1 1 0%;
}
.zone-wrapper.output {}
.button-bar {
display: flex;
flex-wrap: wrap;
align-items: center;
align-content: space-between;
justify-content: flex-start;
}
.button-bar > * {
margin: 0.05em 0.5em 0.05em 0;
flex: 0 1 auto;
align-self: auto;
}
label[for] {
cursor: pointer;
}
.error {
color: red;
background-color: yellow;
}
.hidden, .initially-hidden {
position: absolute !important;
opacity: 0 !important;
pointer-events: none !important;
display: none !important;
}
fieldset {
border-radius: 0.5em;
border: 1px inset;
padding: 0.25em;
}
fieldset.options {
font-size: 80%;
margin-top: 0.5em;
}
fieldset:not(.options) > legend {
font-size: 80%;
}
fieldset.options > div {
display: flex;
flex-wrap: wrap;
}
fieldset button {
font-size: inherit;
}
fieldset.collapsible > legend > .fieldset-toggle::after {
content: " [hide]";
position: relative;
}
fieldset.collapsible.collapsed > legend > .fieldset-toggle::after {
content: " [show]";
position: relative;
}
span.labeled-input {
padding: 0.25em;
margin: 0.05em 0.25em;
border-radius: 0.25em;
white-space: nowrap;
background: #0002;
display: flex;
align-items: center;
}
span.labeled-input > *:nth-child(2) {
margin-left: 0.3em;
}
.center { text-align: center; }
body.terminal-mode {
max-height: calc(100% - 2em);
display: flex;
flex-direction: column;
align-items: stretch;
}
#view-terminal {}
.app-view {
flex: 20 1 auto;
}
#view-split {
display: flex;
flex-direction: column-reverse;
}
#view-about {
flex: auto;
overflow: auto;
}
#view-about h1:first-child {
display: flex;
}
#view-about h1:first-child > button {
align-self: center;
margin-left: 1em;
}
/* emcscript-related styling, used during the module load/intialization processes... */
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
div.emscripten { text-align: center; }
div.emscripten_border { border: 1px solid black; }
#module-spinner { overflow: visible; }
#module-spinner > * {
margin-top: 1em;
}
.spinner {
height: 50px;
width: 50px;
margin: 0px auto;
animation: rotation 0.8s linear infinite;
border-left: 10px solid rgb(0,150,240);
border-right: 10px solid rgb(0,150,240);
border-bottom: 10px solid rgb(0,150,240);
border-top: 10px solid rgb(100,0,200);
border-radius: 100%;
background-color: rgb(200,100,250);
}
@keyframes rotation {
from {transform: rotate(0deg);}
to {transform: rotate(360deg);}
}
</style>
</head>
<body>
<header id='titlebar'>
<span>SQLite3 Fiddle</span>
<span id='titlebar-buttons'>
<span class='powered-by'>Powered by
<a href='https://sqlite.org'>SQLite3</a></span>
</span>
</header>
<!-- emscripten bits -->
<figure id="module-spinner">
<div class="spinner"></div>
<div class='center'><strong>Initializing app...</strong></div>
<div class='center'>
On a slow internet connection this may take a moment. If this
message displays for "a long time", intialization may have
failed and the JavaScript console may contain clues as to why.
</div>
</figure>
<div class="emscripten" id="module-status">Downloading...</div>
<div class="emscripten">
<progress value="0" max="100" id="module-progress" hidden='1'></progress>
</div><!-- /emscripten bits -->
<div id='view-terminal' class='app-view hidden initially-hidden'>
This is a placeholder for a terminal-like view which is not in
the default build.
</div>
<div id='view-split' class='app-view initially-hidden'>
<div id='main-wrapper' class=''>
<fieldset class='zone-wrapper input'>
<legend><div class='button-bar'>
<button id='btn-shell-exec'>Run</button>
<button id='btn-clear'>Clear Input</button>
<!--button data-cmd='.help'>Help</button-->
<select id='select-examples'></select>
</div></legend>
<div><textarea id="input"
placeholder="Shell input. Ctrl-enter/shift-enter runs it.">
-- ==================================================
-- Use ctrl-enter or shift-enter to execute sqlite3
-- shell commands and SQL.
-- If a subset of the text is currently selected,
-- only that part is executed.
-- ==================================================
.nullvalue NULL
.headers on
</textarea></div>
</fieldset>
<fieldset class='zone-wrapper output'>
<legend><div class='button-bar'>
<button id='btn-clear-output'>Clear Output</button>
<button id='btn-interrupt' class='hidden' disabled>Interrupt</button>
<!-- interruption cannot work in the current configuration
because we cannot send an interrupt message when work
is currently underway. At that point the Worker is
tied up and will not receive the message. -->
</div></legend>
<div><textarea id="output" readonly
placeholder="Shell output."></textarea></div>
</fieldset>
</div><!-- #main-wrapper -->
</div> <!-- #view-split -->
<div class='hidden app-view' id='view-about'>
<h1>About SQLite Fiddle <button id='btn-about-close'>close</button></h1>
<p>Fiddle is a JavaScript application wrapping a <a href='https://webassembly.org'>WebAssembly</a>
build of <a href="https://sqlite.org/cli.html">the SQLite CLI shell</a>, slightly
modified to account for browser-based user input. Aside from the different layout,
it works just like the CLI shell. This copy was built with SQLite version
<a id='sqlite-version-link'></a>.
</p>
<p>This app is provided in the hope that it may prove interesting or useful
but it is not an officially-supported deliverable of the SQLite project.
It is subject to any number of changes or outright removal at any time.
That said, for as long as it's online we do respond to support requests
in <a href="https://sqlite.org/forum">the SQLite forum</a>.
</p>
<p>This app runs on your device. After loading, it does not interact
with the remote server at all. Similarly, this app does not use any
HTTP cookies.</p>
<p>Fiddle databases are transient in-memory databases unless they
specifically use a persistent storage option (if available, help
text in the SQL result output area will indicate how to use
persistent storage when this app starts up).
</p>
<h1>Usage Summary</h1>
<ul>
<li class='hidden unhide-if-terminal-available'>In "terminal
mode" it accepts input just like the CLI shell does.</li>
<li>In split-view mode:
<ul>
<li>Input can be executed with either the Run
button or tapping one of Ctrl-enter or Shift-enter from within
the text input field. If a portion of the input field is
selected, only that portion will be run.
</li>
<li>The various toggle checkboxes can be used to tweak the layout
and behaviors. Those toggles are persistent if the JS environment
allows it.
</li>
</ul>
</li>
<li class='remove-if-terminal-available'>"Terminal mode" is
not available in this deployment.
</li>
<li>Databases can be imported and exported using the buttons in
the Options toolbar. No specific limit for imported database
sizes is imposed, but large databases may cause it to fail with
an out-of-memory error.</li>
<!--li></li-->
</ul>
</div><!-- #view-about -->
<fieldset class='options'>
<legend>Options</legend>
<div class=''>
<span class='labeled-input'>
<input type='file' id='load-db' class='hidden'/>
<button id='btn-load-db'>Load DB...</button>
</span>
<span class='labeled-input'>
<button id='btn-export'>Download DB</button>
</span>
<span class='labeled-input'>
<button id='btn-reset'>Reset DB</button>
</span>
<span id='terminal-button-placeholder' class='hidden'></span>
<span class='labeled-input'>
<button id='btn-about'>About...</button>
</span>
<span class='labeled-input hide-in-terminal'>
<input type='checkbox' id='opt-cb-sbs'
data-csstgt='#main-wrapper'
data-cssclass='side-by-side'
data-config='sideBySide'
>
<label for='opt-cb-sbs'>Side-by-side</label>
</span>
<span class='labeled-input hide-in-terminal'>
<input type='checkbox' id='opt-cb-swapio'
data-csstgt='#main-wrapper'
data-cssclass='swapio'
data-config='swapInOut'
>
<label for='opt-cb-swapio'>Swap in/out</label>
</span>
<span class='labeled-input hide-in-terminal'>
<input type='checkbox' id='opt-cb-autoscroll'
data-config='autoScrollOutput'
>
<label for='opt-cb-autoscroll'>Auto-scroll output</label>
</span>
<span class='labeled-input hide-in-terminal'>
<input type='checkbox' id='opt-cb-autoclear'
data-config='autoClearOutput'>
<label for='opt-cb-autoclear'>Auto-clear output</label>
</span>
</div>
</fieldset><!-- .options -->
<script src="fiddle.js"></script>
</body>
</html>
|