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
|
<!DOCTYPE html>
<html class="neo_ide" style="overflow:hidden;">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Luxcena Neo - Neo IDE</title>
<link rel="stylesheet" href="/css/bundle.css" type="text/css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">
</head>
<body id="neo_ide">
<!--<div class="page-loader">
<div class="loader">
<div class="loading">
<div class="loading__element el1">L</div>
<div class="loading__element el2">O</div>
<div class="loading__element el3">A</div>
<div class="loading__element el4">D</div>
<div class="loading__element el5">I</div>
<div class="loading__element el6">N</div>
<div class="loading__element el7">G</div>
<div class="loading__element el8">.</div>
<div class="loading__element el9">.</div>
<div class="loading__element el10">.</div>
</div>
<div class="current-event">
<p id="event-text"></p>
</div>
</div>
<div class="error">
<h1>ERROR</h1>
</error>
</div>-->
<div class="page-container">
<nav class="nav-container">
<ul>
<li id="back_button" class="left button"><i class="fas fa-chevron-left"></i></li>
<li class="center">Neo IDE - <span class="fileName"></span></li>
<li class="right">
<ul>
<li id="toggle_menu" class="button"><i class="fas fa-caret-down"></i></li>
<li id="save_button" class="button"><i class="fas fa-save"></i></li>
<li id="stop_button" class="button"><i class="fas fa-stop"></i></li>
<li id="start_button" class="button"><i class="fas fa-play"></i></li>
</ul>
</li>
</ul>
</nav>
<div class="menubar-container">
<ul>
<li id="toggle_output_button" class="button"></i>Toggle output</li>
</ul>
</div>
<div class="panel-container">
<div class="panel-top">
<div id="editor"></div>
</div>
<div class="splitter">
<div class="text">
<i class="fas fa-terminal"></i>
<span>output</span>
</div>
</div>
<div class="panel-bottom"><pre></pre></div>
</div>
</div>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/js/bundle.js"></script>
<script type="text/javascript" src="https://rawgit.com/RickStrahl/jquery-resizable/master/src/jquery-resizable.js"></script>
<script src="/monaco-editor/min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': 'monaco-editor/min/vs' }});
let editor = undefined;
let socket = io();
let outputLines = 0;
function resize() {
let screenH = window.innerHeight;
$(".panel-container").css("height", (screenH - 45) + "px");
$(".panel-bottom").css("height", document.getElementsByClassName("panel-bottom")[0].clientHeight);
editor.layout();
}
function findGetParameter(parameterName) {
var result = null,
tmp = [];
location.search
.substr(1)
.split("&")
.forEach(function (item) {
tmp = item.split("=");
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
});
return result;
}
require(['vs/editor/editor.main'], function() {
monaco.editor.defineTheme('neoIdeDark', {
base: 'vs-dark',
inherit: true, // can also be false to completely replace the builtin rules
rules: [
{ token: 'eachSecond(self)', foreground: 'ffa500', fontStyle: 'italic underline' },
{ token: 'string.LuxcenaNeo', foreground: '008800', fontStyle: 'bold' },
{ token: 'comment.css', foreground: '0000ff' } // will inherit fontStyle from `comment` above
]
});
editor = monaco.editor.create(document.getElementById('editor'), {
value: [""].join('\n'),
language: 'python',
theme: 'neoIdeDark'
});
let decorations = editor.deltaDecorations([], [
{ range: new monaco.Range(3,1,5,1), options: { isWholeLine: true, linesDecorationsClassName: 'myLineDecoration' }},
{ range: new monaco.Range(7,1,7,24), options: { inlineClassName: 'myInlineDecoration' }},
]);
let runScriptBinding = editor.addCommand(monaco.KeyCode.F5, function() {
alert('F5 pressed!');
});
resize();
socket.emit("NeoIde_GetScript", {"scriptPath": atob(findGetParameter("scriptName"))});
});
$(".panel-top").resizable({
handleSelector: ".splitter",
resizeWidth: false,
onDrag: resize
});
$("#toggle_menu").on("click", () => {
if ($(".menubar-container").hasClass("menuBarIn")) {
$(".menubar-container").removeClass("menuBarIn");
$(".menubar-container").addClass("menuBarOut");
$("#toggle_menu i").removeClass("fa-caret-up");
$("#toggle_menu i").addClass("fa-caret-down");
} else {
$(".menubar-container").removeClass("menuBarOut");
$(".menubar-container").addClass("menuBarIn");
$("#toggle_menu i").removeClass("fa-caret-down");
$("#toggle_menu i").addClass("fa-caret-up");
}
});
$("#back_button").on("click", () => {
window.location.href = "http://" + window.location.hostname + ":" + window.location.port + "/scripts";
});
$("#save_button").on("click", () => {
$("#save_button").html('<i class="fas fa-circle-notch fa-spin"></i>');
socket.emit("NeoIde_SaveScript", {
script: {
name: $(".fileName").html(),
path: atob(findGetParameter("scriptName")),
files: {
main: editor.getValue()
}
}
});
});
$("#start_button").on("click", () => {
socket.emit("NeoIde_RunScript", {
scriptPath: atob(findGetParameter("scriptName"))
})
});
$("#stop_button").on("click", () => {
socket.emit("NeoIde_StopScript", {});
});
$("#toggle_output_button").on("click", () => {
console.log("NIY");
});
window.onresize = resize;
socket.on("callback", (reqResult) => {
switch (reqResult.request) {
case "NeoIde_GetScript":
if (!reqResult.success) {
alert("Could not load script...");
window.location.href = "http://" + window.location.hostname + ":" + window.location.port + "/scripts";
}
editor.setValue(reqResult.data.script.files.main);
$(".fileName").text(reqResult.data.script.name);
break;
case "NeoIde_SaveScript":
if (!reqResult.success) {
$("#save_button").html('<i class="fas fa-times"></i>');
alert("Could not save script, info in console.");
console.log(reqResult);
} else {
$("#save_button").html('<i class="fas fa-check"></i>');
}
setTimeout(() => {
$("#save_button").html('<i class="fas fa-save"></i>');
}, 1500);
break;
case "NeoIde_StopScript":
console.log(reqResult);
break;
case "NeoIde_GetScriptOutput":
if (reqResult.success) {
let lines = reqResult.output.split("\n");
let preObj = "";
let currentClass = "";
let currentData = "";
for (let i = 0; i < lines.length; i++) {
if (lines[i].includes("====stdout====")) {
preObj += `<span class="${currentClass}">${currentData}</span>`;
currentClass = "stdout";
currentData = "";
} else if (lines[i].includes("====stderr====")) {
preObj += `<span class="${currentClass}">${currentData}</span>`;
currentClass = "stderr";
currentData = "";
} else if (lines[i].includes("====close====")) {
preObj += `<span class="${currentClass}">${currentData}</span>`;
currentClass = "close";
currentData = "";
} else {
if (lines [i].replace("\n", "") == "") {
//currentData += "\n"
} else {
currentData += lines[i] + "\n";
}
}
}
preObj += `<span class="${currentClass}">${currentData}</span>`;
if (outputLines != lines.length) {
outputLines = lines.length;
$(".panel-bottom pre").html(preObj);
var element = document.getElementsByClassName('panel-bottom')[0];
element.scrollTop = element.scrollHeight;
}
} else {
$(".panel-bottom pre").html("<span class=\"stderr\">" + reqResult.error.reason + "</span>");
}
break;
default:
console.log("Got a weird callback from \"" + reqResult.request + "\"");
}
});
setInterval(() => {
socket.emit("NeoIde_GetScriptOutput", {
scriptPath: atob(findGetParameter("scriptName"))
})
}, 400);
</script>
</body>
</html>
|