diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..48e341a
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,3 @@
+{
+ "lockfileVersion": 1
+}
diff --git a/src/packages/NotePad/Makefile b/src/packages/NotePad/Makefile
index 0fb6fd4..638e5da 100644
--- a/src/packages/NotePad/Makefile
+++ b/src/packages/NotePad/Makefile
@@ -1,4 +1,4 @@
-coffee_files = main.coffee
+coffee_files = extensions/extensions.coffee extensions/RemoteRunExtension.coffee main.coffee
jsfiles =
diff --git a/src/packages/NotePad/extensions/RemoteRunExtension.coffee b/src/packages/NotePad/extensions/RemoteRunExtension.coffee
new file mode 100644
index 0000000..0ccd16e
--- /dev/null
+++ b/src/packages/NotePad/extensions/RemoteRunExtension.coffee
@@ -0,0 +1,68 @@
+class RemoteRunExtension extends BaseExtension
+ constructor: () ->
+ super "RemoteRunExtension"
+
+ init: () ->
+ @_gui.htmlToScheme RemoteRunExtension.scheme, @, @host
+
+ main: () ->
+ me = @
+ @output = @find "output"
+ (@find "log-clear").set "onbtclick", (e) ->
+ me.log "clean"
+ (@find "restart").set "onbtclick", (e) ->
+ me.run()
+ @socket = null
+ # Now run the file
+ @run()
+
+ 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 = @
+ return @log "ERROR", __("No target file found") unless @data
+ @gateway = @gw()
+ return @log "ERROR", __("No backend found for file: {0}", @data.path) unless @gateway
+ $((@find "stat")).html(@data.path)
+ @socket.close() if @socket
+ proto = if window.location.protocol is "https:" then "wss://" else "ws://"
+ @socket = new WebSocket proto + @_api.HOST + @gateway
+ @socket.onopen = () ->
+ #send data to server
+ me.socket.send( JSON.stringify {path:me.data.path} )
+
+ @socket.onmessage = (e) -> me.log "INFO", e.data if e.data
+ @socket.onclose = () ->
+ me.socket = null
+ console.log "socket closed"
+
+ gw: () ->
+ return unless @data
+ for k,v of RemoteRunExtension.backends
+ if @data.info.mime.match (new RegExp k, "g") then return v
+ return null
+
+ cleanup: (e)->
+ @socket.close() if @socket
+
+RemoteRunExtension.backends = {
+ "text/lua": "/system/apigateway?ws=1"
+}
+
+RemoteRunExtension.scheme = """
+
+
+
+
+
+
+
+
+
+
+"""
\ No newline at end of file
diff --git a/src/packages/NotePad/extensions/extensions.coffee b/src/packages/NotePad/extensions/extensions.coffee
new file mode 100644
index 0000000..baf1179
--- /dev/null
+++ b/src/packages/NotePad/extensions/extensions.coffee
@@ -0,0 +1,4 @@
+class BaseExtension extends this.OS.GUI.BaseDialog
+ constructor: (name) ->
+ super name
+
\ No newline at end of file
diff --git a/src/packages/NotePad/main.coffee b/src/packages/NotePad/main.coffee
index 3f3bfcf..38492f8 100644
--- a/src/packages/NotePad/main.coffee
+++ b/src/packages/NotePad/main.coffee
@@ -126,6 +126,7 @@ class NotePad extends this.OS.GUI.BaseApplication
@bindKey "ALT-O", () -> me.actionFile "#{me.name}-Open"
@bindKey "CTRL-S", () -> me.actionFile "#{me.name}-Save"
@bindKey "ALT-W", () -> me.actionFile "#{me.name}-Saveas"
+ @bindKey "ALT-R", () -> me.actionFile "#{me.name}-Run"
@open @currfile
open: (file) ->
@@ -266,7 +267,8 @@ class NotePad extends this.OS.GUI.BaseApplication
{ text: "__(New)", dataid: "#{@name}-New", shortcut: "A-N" },
{ text: "__(Open)", dataid: "#{@name}-Open", shortcut: "A-O" },
{ text: "__(Save)", dataid: "#{@name}-Save", shortcut: "C-S" },
- { text: "__(Save as)", dataid: "#{@name}-Saveas", shortcut: "A-W" }
+ { text: "__(Save as)", dataid: "#{@name}-Saveas", shortcut: "A-W" },
+ { text: "__(Run)", dataid: "#{@name}-Run", shortcut: "A-R" }
],
onmenuselect: (e) -> me.actionFile e.item.data.dataid
}]
@@ -301,7 +303,12 @@ class NotePad extends this.OS.GUI.BaseApplication
saveas()
when "#{@name}-New"
@open "Untitled".asFileHandler()
-
+ when "#{@name}-Run"
+ if @currfile.dirty
+ return @notify __("Please save the file before running it")
+ else
+ if @dialog then @dialog.quit()
+ @openDialog new RemoteRunExtension(), null, null, @currfile
cleanup: (evt) ->
dirties = ( v for v in @tabarea.get "items" when v.dirty )
return if dirties.length is 0
@@ -320,4 +327,5 @@ NotePad.dependencies = [
"ace/ext-modelist",
"ace/ext-themelist"
]
+NotePad.extensions = {}
this.OS.register "NotePad", NotePad
\ No newline at end of file
diff --git a/src/packages/NotePad/main.css b/src/packages/NotePad/main.css
index bb5e1a6..ccc84de 100644
--- a/src/packages/NotePad/main.css
+++ b/src/packages/NotePad/main.css
@@ -42,4 +42,38 @@ afx-tab-bar[data-id="tabarea"] afx-list-view{
afx-tab-bar[data-id="tabarea"] afx-list-view > div.list-container > ul > li.selected {
background-color: #f6F6F6;
border-radius: 0;
+}
+
+afx-app-window[data-id="win-remote-run"] div[data-id="output"] p{
+ margin:0;
+ padding:0;
+ font-family: "HermitLight";
+ text-align: left;
+}
+afx-app-window[data-id="win-remote-run"] div[data-id="output"]{
+ background-color: #2f3129;
+ padding: 10px;
+ color:white;
+ overflow: auto;
+}
+afx-app-window[data-id="win-remote-run"] div[data-id="stat"]{
+ background-color: #2f3129;
+ padding: 5px;
+ color:white;
+ font-weight: bold;
+ font-size: 10px;
+}
+afx-app-window[data-id="win-remote-run"] afx-resizer{
+ border-top: 1px solid #a6a6a6;
+ background-color: #2f3129;
+ border-right: 0;
+}
+afx-app-window[data-id="win-remote-run"] afx-hbox[data-id="bottom-vbox"] {
+ background-color:#2f3129;
+}
+afx-app-window[data-id="win-remote-run"] afx-hbox[data-id="bottom-vbox"] afx-button button{
+ background-color:#2f3129;
+ color:white;
+ border:0;
+ border-radius: 0;
}
\ No newline at end of file