-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
101 lines (89 loc) · 3 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>NodeMCU Tool</title>
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="./node_modules/xterm/dist/xterm.css" />
<script src="./node_modules/xterm/dist/xterm.js"></script>
<script src="./node_modules/xterm/dist/addons/fit/fit.js"></script>
</head>
<body>
<div id="container">
<div id="sidebar">
<div class="grouping">
<label>Connect to device (<a href="javascript:void(0)" id="reloadports_button">reload</a>)
</label>
<select id="port_selector"></select>
<button id="connect_button">Connect</button>
<button id="disconnect_button" disabled>Disconnect</button>
</div>
<div class="grouping">
Files: (<a href="javascript:void(0)" id="reloadfiles_button" disabled>refresh</a>)
<ul id="file_list">
</ul>
<button class="full" id="save_current_button" disabled>save current file</button>
<button class="full" id="exec_current_button" disabled>exec current file</button>
<button class="full" id="exec_selection_button" disabled>exec selection</button>
</div>
</div>
<div id="editor"></div>
<div id="terminal"></div>
</div>
</body>
<script>
// Monaco uses a custom amd loader that over-rides node's require.
// Keep a reference to node's require so we can restore it after executing the amd loader file.
var nodeRequire = global.require;
</script>
<script src="./node_modules/monaco-editor/min/vs/loader.js"></script>
<script>
// Save Monaco's amd require and restore Node's require
var amdRequire = global.require;
global.require = nodeRequire;
</script>
<script>
// require node modules before loader.js comes in
var path = require('path');
function uriFromPath(_path) {
var pathName = path.resolve(_path).replace(/\\/g, '/');
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
pathName = '/' + pathName;
}
return encodeURI('file://' + pathName);
}
amdRequire.config({
baseUrl: uriFromPath(path.join(__dirname, './node_modules/monaco-editor/min'))
});
// workaround monaco-css not understanding the environment
self.module = undefined;
// workaround monaco-typescript not understanding the environment
self.process.browser = true;
amdRequire(['vs/editor/editor.main'], function () {
var editor = monaco.editor.create(document.getElementById('editor'), {
value: [
'',
'-- print something',
'print("welcome to nodemcu")',
''
].join('\n'),
language: 'lua',
theme: "vs-dark",
});
window.addEventListener('resize', () => {
console.log('resize');
editor.layout()
});
window.editor = editor;
});
</script>
<script>
const terminal = new Terminal({
});
terminal.open(document.getElementById('terminal'));
terminal.fit();
window.addEventListener('resize', () => terminal.fit());
terminal.write('Not connected \r\n');
</script>
<script src="./app/communication.js"></script>
</html>