mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-11-07 22:18:29 +01:00
add lua playground package
This commit is contained in:
parent
c26577a72d
commit
1d4957b4c5
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.DS_Store
|
3
LuaPlayground/README.md
Normal file
3
LuaPlayground/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
#LuaPlayground
|
||||
|
||||
Application for serverside code testing and analytics tool
|
7
LuaPlayground/assets/scheme.html
Normal file
7
LuaPlayground/assets/scheme.html
Normal file
@ -0,0 +1,7 @@
|
||||
<afx-app-window apptitle="Lua Playground" width="500" height="450" data-id="LuaPlayground">
|
||||
<afx-vbox >
|
||||
<div data-id="editorea"></div>
|
||||
<afx-resizer data-height="5"></afx-resizer>
|
||||
<div data-id="output"></div>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
3
LuaPlayground/build/debug/README.md
Normal file
3
LuaPlayground/build/debug/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
#LuaPlayground
|
||||
|
||||
Application for serverside code testing and analytics tool
|
19
LuaPlayground/build/debug/main.css
Normal file
19
LuaPlayground/build/debug/main.css
Normal file
@ -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;
|
||||
}
|
99
LuaPlayground/build/debug/main.js
Normal file
99
LuaPlayground/build/debug/main.js
Normal file
@ -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 = ($("<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);
|
13
LuaPlayground/build/debug/package.json
Normal file
13
LuaPlayground/build/debug/package.json
Normal file
@ -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"]
|
||||
}
|
7
LuaPlayground/build/debug/scheme.html
Normal file
7
LuaPlayground/build/debug/scheme.html
Normal file
@ -0,0 +1,7 @@
|
||||
<afx-app-window apptitle="Lua Playground" width="500" height="450" data-id="LuaPlayground">
|
||||
<afx-vbox >
|
||||
<div data-id="editorea"></div>
|
||||
<afx-resizer data-height="5"></afx-resizer>
|
||||
<div data-id="output"></div>
|
||||
</afx-vbox>
|
||||
</afx-app-window>
|
60
LuaPlayground/coffees/main.coffee
Normal file
60
LuaPlayground/coffees/main.coffee
Normal file
@ -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 = ($ "<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
|
18
LuaPlayground/css/main.css
Normal file
18
LuaPlayground/css/main.css
Normal file
@ -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;
|
||||
}
|
13
LuaPlayground/package.json
Normal file
13
LuaPlayground/package.json
Normal file
@ -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"]
|
||||
}
|
1
LuaPlayground/project.apj
Normal file
1
LuaPlayground/project.apj
Normal file
@ -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"]}
|
Loading…
Reference in New Issue
Block a user