-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.html
376 lines (339 loc) · 13.7 KB
/
demo.html
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
<!DOCTYPE HTML>
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-179525394-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-179525394-1');
</script>
<link rel="apple-touch-icon" sizes="180x180" href="images/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
<link rel="manifest" href="images/site.webmanifest">
<title>Seq • Playground</title>
<style type="text/css" media="screen">
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
#cookbook {
height: 250px;
overflow: auto;
}
div.cookbook-element {
text-align: left;
}
div.cookbook-element:hover {
text-decoration: underline;
cursor: pointer;
}
div.playground-info {
text-align: left;
width: 400px;
}
div.seqpad {
position: relative;
margin: 0 auto;
height: 450px;
width: 50%;
}
div.editctrl {
position: relative;
margin: 0 auto;
height: 25px;
width: 50%;
}
textarea.seqout {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
background: #394035;
font-family: "Lucida Console", monospace;
border-radius: 0px;
border: none;
color: #fff;
display: block;
outline: 0;
text-decoration: none;
width: 50%;
margin-left: auto;
margin-right: auto;
resize: none;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 225px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
animation: growDown 300ms ease-in-out forwards;
transform-origin: top center;
}
.dropdown:hover .dropdown-content {
display: block;
}
button.editor {
-moz-appearance: none;
-webkit-appearance: none;
-ms-appearance: none;
appearance: none;
-moz-transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
-webkit-transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
-ms-transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
background-color: transparent;
box-shadow: inset 0 0 0 3px #ffffff;
color: #000000 !important;
border-radius: 15px;
border: 0;
cursor: pointer;
display: inline-block;
font-size: .75em;
font-weight: 400;
height: 3.75em;
line-height: 3em;
letter-spacing: 2px;
padding: 0 2em;
text-align: left;
text-decoration: none;
text-transform: uppercase;
white-space: nowrap;
}
@media screen and (max-width: 600px) {
div.seqpad {
width: 100%;
}
div.editctrl {
width: 100%;
}
textarea.seqout {
width: 100%;
}
button.editor {
width: auto;
}
}
button.editor:hover {
background-color: #e6e6e6;
}
@-moz-keyframes growDown {
0% {
transform: scaleY(0);
}
80% {
transform: scaleY(1.1);
}
100% {
transform: scaleY(1);
}
}
@-webkit-keyframes growDown {
0% {
transform: scaleY(0);
}
80% {
transform: scaleY(1.1);
}
100% {
transform: scaleY(1);
}
}
@-o-keyframes growDown {
0% {
transform: scaleY(0);
}
80% {
transform: scaleY(1.1);
}
100% {
transform: scaleY(1);
}
}
@keyframes growDown {
0% {
transform: scaleY(0);
}
80% {
transform: scaleY(1.1);
}
100% {
transform: scaleY(1);
}
}
#pg-run {
float: left;
}
#pg-clear {
float: left;
}
#pg-info {
float: left;
}
#pg-examples {
float: right;
}
@media only screen and (max-width: 760px) {
#pg-info {
display: none;
}
#pg-clear {
display: none;
}
#pg-examples {
float: left;
}
}
</style>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="assets/css/main.css" />
</head>
<body class="subpage">
<!-- Header -->
<header id="header">
<div class="inner">
<a href="index.html" class="logo"><strong>Seq</strong> playground</a>
<nav id="nav">
<div class="navitem" onclick="window.location.href='https://docs.seq-lang.org'">Docs</div>
<div class="navitem" onclick="window.location.href='https://github.com/seq-lang/seq'">GitHub</div>
<div class="navitem" onclick="window.location.href='demo.html?code='">Demo</div>
</nav>
<a href="#navPanel" class="navPanelToggle"><span class="fa fa-bars"></span></a>
</div>
</header>
<!-- Three -->
<section id="three" class="wrapper">
<div class="editctrl">
<button id="pg-run" class="editor" onclick="execute()">
<i class="fa fa-cog"></i> Run
</button>
<button id="pg-clear" class="editor" onclick="clearEditor()">
<i class="fa fa-times"></i> Clear
</button>
<div id="pg-info" class="dropdown">
<button class="editor">
<i class="fa fa-info"></i> Info
</button>
<div class="dropdown-content">
<div class="playground-info">
Welcome to the Seq playground! Type Seq code in the editor below,
then click the "RUN" button to execute it. Alternatively, select
from one of the examples on the right.
<br />
<br />
Issues or feedback? Let us know <a href="https://github.com/seq-lang/seq/issues">on GitHub</a>.
</div>
</div>
</div>
<div id="pg-examples" class="dropdown">
<button class="editor">
Examples <i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content" id="cookbook">
<div class="cookbook-element" onclick="setEditor('samples/basics.seq')">Basics</div>
<div class="cookbook-element" onclick="setEditor('samples/subsequence.seq')">Subsequences</div>
<div class="cookbook-element" onclick="setEditor('samples/kmers.seq')">k-mers</div>
<div class="cookbook-element" onclick="setEditor('samples/revcomp.seq')">Reverse complement</div>
<div class="cookbook-element" onclick="setEditor('samples/hamming.seq')">Hamming distance</div>
<div class="cookbook-element" onclick="setEditor('samples/neighbors.seq')">Hamming neighbors</div>
<div class="cookbook-element" onclick="setEditor('samples/minimizer.seq')">Minimizers</div>
<div class="cookbook-element" onclick="setEditor('samples/debruijn.seq')">de Bruijn edge</div>
<div class="cookbook-element" onclick="setEditor('samples/alignment.seq')">Sequence alignment</div>
<div class="cookbook-element" onclick="setEditor('samples/basecount.seq')">Base counting</div>
<div class="cookbook-element" onclick="setEditor('samples/palindrome.seq')">Palindromes</div>
<div class="cookbook-element" onclick="setEditor('samples/spacedseed.seq')">Spaced seeds</div>
<div class="cookbook-element" onclick="setEditor('samples/proteins.seq')">Protein translation</div>
</div>
</div>
</div>
<br />
<div class="seqpad">
<div id="editor"></div>
</div>
<br />
<div>
<textarea class="seqout" id="result" rows="5" readonly></textarea>
</div>
</section>
<!-- Footer -->
<footer id="footer">
<div class="inner">
<div class="copyright">
© 2020 <a href="https://github.com/seq-lang">seq-lang</a>. All Rights Reserved. Design: <a href="https://templated.co">TEMPLATED</a>
</div>
</div>
</footer>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
<script src="assets/js/ace/ace.js"></script>
<script type="text/javascript">
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.setShowPrintMargin(false);
editor.session.setMode("ace/mode/seq");
document.getElementById('editor').style.fontSize='20px';
function execute() {
$("#result").html("running...");
$.ajax({
url: 'https://exec.seq-lang.org:8000/seq_exec',
dataType: 'text',
type: 'post',
contentType: 'application/json',
data: JSON.stringify({"code": editor.getValue()}),
processData: false,
success: function(data, textStatus, jQxhr) {
// remove error code ANSI colors
var dataClean =
data.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
$("#result").html(dataClean);
},
error: function(jqXhr, textStatus, errorThrown) {
$("#result").html("error: could not communicate with execution server");
}
});
}
editor.commands.addCommand({
name: 'run',
bindKey: {win: 'Shift-Enter', mac: 'Shift-Enter'},
exec: function(editor) {
execute();
},
readOnly: true
});
function clearEditor() {
editor.setValue("", 1);
}
function setEditor(file) {
let xhr = new XMLHttpRequest();
xhr.open('GET', file, false);
xhr.send(null);
editor.setValue(xhr.responseText, 1);
}
function initEditor() {
var url = new URL(window.location.href);
if (url.searchParams.has("code")) {
editor.setValue(url.searchParams.get("code"), 1);
} else {
setEditor('samples/basics.seq');
}
}
initEditor();
</script>
</body>
</html>