diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2018-09-07 00:32:51 +0200 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2018-09-07 00:32:51 +0200 |
commit | 78d7c8d75a5f55ab56dd018edc85ebce9aa033bb (patch) | |
tree | 2ad9da977667b79236cfdd827d0446a5bf9fea18 /public/neo_ide.html | |
download | Luxcena-Neo-78d7c8d75a5f55ab56dd018edc85ebce9aa033bb.tar.gz Luxcena-Neo-78d7c8d75a5f55ab56dd018edc85ebce9aa033bb.zip |
:construction: Add pre-v1 project
Because of some stupid mistakes with the repo, I decided to delete the
git history. Create a new, fresh repo, and move all the code there.
Since all this is pre-v1, everything is in a testing-phase anyways. So i
do not think we are going to feel the need for any history. The old repo
is renamed to Luxcena-Neo-Old, and will be there until i convince
myself i won't need the history.
Diffstat (limited to 'public/neo_ide.html')
-rw-r--r-- | public/neo_ide.html | 274 |
1 files changed, 274 insertions, 0 deletions
diff --git a/public/neo_ide.html b/public/neo_ide.html new file mode 100644 index 0000000..584b5ea --- /dev/null +++ b/public/neo_ide.html @@ -0,0 +1,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> |