diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/LuaPlayground/README.md b/LuaPlayground/README.md new file mode 100644 index 0000000..cb079f4 --- /dev/null +++ b/LuaPlayground/README.md @@ -0,0 +1,3 @@ +#LuaPlayground + +Application for serverside code testing and analytics tool \ No newline at end of file diff --git a/LuaPlayground/assets/scheme.html b/LuaPlayground/assets/scheme.html new file mode 100644 index 0000000..c7e664d --- /dev/null +++ b/LuaPlayground/assets/scheme.html @@ -0,0 +1,7 @@ + + +
+ +
+
+
\ No newline at end of file diff --git a/LuaPlayground/build/debug/README.md b/LuaPlayground/build/debug/README.md new file mode 100644 index 0000000..cb079f4 --- /dev/null +++ b/LuaPlayground/build/debug/README.md @@ -0,0 +1,3 @@ +#LuaPlayground + +Application for serverside code testing and analytics tool \ No newline at end of file diff --git a/LuaPlayground/build/debug/main.css b/LuaPlayground/build/debug/main.css new file mode 100644 index 0000000..9784767 --- /dev/null +++ b/LuaPlayground/build/debug/main.css @@ -0,0 +1,19 @@ + +afx-app-window[data-id="LuaPlayground"] div[data-id="output"] p{ + margin:0; + padding:0; + font-family: "HermitLight"; + text-align: left; +} +afx-app-window[data-id="LuaPlayground"] div[data-id="output"]{ + background-color: #2f3129; + padding: 10px; + padding-left: 40px; + color:white; + overflow: auto; +} +afx-app-window[data-id="LuaPlayground"] afx-resizer{ + border-top: 1px solid #a6a6a6; + background-color: #2f3129; + border-right: 0; +} diff --git a/LuaPlayground/build/debug/main.js b/LuaPlayground/build/debug/main.js new file mode 100644 index 0000000..635b342 --- /dev/null +++ b/LuaPlayground/build/debug/main.js @@ -0,0 +1,99 @@ +(function() { + var LuaPlayground; + + LuaPlayground = class LuaPlayground extends this.OS.GUI.BaseApplication { + constructor(args) { + super("LuaPlayground", args); + } + + main() { + var me; + me = this; + this.datarea = this.find("editorea"); + this.output = this.find("output"); + this.editor = ace.edit(this.datarea); + this.editor.setOptions({ + enableBasicAutocompletion: true, + enableLiveAutocompletion: true, + fontSize: "10pt" + }); + this.editor.getSession().setUseWrapMode(true); + this.editor.session.setMode("ace/mode/lua"); + this.editor.setTheme("ace/theme/monokai"); + this.on("vboxchange", function() { + return me.editor.resize(); + }); + return this.socket = null; + } + + menu() { + var me, menu; + me = this; + menu = [ + { + text: "__(Code)", + child: [ + { + text: "__(Run)", + dataid: `${this.name}-Run`, + shortcut: "C-R" + } + ], + onmenuselect: function(e) { + return me.run(); + } + } + ]; + return menu; + } + + log(t, m) { + var p; + if (t === "clean") { + return $(this.output).empty(); + } + p = ($("

")).attr("class", t.toLowerCase())[0]; + $(p).html(`${t}: ${m.__()}`); + ($(this.output)).append(p); + return ($(this.output)).scrollTop(this.output.scrollHeight); + } + + run() { + var me, proto, value; + me = this; + value = this.editor.getValue().trim(); + if (!(value && value !== "")) { + return; + } + proto = window.location.protocol === "https:" ? "wss://" : "ws://"; + this.socket = new WebSocket(proto + this._api.HOST + "/lua-api/os/apigateway?ws=1"); + this.socket.onopen = function() { + //send data to server + return me.socket.send(JSON.stringify({ + code: value + })); + }; + this.socket.onmessage = function(e) { + if (e.data) { + return me.log("INFO", e.data); + } + }; + return this.socket.onclose = function() { + me.socket = null; + return console.log("socket closed"); + }; + } + + cleanup(e) { + if (this.socket) { + return this.socket.close(); + } + } + + }; + + this.OS.dependencies = ["ace/ace"]; + + this.OS.register("LuaPlayground", LuaPlayground); + +}).call(this); diff --git a/LuaPlayground/build/debug/package.json b/LuaPlayground/build/debug/package.json new file mode 100644 index 0000000..b52c9f3 --- /dev/null +++ b/LuaPlayground/build/debug/package.json @@ -0,0 +1,13 @@ +{ + "app":"LuaPlayground", + "name":"LuaPlayground", + "description":"Module testing and analytics tool", + "info":{ + "author": "Xuan Sang LEs", + "email": "xsang.le@gmail.com" + }, + "version":"0.0.1-a", + "category":"System", + "iconclass":"fa fa-adn", + "mimes":["none"] +} \ No newline at end of file diff --git a/LuaPlayground/build/debug/scheme.html b/LuaPlayground/build/debug/scheme.html new file mode 100644 index 0000000..c7e664d --- /dev/null +++ b/LuaPlayground/build/debug/scheme.html @@ -0,0 +1,7 @@ + + +

+ +
+ + \ No newline at end of file diff --git a/LuaPlayground/coffees/main.coffee b/LuaPlayground/coffees/main.coffee new file mode 100644 index 0000000..2de1ca9 --- /dev/null +++ b/LuaPlayground/coffees/main.coffee @@ -0,0 +1,60 @@ +class LuaPlayground extends this.OS.GUI.BaseApplication + constructor: ( args ) -> + super "LuaPlayground", args + + main: () -> + me = @ + @datarea = @find "editorea" + @output = @find "output" + @.editor = ace.edit @datarea + @.editor.setOptions { + enableBasicAutocompletion: true, + enableLiveAutocompletion: true, + fontSize: "10pt" + } + @editor.getSession().setUseWrapMode true + @editor.session.setMode "ace/mode/lua" + @editor.setTheme "ace/theme/monokai" + @on "vboxchange", () -> + me.editor.resize() + + @socket = null + + menu: () -> + me = @ + menu = [{ + text: "__(Code)", + child: [ + { text: "__(Run)", dataid: "#{@name}-Run", shortcut: "C-R" } + ], + onmenuselect: (e) -> me.run() + }] + menu + + log: (t, m) -> + return $(@output).empty() if t is "clean" + p = ($ "

").attr("class", t.toLowerCase())[0] + $(p).html "#{t}: #{m.__()}" + ($ @output).append p + ($ @output).scrollTop @output.scrollHeight + + run: () -> + me = @ + value = @editor.getValue().trim() + return unless value and value isnt "" + proto = if window.location.protocol is "https:" then "wss://" else "ws://" + @socket = new WebSocket proto + @_api.HOST + "/lua-api/os/apigateway?ws=1" + @socket.onopen = () -> + #send data to server + me.socket.send( JSON.stringify { code: value } ) + + @socket.onmessage = (e) -> me.log "INFO", e.data if e.data + @socket.onclose = () -> + me.socket = null + console.log "socket closed" + + cleanup: (e)-> + @socket.close() if @socket + +this.OS.dependencies = ["ace/ace"] +this.OS.register "LuaPlayground", LuaPlayground diff --git a/LuaPlayground/css/main.css b/LuaPlayground/css/main.css new file mode 100644 index 0000000..9582186 --- /dev/null +++ b/LuaPlayground/css/main.css @@ -0,0 +1,18 @@ +afx-app-window[data-id="LuaPlayground"] div[data-id="output"] p{ + margin:0; + padding:0; + font-family: "HermitLight"; + text-align: left; +} +afx-app-window[data-id="LuaPlayground"] div[data-id="output"]{ + background-color: #2f3129; + padding: 10px; + padding-left: 40px; + color:white; + overflow: auto; +} +afx-app-window[data-id="LuaPlayground"] afx-resizer{ + border-top: 1px solid #a6a6a6; + background-color: #2f3129; + border-right: 0; +} diff --git a/LuaPlayground/package.json b/LuaPlayground/package.json new file mode 100644 index 0000000..b52c9f3 --- /dev/null +++ b/LuaPlayground/package.json @@ -0,0 +1,13 @@ +{ + "app":"LuaPlayground", + "name":"LuaPlayground", + "description":"Module testing and analytics tool", + "info":{ + "author": "Xuan Sang LEs", + "email": "xsang.le@gmail.com" + }, + "version":"0.0.1-a", + "category":"System", + "iconclass":"fa fa-adn", + "mimes":["none"] +} \ No newline at end of file diff --git a/LuaPlayground/project.apj b/LuaPlayground/project.apj new file mode 100644 index 0000000..61e0ed8 --- /dev/null +++ b/LuaPlayground/project.apj @@ -0,0 +1 @@ +{"name":"LuaPlayground","root":"home://antosdk-apps/LuaPlayground","css":["css/main.css"],"javascripts":[],"coffees":["coffees/main.coffee"],"copies":["assets/scheme.html","package.json","README.md"]} \ No newline at end of file