-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
29 lines (26 loc) · 1003 Bytes
/
index.js
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
const myCodeMirrorIn = CodeMirror.fromTextArea(document.querySelector('#soql'), {mode:'sql', theme: 'dracula', lineNumbers: true});
const myCodeMirrorOut = CodeMirror.fromTextArea(document.querySelector('#result-area'), {mode:'javascript', theme: 'dracula', lineNumbers: true, lineWrapping: true});
function execParse(event) {
event.preventDefault();
try {
let result = parseSoql(myCodeMirrorIn.getDoc().getValue());
myCodeMirrorOut.getDoc().setValue(result);
} catch(e) {
rebootGoApplication();
myCodeMirrorOut.getDoc().setValue(e.message ?? e);
}
}
async function copyToClipboard(event) {
event.preventDefault();
const text = myCodeMirrorOut.getDoc().getValue();
try {
await navigator.clipboard.writeText(text);
const el = document.querySelector('#copied');
el.style.display = 'inline-block';
setTimeout(() => {
el.style.display = 'none';
}, 1200);
} catch (e) {
//
}
}