diff --git a/LuaPlayground/build/debug/main.js b/LuaPlayground/build/debug/main.js
index 9cb6762..5ce093f 100644
--- a/LuaPlayground/build/debug/main.js
+++ b/LuaPlayground/build/debug/main.js
@@ -1,4 +1,5 @@
(function() {
+ void 0;
var DataViewer, LuaPlayground, PointCloudViewer;
DataViewer = class DataViewer {
@@ -175,7 +176,7 @@
}
- // point clound render
+ // point clound render
render() {
var end, j, len, path, ref, start, v;
this.drawGrid(20, "#DBDBDB"); // 20 px
@@ -204,42 +205,44 @@
}
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"
+ highlightActiveLine: true,
+ highlightSelectedWord: true,
+ behavioursEnabled: true,
+ wrap: true,
+ fontSize: "11pt",
+ showInvisibles: true
});
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();
+ this.on("vboxchange", () => {
+ return this.editor.resize();
});
- (this.find("log-clear")).set("onbtclick", function(e) {
- return me.log("clean");
+ (this.find("log-clear")).set("onbtclick", (e) => {
+ return this.log("clean");
});
- (this.find("code-run")).set("onbtclick", function(e) {
- return me.run();
+ (this.find("code-run")).set("onbtclick", (e) => {
+ return this.run();
});
- (this.find("code-stop")).set("onbtclick", function(e) {
- if (me.socket) {
- return me.socket.close();
+ (this.find("code-stop")).set("onbtclick", (e) => {
+ if (this.socket) {
+ return this.socket.close();
}
});
this.socket = null;
- return this.bindKey("CTRL-R", function() {
- return me.run();
+ return this.bindKey("CTRL-R", () => {
+ return this.run();
});
}
menu() {
- var me, menu;
- me = this;
+ var menu;
menu = [
{
text: "__(Code)",
@@ -250,8 +253,8 @@
shortcut: "C-R"
}
],
- onmenuselect: function(e) {
- return me.run();
+ onchildselect: (e) => {
+ return this.run();
}
}
];
@@ -270,39 +273,42 @@
}
run() {
- var me, value;
- me = this;
+ var value;
value = this.editor.getValue().trim();
if (!(value && value !== "")) {
return;
}
- this.socket = this.stream();
- this.socket.onopen = function() {
- //send data to server
- return me.socket.send(JSON.stringify({
- code: value
- }));
- };
- this.socket.onmessage = function(e) {
- var err, obj;
- if (!e.data) {
- return;
- }
- try {
- obj = JSON.parse(e.data);
- if (!me.view(obj)) {
- return me.log("INFO", e.data);
+ return this.stream().then((s) => {
+ this.socket = s;
+ this.socket.onopen = () => {
+ //send data to server
+ return this.socket.send(JSON.stringify({
+ code: value
+ }));
+ };
+ this.socket.onmessage = (e) => {
+ var err, obj;
+ if (!e.data) {
+ return;
}
- } catch (error) {
- err = error;
- me.log("INFO", e.data);
- return console.log(err);
- }
- };
- return this.socket.onclose = function() {
- me.socket = null;
- return console.log("socket closed");
- };
+ try {
+ obj = JSON.parse(e.data);
+ if (!this.view(obj)) {
+ return this.log("INFO", e.data);
+ }
+ } catch (error) {
+ err = error;
+ this.log("INFO", e.data);
+ return console.log(err);
+ }
+ };
+ return this.socket.onclose = () => {
+ this.socket = null;
+ return console.log("socket closed");
+ };
+ }).catch((e) => {
+ return this.error(__("Unable to get websocket stream"));
+ });
}
view(obj) {
@@ -330,7 +336,7 @@
};
- LuaPlayground.dependencies = ["ace/ace"];
+ LuaPlayground.dependencies = ["os://scripts/ace/ace.js"];
this.OS.register("LuaPlayground", LuaPlayground);
diff --git a/LuaPlayground/build/release/LuaPlayground.zip b/LuaPlayground/build/release/LuaPlayground.zip
new file mode 100644
index 0000000..0087b14
Binary files /dev/null and b/LuaPlayground/build/release/LuaPlayground.zip differ
diff --git a/LuaPlayground/coffees/main.coffee b/LuaPlayground/coffees/main.coffee
index e6f098c..73e27f8 100644
--- a/LuaPlayground/coffees/main.coffee
+++ b/LuaPlayground/coffees/main.coffee
@@ -147,38 +147,41 @@ class LuaPlayground extends this.OS.GUI.BaseApplication
super "LuaPlayground", args
main: () ->
- me = @
@datarea = @find "editorea"
@output = @find "output"
@.editor = ace.edit @datarea
@.editor.setOptions {
enableBasicAutocompletion: true,
enableLiveAutocompletion: true,
- fontSize: "10pt"
+ highlightActiveLine: true,
+ highlightSelectedWord: true,
+ behavioursEnabled: true,
+ wrap: true,
+ fontSize: "11pt",
+ showInvisibles: true
}
@editor.getSession().setUseWrapMode true
@editor.session.setMode "ace/mode/lua"
@editor.setTheme "ace/theme/monokai"
- @on "vboxchange", () ->
- me.editor.resize()
- (@find "log-clear").set "onbtclick", (e) ->
- me.log "clean"
- (@find "code-run").set "onbtclick", (e) ->
- me.run()
+ @on "vboxchange", () =>
+ @editor.resize()
+ (@find "log-clear").set "onbtclick", (e) =>
+ @log "clean"
+ (@find "code-run").set "onbtclick", (e) =>
+ @run()
- (@find "code-stop").set "onbtclick", (e) ->
- me.socket.close() if me.socket
+ (@find "code-stop").set "onbtclick", (e) =>
+ @socket.close() if @socket
@socket = null
- @bindKey "CTRL-R", () -> me.run()
+ @bindKey "CTRL-R", () => @run()
menu: () ->
- me = @
menu = [{
text: "__(Code)",
child: [
{ text: "__(Run)", dataid: "#{@name}-Run", shortcut: "C-R" }
],
- onmenuselect: (e) -> me.run()
+ onchildselect: (e) => @run()
}]
menu
@@ -190,26 +193,27 @@ class LuaPlayground extends this.OS.GUI.BaseApplication
($ @output).scrollTop @output.scrollHeight
run: () ->
- me = @
value = @editor.getValue().trim()
return unless value and value isnt ""
- @socket = @stream()
- @socket.onopen = () ->
- #send data to server
- me.socket.send( JSON.stringify { code: value } )
-
- @socket.onmessage = (e) ->
- return unless e.data
- try
- obj = JSON.parse e.data
- me.log "INFO", e.data unless me.view obj
- catch err
- me.log "INFO", e.data
- console.log err
-
- @socket.onclose = () ->
- me.socket = null
- console.log "socket closed"
+ @stream().then (s) =>
+ @socket = s
+ @socket.onopen = () =>
+ #send data to server
+ @socket.send( JSON.stringify { code: value } )
+
+ @socket.onmessage = (e) =>
+ return unless e.data
+ try
+ obj = JSON.parse e.data
+ @log "INFO", e.data unless @view obj
+ catch err
+ @log "INFO", e.data
+ console.log err
+
+ @socket.onclose = () =>
+ @socket = null
+ console.log "socket closed"
+ .catch (e) => @error __("Unable to get websocket stream")
view: (obj) ->
return false unless obj and obj.type and @[obj.type]
@@ -226,5 +230,5 @@ class LuaPlayground extends this.OS.GUI.BaseApplication
cleanup: (e)->
@socket.close() if @socket
-LuaPlayground.dependencies = ["ace/ace"]
+LuaPlayground.dependencies = ["os://scripts/ace/ace.js"]
this.OS.register "LuaPlayground", LuaPlayground
diff --git a/LuaPlayground/project.apj b/LuaPlayground/project.apj
deleted file mode 100644
index e8e147d..0000000
--- a/LuaPlayground/project.apj
+++ /dev/null
@@ -1 +0,0 @@
-{"name":"LuaPlayground","root":"home://myws/antosdk-apps/LuaPlayground","css":["css/main.css"],"javascripts":["javascripts/paper-core.min.js"],"coffees":["coffees/main.coffee"],"copies":["assets/scheme.html","package.json","README.md"]}
\ No newline at end of file
diff --git a/LuaPlayground/project.json b/LuaPlayground/project.json
new file mode 100644
index 0000000..abaccc8
--- /dev/null
+++ b/LuaPlayground/project.json
@@ -0,0 +1,8 @@
+{
+ "name": "LuaPlayground",
+ "root": "home://workspace/antosdk-apps/LuaPlayground",
+ "css": ["css/main.css"],
+ "javascripts": ["javascripts/paper-core.min.js"],
+ "coffees": ["coffees/main.coffee"],
+ "copies": ["assets/scheme.html", "package.json", "README.md"]
+}
\ No newline at end of file
diff --git a/OpenPage/README.md b/OpenPage/README.md
index 9dcf530..d9dfca7 100644
--- a/OpenPage/README.md
+++ b/OpenPage/README.md
@@ -1,24 +1,14 @@
-# OpenPage
-This is an example project, generated by AntOS Development Kit
+![](https://os.lxsang.me/repo/OpenPage/OpenPage.png)
+# OpenPage: ODT (Open Document Text) editor alpha
+**OpenPage** is an AntOS application developed in-browser using AntOSDK. It is a Pure Javascript based rich text editor compatible with Open Document Format.
-## Howto
-
-1. Open the project.apj file with AntOSDK (simply double Click on it)
-2. Modify the UI in *assets/scheme.html*
-3. Modify application code in *coffees/main.coffee*
-4. Modify CSS style in *css/main.css*
-5. Other files need to be copied: put in to assets
-
-## Set up build target
-
-Click **Menu> Build > Build Option** or simply hit **ALT-Y**
-
-In the build options dialog, add or remove files that need to be
-included into the build
-
-Click **Save**
-
-## Build application
-* To build: **Menu > Build > Build** or **ALT-C**
-* To build and run: **Menu > Build > Build and Run** or **CTRL-R**
-* To release: **Menu > Build > Build release** or **ALT-P**
\ No newline at end of file
+**Feature:**
+* Open, view and edit *.odt* documents
+* Offer various formatting style to text
+* Define and apply paragraph styles
+* Insert link, image
+* Embeded fonts
+* Save documents as ODF format so that it can be compatible with desktop applications like Open Office
+
+**Credit:**
+OpenPage is heavily based on the WebODF javascript library: https://webodf.org
\ No newline at end of file
diff --git a/OpenPage/assets/OpenPage.md b/OpenPage/assets/OpenPage.md
deleted file mode 100644
index d9dfca7..0000000
--- a/OpenPage/assets/OpenPage.md
+++ /dev/null
@@ -1,14 +0,0 @@
-![](https://os.lxsang.me/repo/OpenPage/OpenPage.png)
-# OpenPage: ODT (Open Document Text) editor alpha
-**OpenPage** is an AntOS application developed in-browser using AntOSDK. It is a Pure Javascript based rich text editor compatible with Open Document Format.
-
-**Feature:**
-* Open, view and edit *.odt* documents
-* Offer various formatting style to text
-* Define and apply paragraph styles
-* Insert link, image
-* Embeded fonts
-* Save documents as ODF format so that it can be compatible with desktop applications like Open Office
-
-**Credit:**
-OpenPage is heavily based on the WebODF javascript library: https://webodf.org
\ No newline at end of file
diff --git a/OpenPage/build/debug/main.js b/OpenPage/build/debug/main.js
index 9a9b769..df39f39 100644
--- a/OpenPage/build/debug/main.js
+++ b/OpenPage/build/debug/main.js
@@ -1,4 +1,5 @@
(function() {
+ void 0;
var FormatDialog, HyperLinkDialog, OpenPage;
OpenPage = class OpenPage extends this.OS.GUI.BaseApplication {
@@ -114,7 +115,7 @@
newdoc() {
var blank;
- blank = `${(this.meta().path)}/blank.odt`;
+ blank = `${this.meta().path}/blank.odt`;
return this.open(blank, true);
}
@@ -1167,7 +1168,119 @@
};
- FormatDialog.scheme = "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce laoreet diam vestibulum massa malesuada quis dignissim libero blandit. Duis sit amet volutpat nisl.
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n";
+ FormatDialog.scheme = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce laoreet diam vestibulum massa malesuada quis dignissim libero blandit. Duis sit amet volutpat nisl.
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
}).call(this);
diff --git a/OpenPage/coffees/main.coffee b/OpenPage/coffees/main.coffee
index 4fdd212..4a11b9c 100644
--- a/OpenPage/coffees/main.coffee
+++ b/OpenPage/coffees/main.coffee
@@ -66,6 +66,7 @@ class OpenPage extends this.OS.GUI.BaseApplication
newdoc: () ->
blank = "#{@meta().path}/blank.odt"
@open blank, true
+
open: (p,b) ->
me = @
@pathAsDataURL(p)
diff --git a/OpenPage/project.apj b/OpenPage/project.apj
deleted file mode 100644
index 24a8569..0000000
--- a/OpenPage/project.apj
+++ /dev/null
@@ -1 +0,0 @@
-{"name":"OpenPage","root":"home://workspace/OpenPage","css":["css/main.css","css/dialog.css"],"javascripts":["javascripts/webodf.js","javascripts/EditorSession.js"],"coffees":["coffees/main.coffee","coffees/dialogs.coffee"],"copies":["assets/scheme.html","package.json","assets/OpenPage.md","assets/icon.png","assets/blank.odt"]}
\ No newline at end of file
diff --git a/OpenPage/project.json b/OpenPage/project.json
new file mode 100644
index 0000000..ffd90a5
--- /dev/null
+++ b/OpenPage/project.json
@@ -0,0 +1,8 @@
+{
+ "name": "OpenPage",
+ "root": "home://workspace/antosdk-apps/OpenPage",
+ "css": ["css/main.css", "css/dialog.css"],
+ "javascripts": ["javascripts/webodf.js", "javascripts/EditorSession.js"],
+ "coffees": ["coffees/main.coffee", "coffees/dialogs.coffee"],
+ "copies": ["assets/scheme.html", "package.json", "assets/icon.png", "assets/blank.odt"]
+}
\ No newline at end of file
diff --git a/Preview/build/debug/main.css b/Preview/build/debug/main.css
index fb523a2..555c20c 100644
--- a/Preview/build/debug/main.css
+++ b/Preview/build/debug/main.css
@@ -8,20 +8,26 @@ afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div[data-i
background-repeat: repeat;
}
-afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div[data-id = "status"]
+afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] afx-hbox[data-id = "statcontainer"]
{
background-color: transparent;
- border-top: 1px solid #cbcbcb;
- padding-left: 10px;
- padding-top: 3px;
+ border-bottom: 1px solid #cbcbcb;
+}
+afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] afx-hbox[data-id = "statcontainer"] button,
+afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] afx-hbox[data-id = "statcontainer"] input
+{
+ height: 24px;
}
-
afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] canvas{
margin-left: auto;
margin-right: auto;
display: block;
}
+afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div.pdf-page {
+ margin-bottom: 5px;
+}
+
afx-app-window[data-id = "preview-win"] afx-vbox[data-id="container"] div[data-id = "view"].image
{
display: flex;
diff --git a/Preview/build/debug/main.js b/Preview/build/debug/main.js
index f3aa5c6..62b4600 100644
--- a/Preview/build/debug/main.js
+++ b/Preview/build/debug/main.js
@@ -25,18 +25,62 @@
}
main() {
+ this.currfile = void 0;
if (this.args && this.args.length > 0) {
this.currfile = this.args[0].path.asFileHandle();
}
this.view = this.find("view");
this.status = this.find("status");
+ this.zoom = this.find("zoom");
+ this.btnext = this.find("btnext");
+ this.btprev = this.find("btprev");
+ this.btreset = this.find("btreset");
+ this.txtpage = this.find("txtpage");
+ this.zoom.set("onchange", (e) => {
+ return this.setViewScale(e.data);
+ });
+ this.btreset.set("onbtclick", (e) => {
+ this.zoom.set("value", 100);
+ return this.setViewScale(100);
+ });
+ this.btnext.set("onbtclick", (e) => {
+ var val;
+ val = parseInt($(this.txtpage).val());
+ if (isNaN(val)) {
+ return;
+ }
+ $(this.txtpage).val(val + 1);
+ return this.gotoPage();
+ });
+ this.btprev.set("onbtclick", (e) => {
+ var val;
+ val = parseInt($(this.txtpage).val());
+ if (isNaN(val)) {
+ return;
+ }
+ $(this.txtpage).val(val - 1);
+ return this.gotoPage();
+ });
+ $(this.txtpage).keyup((e) => {
+ if (e.which !== 13) {
+ return;
+ }
+ if (!this.pdf) {
+ return;
+ }
+ return this.gotoPage();
+ });
PDFJS.workerSrc = `${this.path()}/pdf.worker.js`.asFileHandle().getlink();
+ this.pdf = void 0;
+ this.img = void 0;
this.bindKey("ALT-O", () => {
return this.actionFile(`${this.name}-Open`);
});
this.bindKey("CTRL-X", () => {
return this.actionFile(`${this.name}-Close`);
});
+ this.zoom.set("max", 200);
+ this.zoom.set("value", 100);
return this.open(this.currfile);
}
@@ -49,25 +93,46 @@
}
return file.onready().then(() => {
file.info.size = (file.info.size / 1024).toFixed(2);
- return this.renderFile(file);
+ return this.renderFile();
}).catch((err) => {
return this.error(__("File not found {0}", file.path), err);
});
}
- renderFile(file) {
- var mime;
- mime = file.info.mime;
- if (!mime) {
+ gotoPage() {
+ var val;
+ if (!this.pdf) {
+ return;
+ }
+ val = parseInt($(this.txtpage).val());
+ if (isNaN(val)) {
+ return;
+ }
+ if (val <= 0 || val > this.pdf.numPages) {
return;
}
($(this.view)).empty();
+ return this.renderPDFPages(val, this.zoom.get("value") / 100, false).catch((e) => {
+ return this.error(__("Unable to render page {0}", val), e);
+ });
+ }
+
+ renderFile() {
+ var mime;
+ mime = this.currfile.info.mime;
+ if (!mime) {
+ return;
+ }
+ this.pdf = void 0;
+ this.img = void 0;
+ ($(this.view)).empty();
+ this.zoom.set("value", 100);
if (mime.match(/^[^\/]+\/.*pdf.*/g)) {
- return this.renderPDF(file);
+ return this.renderPDF();
} else if (mime.match(/image\/.*svg.*/g)) {
- return this.renderSVG(file);
+ return this.renderSVG();
} else if (mime.match(/image\/.*/g)) {
- return this.renderImage(file);
+ return this.renderImage();
} else {
return this.notify(__("Mime type {0} is not supported", file.info.mime));
}
@@ -77,44 +142,92 @@
return ($(this.status)).html(t);
}
- renderPDF(file) {
- return this.load(new Promise((resolve, reject) => {
+ setViewScale(value) {
+ var canvas, context, h, mime, scale, w;
+ if (!this.currfile) {
+ return;
+ }
+ mime = this.currfile.info.mime;
+ scale = value / 100;
+ if (mime.match(/^[^\/]+\/.*pdf.*/g)) {
+ if (!this.pdf) {
+ return;
+ }
+ ($(this.view)).empty();
+ return this.load(this.renderPDFPages(1, scale)).catch((e) => {
+ return this.error(__("Unable to set view scale"), e);
+ });
+ } else if (mime.match(/image\/.*svg.*/g)) {
+ return $($(this.view).children()[0]).css("width", `${Math.round(value)}%`).css("height", `${Math.round(value)}%`);
+ } else if (mime.match(/image\/.*/g)) {
+ if (!this.img) {
+ return;
+ }
+ canvas = $(this.view).children()[0];
+ context = canvas.getContext('2d');
+ w = this.img.width * scale;
+ h = this.img.height * scale;
+ canvas.height = h;
+ canvas.width = w;
+ context.clearRect(0, 0, canvas.width, canvas.height);
+ context.scale(scale, scale);
+ return context.drawImage(this.img, 0, 0);
+ }
+ }
+
+ renderPDFPages(n, scale, recursive) {
+ return new Promise((resolve, reject) => {
var status;
- status = `${file.info.name} (${file.info.size} Kb)`;
- return file.read("binary").then((d) => {
+ status = `${this.currfile.info.name} (${this.currfile.info.size} Kb)`;
+ if (n > this.pdf.numPages) {
+ return resolve();
+ }
+ return this.pdf.getPage(n).then((page) => {
+ var canvas, context, div, renderContext, viewport;
+ viewport = page.getViewport(scale);
+ div = ($("
")).attr("id", "page-" + (page.pageIndex + 1)).attr("scale", scale).addClass("pdf-page");
+ ($(this.view)).append(div);
+ canvas = ($("