-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
431 lines (414 loc) · 17.8 KB
/
index.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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta property="og:title" content="EffiwBin" />
<meta property="og:type" content="website" />
<meta property="og:url" content="/" />
<meta property="og:image" content="/das_ding.png" />
<meta property="og:image:width" content="300" />
<meta property="og:image:height" content="300" />
<meta property="og:description" content="A paste service built on Eludris' Effis!" />
<meta name="theme-color" content="#211233" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<title>EffiwBin</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<nav>
<a class="nava" href="https://github.com/enokiun/effiwbin"><button class="navbutton">GitHub</button></a>
<button onclick="newPaste()" class="navbutton left">New</button>
<a style="display: none" id="effiw-link" class="nava"
><button class="navbutton">Effis URL</button></a
>
<button onclick="save()" class="navbutton">Save</button>
<button onclick="settings()" class="navbutton">Settings</button>
</nav>
<div id="settings" style="display: none">
<h3>Settings</h3>
<span>
<label for="lang">Language</label>
<select name="Language" id="lang" onchange="langChange()">
<option value="abap">Abap</option>
<option value="abc">Abc</option>
<option value="actionscript">ActionScript</option>
<option value="ada">Ada</option>
<option value="alda">Alda</option>
<option value="apache_conf">Apache Conf</option>
<option value="apex">Apex</option>
<option value="applescript">AppleScript</option>
<option value="aql">Aql</option>
<option value="asciidoc">Asciidoc</option>
<option value="asl">Asl</option>
<option value="assembly_x86">x86 Assembly</option>
<option value="autohotkey">AutoHotKey</option>
<option value="batchfile">Batch</option>
<option value="bibtex">Bibtex</option>
<option value="c9search">C9search</option>
<option value="c_cpp">C</option>
<option value="c_cpp">C++</option>
<option value="cirru">Cirru</option>
<option value="clojure">Clojure</option>
<option value="cobol">Cobol</option>
<option value="coffee">Coffee</option>
<option value="coldfusion">Coldfusion</option>
<option value="crystal">Crystal</option>
<option value="csharp">C#</option>
<option value="csound_document">CSound Document</option>
<option value="csound_orchestra">CSound Orchestra</option>
<option value="csound_score">CSound Score</option>
<option value="csp">Csp</option>
<option value="css">Css</option>
<option value="curly">Curly</option>
<option value="dart">Dart</option>
<option value="diff">Diff</option>
<option value="django">Django</option>
<option value="d">D</option>
<option value="dockerfile">Dockerfile</option>
<option value="dot">Dot</option>
<option value="drools">Drools</option>
<option value="edifact">Edifact</option>
<option value="eiffel">Eiffel</option>
<option value="ejs">Ejs</option>
<option value="elixir">Elixir</option>
<option value="elm">Elm</option>
<option value="erlang">Erlang</option>
<option value="forth">Forth</option>
<option value="fortran">Fortran</option>
<option value="fsharp">Fsharp</option>
<option value="fsl">Fsl</option>
<option value="ftl">Ftl</option>
<option value="gcode">GCode</option>
<option value="gherkin">Gherkin</option>
<option value="gitignore">Gitignore</option>
<option value="glsl">GLSL</option>
<option value="gobstones">Gobstones</option>
<option value="golang">Golang</option>
<option value="graphqlschema">GQL</option>
<option value="groovy">Groovy</option>
<option value="haml">Haml</option>
<option value="handlebars">Handlebars</option>
<option value="haskell_cabal">Haskell Cabal</option>
<option value="haskell">Haskell</option>
<option value="haxe">Haxe</option>
<option value="hjson">Hjson</option>
<option value="html_elixir">HTML Elixir</option>
<option value="html">HTML</option>
<option value="html_ruby">HTML ruby</option>
<option value="ini">INI</option>
<option value="io">IO</option>
<option value="ion">Ion</option>
<option value="jack">Jack</option>
<option value="jade">Jade</option>
<option value="java">Java</option>
<option value="javascript">JavaScript</option>
<option value="jexl">Jexl</option>
<option value="json5">JSON5</option>
<option value="jsoniq">JSONIQ</option>
<option value="json">JSON</option>
<option value="jsp">Jsp</option>
<option value="jssm">Jssm</option>
<option value="jsx">JSX</option>
<option value="julia">Julia</option>
<option value="kotlin">Kotlin</option>
<option value="latex">Latex</option>
<option value="latte">Latte</option>
<option value="less">Less</option>
<option value="liquid">Liquid</option>
<option value="lisp">Lisp</option>
<option value="livescript">LiveScript</option>
<option value="logiql">Logiql</option>
<option value="logtalk">Logtalk</option>
<option value="lsl">LSL</option>
<option value="lua">Lua</option>
<option value="luapage">Luapage</option>
<option value="lucene">Lucene</option>
<option value="makefile">Makefile</option>
<option value="markdown">MarkDown</option>
<option value="mask">Mask</option>
<option value="matlab">Matlab</option>
<option value="maze">Maze</option>
<option value="mediawiki">Mediawiki</option>
<option value="mel">Mel</option>
<option value="mips">Mips</option>
<option value="mixal">Mixal</option>
<option value="mushcode">Mushcode</option>
<option value="mysql">Mysql</option>
<option value="nginx">Nginx</option>
<option value="nim">Nim</option>
<option value="nix">Nix</option>
<option value="nsis">Nsis</option>
<option value="nunjucks">Nunjucks</option>
<option value="objectivec">Objectivec</option>
<option value="ocaml">Ocaml</option>
<option value="partiql">Partiql</option>
<option value="pascal">Pascal</option>
<option value="perl">Perl</option>
<option value="pgsql">Pgsql</option>
<option value="php">Php</option>
<option value="php_laravel_blade">PHP Laravel Blade</option>
<option value="pig">Pig</option>
<option value="plain_text">Plain</option>
<option value="powershell">Powershell</option>
<option value="praat">Praat</option>
<option value="prisma">Prisma</option>
<option value="prolog">Prolog</option>
<option value="properties">Properties</option>
<option value="protobuf">Protobuf</option>
<option value="puppet">Puppet</option>
<option value="python">Python</option>
<option value="qml">QML</option>
<option value="raku">Raku</option>
<option value="razor">Razor</option>
<option value="rdoc">Rdoc</option>
<option value="red">Red</option>
<option value="redshift">Redshift</option>
<option value="rhtml">Rhtml</option>
<option value="r">R</option>
<option value="robot">Robot</option>
<option value="rst">RST</option>
<option value="ruby">Ruby</option>
<option value="rust">Rust</option>
<option value="sac">Sac</option>
<option value="sass">Sass</option>
<option value="scad">Scad</option>
<option value="scala">Scala</option>
<option value="scheme">Scheme</option>
<option value="scrypt">Scrypt</option>
<option value="scss">SCSS</option>
<option value="sh">Shell</option>
<option value="sjs">SJS</option>
<option value="slim">Slim</option>
<option value="smarty">Smarty</option>
<option value="smithy">Smithy</option>
<option value="snippets">Snippets</option>
<option value="soy_template">Soy Template</option>
<option value="space">Space</option>
<option value="sparql">Sparql</option>
<option value="sql">Sql</option>
<option value="sqlserver">Sqlserver</option>
<option value="stylus">Stylus</option>
<option value="svg">SVG</option>
<option value="swift">Swift</option>
<option value="tcl">Tcl</option>
<option value="terraform">Terraform</option>
<option value="tex">Tex</option>
<option value="textile">Textile</option>
<option value="text">Text</option>
<option value="toml">Toml</option>
<option value="tsx">Tsx</option>
<option value="turtle">Turtle</option>
<option value="twig">Twig</option>
<option value="typescript">TypeScript</option>
<option value="vala">Vala</option>
<option value="vbscript">VBS</option>
<option value="velocity">Velocity</option>
<option value="verilog">Verilog</option>
<option value="vhdl">VHDL</option>
<option value="visualforce">Visualforce</option>
<option value="wollok">Wollok</option>
<option value="xml">XML</option>
<option value="xquery">Xquery</option>
<option value="yaml">Yaml</option>
<option value="zeek">Zeek</option>
</select>
</span>
<span>
<label for="theme">Theme</label>
<select name="Theme" id="theme" onchange="themeChange()">
<option value="ambiance">Ambiance</option>
<option value="chaos">Chaos</option>
<option value="chrome">Chrome</option>
<option value="cloud9_day">Cloud9 Day</option>
<option value="cloud9_night">Cloud9 Night</option>
<option value="cloud9_night_low_color">Cloud9 Night Low Color</option>
<option value="clouds">Clouds</option>
<option value="clouds_midnight">Clouds Midnight</option>
<option value="cobalt">Cobalt</option>
<option value="crimson_editor">Crimson Editor</option>
<option value="dawn">Dawn</option>
<option value="dracula">Dracula</option>
<option value="dreamweaver">Dreamweaver</option>
<option value="eclipse">Eclipse</option>
<option value="github">Github</option>
<option value="gob">Gob</option>
<option value="gruvbox_dark_hard">Gruvbox Dark Hard</option>
<option value="gruvbox">Gruvbox</option>
<option value="gruvbox_light_hard">Gruvbox Light Hard</option>
<option value="idle_fingers">Idle Fingers</option>
<option value="iplastic">Iplastic</option>
<option value="katzenmilch">Katzenmilch</option>
<option value="kr_theme">KR theme</option>
<option value="kuroir">Kuroir</option>
<option value="merbivore">Merbivore</option>
<option value="merbivore_soft">Merbivore Soft</option>
<option value="mono_industrial">Mono Industrial</option>
<option value="monokai">Monokai</option>
<option value="nord_dark">Nord Dark</option>
<option value="one_dark">One Dark</option>
<option value="pastel_on_dark">Pastel on Dark</option>
<option value="solarized_dark">Solarized Dark</option>
<option value="solarized_light">Solarized Light</option>
<option value="sqlserver">SQL server</option>
<option value="terminal">Terminal</option>
<option value="textmate">Textmate</option>
<option value="tomorrow">Tomorrow</option>
<option value="tomorrow_night_blue">Tomorrow Night Blue</option>
<option value="tomorrow_night_bright">Tomorrow Night Bright</option>
<option value="tomorrow_night_eighties">
Tomorrow Night Eighties
</option>
<option value="tomorrow_night">Tomorrow Night</option>
<option value="twilight">Twilight</option>
<option value="vibrant_ink">Vibrant Ink</option>
<option value="xcode">XCode</option>
</select>
</span>
<span>
<label for="keybindings">Keybindings</label>
<select
name="Keybindings"
id="keybindings"
onchange="keybindingsChange()"
>
<option value="vscode">VSCode</option>
<option value="vim">Vim</option>
<option value="sublime">Sublime Text</option>
<option value="emacs">Emacs</option>
</select>
</span>
<span>
<label for="instanceUrl">Instance URL</label>
<input type="text" id="instanceUrl" placeholder="https://effis.tooty.xyz" onchange="instanceUrlChange()"></input>
</span>
</div>
<div id="editor"></div>
<script src="ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/ext-language_tools.js"></script>
<script>
const root = '';
const params = new URL(location.href).searchParams;
const id = params.get('id');
const lang = params.get('lang');
const settingsDiv = document.getElementById('settings');
const langSelect = document.getElementById('lang');
const themeSelect = document.getElementById('theme');
const keybindingsSelect = document.getElementById('keybindings');
const instanceUrlInput = document.getElementById('instanceUrl');
const instance = localStorage.getItem('instanceUrl');
let instanceUrl = instance? instance: 'https://effis.tooty.xyz';
if (instance) {
instanceUrlInput.value = instance;
}
ace.require('ace/ext/language_tools');
var editor = ace.edit('editor');
editor.setOptions({
enableBasicAutocompletion: true
});
const theme = localStorage.getItem('theme');
if (theme) {
editor.setTheme(`ace/theme/${theme}`);
themeSelect.value = theme;
} else {
editor.setTheme('ace/theme/gruvbox_dark_hard');
}
const keybindings = localStorage.getItem('keybindings');
if (keybindings) {
keybindingsSelect.value = keybindings;
editor.setKeyboardHandler(`ace/keyboard/${keybindings}`);
if (keybindings == 'vim') {
ace.config.loadModule('ace/keyboard/vim', (m) => {
var VimApi = require('ace/keyboard/vim').CodeMirror.Vim
VimApi.defineEx('write', 'w', (cm, input) => {
save()
})
})
}
}
if (lang) {
langSelect.value = lang;
editor.session.setMode(`ace/mode/${lang}`);
} else {
langSelect.value = 'text';
}
editor.setShowPrintMargin(false);
if (id) {
editor.setValue('Loading, please wait...');
fetch(`${instanceUrl}/${id}/data`).then((resp) => {
resp.json().then((data) => {
if (data.metadata.type == 'TEXT') {
const effiwLink = document.getElementById('effiw-link');
effiwLink.href = `${instanceUrl}/${id}`;
effiwLink.style.display = 'block';
fetch(`${instanceUrl}/${id}`).then((resp) => {
resp.text().then((text) => {
editor.setValue(text, -1);
});
});
editor.setReadOnly(true);
} else {
alert(`Invalid file type: expected TEXT, found ${data.metadata.type}`);
}
});
});
}
editor.commands.addCommand({
name: 'write',
bindKey: {win: 'Ctrl-S', mac: 'Command-S'},
exec: (editor) => {
save();
},
readOnly: false,
});
</script>
<script>
const newPaste = () => {
location.href = root;
};
const save = () => {
let formData = new FormData();
formData.append('file', editor.getValue());
fetch(instanceUrl, {
body: formData,
method: 'POST',
}).then((resp) =>
resp.json().then((data) => {
location.href = `${root}/?id=${data.id}&lang=${langSelect.value}`;
})
);
};
const settings = () => {
settingsDiv.style.display =
settingsDiv.style.display === 'none' ? 'flex' : 'none';
};
const langChange = () => {
editor.session.setMode(`ace/mode/${langSelect.value}`);
};
const themeChange = () => {
localStorage.setItem('theme', themeSelect.value);
editor.setTheme(`ace/theme/${themeSelect.value}`);
};
const keybindingsChange = () => {
localStorage.setItem('keybindings', keybindingsSelect.value);
editor.setKeyboardHandler(`ace/keyboard/${keybindingsSelect.value}`);
if (keybindings == 'vim') {
ace.config.loadModule('ace/keyboard/vim', (m) => {
var VimApi = require('ace/keyboard/vim').CodeMirror.Vim
VimApi.defineEx('write', 'w', (cm, input) => {
save()
})
})
}
};
const instanceUrlChange = () => {
localStorage.setItem('instanceUrl', instanceUrlInput.value);
if (instanceUrlInput.value.length == 0) {
localStorage.removeItem('instanceUrl');
} else {
instanceUrl = instanceUrlInput.value;
}
}
</script>
</body>
</html>