-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvscode.html
48 lines (44 loc) · 1.54 KB
/
vscode.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<div id="container" style="position:fixed;bottom:0;left:0;width:100%;height:100%"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.10.1/min/vs/loader.js" integrity="sha256-PwMxLuduSzsT9fefu+Nz/M8z0sYHV9Pp77VxsOxk1Pc=" crossorigin="anonymous"></script>
<script>
require.config({
paths: {
'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.10.1/min/vs'
}
});
require(['vs/editor/editor.main'], function() {
var editor = monaco.editor.create(document.getElementById('container'), {
value: [
'function x() {',
'\tprint("Hello world!");',
'}',
'x();'
].join('\n'),
language: 'javascript',
automaticLayout: true
});
window.run = () => {
try {
var out = '';
var ev = eval('(print=>{' + editor.getValue() + '})(o=>{out+=o+"\\n"});');
document.getElementById("output").innerHTML = (out == '' ? '' : out + '\n\n') + (typeof ev === 'undefined' ? 'Nothing was returned.' : 'Returned: ' + ev);
} catch (e) {
console.log(e);
document.getElementById('output').innerHTML = e;
}
};
window.handleFiles = files => {
console.log(files);
};
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S, run);
});
</script>
</body>
</html>