update code

This commit is contained in:
Xuan Sang LE 2020-06-05 17:45:07 +02:00
parent aae08d9efe
commit 676cce26c2
61 changed files with 685 additions and 264 deletions

View File

@ -1 +1 @@
(function(){var t;(t=class extends this.OS.GUI.BaseApplication{constructor(t){super("About",t)}main(){var t,n;return t=this,this.container=this.find("container"),(n="os://README.md").asFileHandle().read().then((function(n){var e;return e=new showdown.Converter,$(t.container).html(e.makeHtml(n))})).catch(()=>this.notify(__("Unable to read: {0}",n))),this.find("btnclose").set("onbtclick",()=>this.quit())}}).singleton=!0,t.dependencies=["os://scripts/showdown.min.js"],this.OS.register("About",t)}).call(this);
(function(){var t;(t=class extends this.OS.application.BaseApplication{constructor(t){super("About",t)}main(){var t,n;return t=this,this.container=this.find("container"),(n="os://README.md").asFileHandle().read().then((function(n){var i;return i=new showdown.Converter,$(t.container).html(i.makeHtml(n))})).catch(()=>this.notify(__("Unable to read: {0}",n))),this.find("btnclose").onbtclick=()=>this.quit()}}).singleton=!0,t.dependencies=["os://scripts/showdown.min.js"],this.OS.register("About",t)}).call(this);

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.2-a",
"version":"0.0.3-a",
"category":"Other",
"iconclass":"fa fa-question-circle",
"mimes":["none"],

Binary file not shown.

View File

@ -1,4 +1,4 @@
class About extends this.OS.GUI.BaseApplication
class About extends this.OS.application.BaseApplication
constructor: ( args ) ->
super "About", args
@ -14,7 +14,7 @@ class About extends this.OS.GUI.BaseApplication
.catch () =>
@notify __("Unable to read: {0}", path)
@find("btnclose").set "onbtclick", () =>
@find("btnclose").onbtclick = () =>
@quit()
About.singleton = true

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.2-a",
"version":"0.0.3-a",
"category":"Other",
"iconclass":"fa fa-question-circle",
"mimes":["none"],

View File

@ -1 +1 @@
(function(){var t,i,e;e=this.OS.PM,i=this.OS.APP,(t=class extends this.OS.GUI.BaseApplication{constructor(t){super("ActivityMonitor",t)}main(){var t;return this.scheme.set("apptitle","Activity Monitor"),this.grid=this.find("mygrid"),this.on("btclick",t=>{var i,s,a;if("btkill"===t.id&&(a=this.grid.get("selectedRow")))return s=a.get("data")[0],(i=e.appByPid(s.text))?i.quit(!0):void 0}),t=[{width:50,text:"__(Pid)"},{text:"__(Name)"},{text:"__(Type)",width:80},{width:80,text:"__(Alive (ms))"}],this.gdata={processes:{},alive:[]},this.grid.set("header",t),this.monitor()}monitor(){var t;return this.gdata.alive=[],t=(new Date).getTime(),$.each(e.processes,(e,s)=>$.each(s,(e,s)=>(this.gdata.processes[s.pid]?(this.gdata.processes[s.pid][3].text=t-s.birth,this.gdata.processes[s.pid][3].domel.update()):(this.gdata.processes[s.pid]=[{text:s.pid},{icon:1===i[s.name].type?i[s.name].meta.icon:s.icon,iconclass:1===i[s.name].type?i[s.name].meta.iconclass:s.iconclass,text:s.name},{text:1===i[s.name].type?"__(Application)":"__(Service)"},{text:t-s.birth}],this.grid.push(this.gdata.processes[s.pid])),this.gdata.alive.push(s.pid)))),$.each(this.gdata.processes,(t,i)=>{if($.inArray(Number(t),this.gdata.alive)<0)return this.grid.remove(this.gdata.processes[t].domel),this.gdata.processes[t]=void 0,delete this.gdata.processes[t]}),this.timer=setTimeout(()=>this.monitor(),500)}cleanup(t){if(this.timer)return clearTimeout(this.timer)}}).singleton=!0,this.OS.register("ActivityMonitor",t)}).call(this);
(function(){var t,i,e;e=this.OS.PM,i=this.OS.application,(t=class extends this.OS.application.BaseApplication{constructor(t){super("ActivityMonitor",t)}main(){var t;return this.scheme.apptitle="Activity Monitor",this.grid=this.find("mygrid"),this.on("btclick",t=>{var i,s,a;if("btkill"===t.id&&(a=this.grid.selectedRow))return s=a.data[0],(i=e.appByPid(s.text))?i.quit(!0):void 0}),t=[{width:50,text:"__(Pid)"},{text:"__(Name)"},{text:"__(Type)",width:80},{width:80,text:"__(Alive (ms))"}],this.gdata={processes:{},alive:[]},this.grid.header=t,this.monitor()}monitor(){var t;return this.gdata.alive=[],t=(new Date).getTime(),$.each(e.processes,(e,s)=>$.each(s,(e,s)=>(this.gdata.processes[s.pid]?(this.gdata.processes[s.pid][3].text=t-s.birth,this.gdata.processes[s.pid][3].domel.update()):(this.gdata.processes[s.pid]=[{text:s.pid},{icon:1===i[s.name].type?i[s.name].meta.icon:s.icon,iconclass:1===i[s.name].type?i[s.name].meta.iconclass:s.iconclass,text:s.name},{text:1===i[s.name].type?"__(Application)":"__(Service)"},{text:t-s.birth}],this.grid.push(this.gdata.processes[s.pid])),this.gdata.alive.push(s.pid)))),$.each(this.gdata.processes,(t,i)=>{if($.inArray(Number(t),this.gdata.alive)<0)return this.grid.delete(this.gdata.processes[t].domel),this.gdata.processes[t]=void 0,delete this.gdata.processes[t]}),this.timer=setTimeout(()=>this.monitor(),500)}cleanup(t){if(this.timer)return clearTimeout(this.timer)}}).singleton=!0,this.OS.register("ActivityMonitor",t)}).call(this);

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.2-a",
"version":"0.0.4-a",
"category":"System",
"iconclass":"fa fa-heartbeat",
"mimes":["none"]

View File

@ -16,18 +16,18 @@
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
_PM = this.OS.PM
_APP = this.OS.APP
class ActivityMonitor extends this.OS.GUI.BaseApplication
_APP = this.OS.application
class ActivityMonitor extends this.OS.application.BaseApplication
constructor: (args) ->
super "ActivityMonitor", args
main: () ->
@scheme.set "apptitle", "Activity Monitor"
@scheme.apptitle = "Activity Monitor"
@grid = @find "mygrid"
@on "btclick", (e) =>
return unless e.id == "btkill"
item = @grid.get "selectedRow"
item = @grid.selectedRow
return unless item
data = item.get("data")[0]
data = item.data[0]
app = _PM.appByPid data.text
app.quit(true) if app
@ -52,7 +52,7 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
processes: {}
alive: []
}
@grid.set "header", header
@grid.header = header
@monitor()
monitor: () ->
@ -84,7 +84,7 @@ class ActivityMonitor extends this.OS.GUI.BaseApplication
$.each @gdata.processes, (i, e) =>
if ($.inArray (Number i), @gdata.alive) < 0
@grid.remove @gdata.processes[i].domel
@grid.delete @gdata.processes[i].domel
@gdata.processes[i] = undefined
delete @gdata.processes[i]

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.2-a",
"version":"0.0.4-a",
"category":"System",
"iconclass":"fa fa-heartbeat",
"mimes":["none"]

View File

@ -1,4 +1,4 @@
# Blogger
Blackend for my blog at
"katex/fonts",
Blackend for my blog at https://blog.iohub.dev

View File

@ -1,4 +1,3 @@
# Blogger
Blackend for my blog at
Blackend for my blog at https://blog.iohub.dev
"katex/fonts",

View File

@ -26,7 +26,7 @@ afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-lab
afx-app-window .lbl-header i.label-text{
font-weight: bold;
}
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="cv-container"] afx-label.cat-header{
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="cv-container"] .cat-header{
border-bottom: 1px solid #cbcbcb;
text-align: center;
}

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.7-a",
"version":"0.0.9-a",
"category":"Internet",
"iconclass":"fa fa-book",
"mimes":["none"]

Binary file not shown.

View File

@ -17,24 +17,24 @@
#along with this program. If not, see https://www.gnu.org/licenses/.
class BloggerCategoryDialog extends this.OS.GUI.BasicDialog
constructor: () ->
super "BloggerCategoryDialog"
super "BloggerCategoryDialog", BloggerCategoryDialog.scheme
main: () ->
super.main()
@tree = @find "tree"
@txtinput = @find "txtinput"
(@find "bt-ok").set "onbtclick", (e) =>
sel = @tree.get "selectedItem"
(@find "bt-ok").onbtclick = (e) =>
sel = @tree.selectedItem
return @notify __("Please select a parent category") unless sel
seldata = sel.get "data"
seldata = sel.data
val = @txtinput.value
return @notify __("Please enter category name") if val is "" and not @data.selonly
return @notify __("Parent can not be the category itself") if @data.cat and @data.cat.id is seldata.id
@handle { p: seldata, value: val } if @handle
@quit()
(@find "bt-cancel").set "onbtclick", (e) =>
(@find "bt-cancel").onbtclick = (e) =>
@quit()
if @data and @data.tree
if @data and @data.cat
@ -44,7 +44,7 @@ class BloggerCategoryDialog extends this.OS.GUI.BasicDialog
else
seldata = @findDataByID @data.cat.pid, @data.tree.nodes
seldata.selected = true if seldata
@tree.set "data", @data.tree
@tree.data = @data.tree
@tree.expandAll()
# TODO set selected category name
@ -62,10 +62,13 @@ BloggerCategoryDialog.scheme = """
<afx-tree-view data-id="tree" ></afx-tree-view>
<afx-label text="__(Category name)" data-height="25" class="lbl-header" ></afx-label>
<input type="text" data-height="25" data-id = "txtinput"/ >
<div data-height = '30' style=' text-align:right;padding:3px;'>
<afx-button data-id = "bt-ok" text = "__(Ok)"></afx-button>
<afx-button data-id = "bt-cancel" text = "__(Cancel)"></afx-button>
</div>
<afx-hbox data-height = '30'>
<div style=' text-align:right;'>
<afx-button data-id = "bt-ok" text = "__(Ok)"></afx-button>
<afx-button data-id = "bt-cancel" text = "__(Cancel)"></afx-button>
</div>
<div data-width="5"></div>
</afx-hbox>
</afx-vbox>
</afx-app-window>
"""
@ -89,15 +92,15 @@ class BloggerCVSectionDiaglog extends this.OS.GUI.BasicDialog
inputs = @select "[input-class='user-input']"
(($ v).val @data.section[v.name] for v in inputs ) if @data and @data.section
@editor.value @data.section.content if @data and @data.section
(@find "section-publish").set "swon", (if @data and @data.section and Number(@data.section.publish) then true else false)
(@find "bt-cv-sec-save").set "onbtclick", (e) =>
(@find "section-publish").swon = (if @data and @data.section and Number(@data.section.publish) then true else false)
(@find "bt-cv-sec-save").onbtclick = (e) =>
data = {}
data[v.name] = ($ v).val() for v in inputs
data.content = @editor.value()
return @notify __("Title or content must not be blank") if data.title is "" and data.content is ""
#return @notify "Content must not be blank" if data.content is ""
data.id = @data.section.id if @data and @data.section
val = (@find "section-publish").get "swon"
val = (@find "section-publish").swon
if val is true
data.publish = 1
else
@ -136,12 +139,12 @@ class BloggerSendmailDiaglog extends this.OS.GUI.BasicDialog
v.text = v.name
v.switch = true
v.checked = true
@maillinglist.set "items", d
@maillinglist. items = d
.catch (e) =>
@error __("Cannot fetch subscribers data: {0}", e.toString()), e
(@find "bt-sendmail").set "onbtclick", (e) =>
items = @maillinglist.get "items"
(@find "bt-sendmail").onbtclick = (e) =>
items = @maillinglist.items
emails = []
for v in items
if v.checked is true

View File

@ -15,16 +15,16 @@
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
class Blogger extends this.OS.GUI.BaseApplication
class Blogger extends this.OS.application.BaseApplication
constructor: (args) ->
super "Blogger", args
main: () ->
@user = {}
@cvlist = @find "cv-list"
@cvlist.set "ontreeselect", (d) =>
@cvlist.ontreeselect = (d) =>
return unless d
data = d.data.item.get "data"
data = d.data.item.data
@CVSectionByCID Number(data.id)
@inputtags = @.find "input-tags"
@ -38,13 +38,13 @@ class Blogger extends this.OS.GUI.BaseApplication
@tabcontainer = @find "tabcontainer"
@tabcontainer.set "ontabselect", (e) =>
@fetchData e.data.container.aid()
@tabcontainer.ontabselect = (e) =>
@fetchData e.data.container.aid
(@find "bt-user-save").set "onbtclick", (e) =>
(@find "bt-user-save").onbtclick = (e) =>
@saveUser()
(@find "cv-cat-add").set "onbtclick", (e) =>
(@find "cv-cat-add").onbtclick = (e) =>
@fetchCVCat().then (tree) =>
@openDialog(new BloggerCategoryDialog(), {
title: __("Add category"),
@ -61,10 +61,10 @@ class Blogger extends this.OS.GUI.BaseApplication
.catch (e) => @error e.toString(), e
.catch (e) => @error __("Unable to fetch categories"), e
(@find "cv-cat-edit").set "onbtclick", (e) =>
sel = @cvlist.get "selectedItem"
(@find "cv-cat-edit").onbtclick = (e) =>
sel = @cvlist.selectedItem
return unless sel
cat = sel.get "data"
cat = sel.data
return unless cat
@fetchCVCat().then (tree) =>
@openDialog(new BloggerCategoryDialog(), {
@ -84,10 +84,10 @@ class Blogger extends this.OS.GUI.BaseApplication
@error __("Cannot Edit category"), e
.catch (e) => @error __("Unable to fetch categories"), e
(@find "cv-cat-del").set "onbtclick", (e) =>
sel = @cvlist.get "selectedItem"
(@find "cv-cat-del").onbtclick = (e) =>
sel = @cvlist.selectedItem
return unless sel
cat = sel.get "data"
cat = sel.data
return unless cat
@openDialog("YesNoDialog", {
title: __("Delete category") ,
@ -98,10 +98,10 @@ class Blogger extends this.OS.GUI.BaseApplication
@deleteCVCat cat
.catch (e) => @error e.toString(), e
(@find "cv-sec-add").set "onbtclick", (e) =>
sel = @cvlist.get "selectedItem"
(@find "cv-sec-add").onbtclick = (e) =>
sel = @cvlist.selectedItem
return unless sel
cat = sel.get "data"
cat = sel.data
return @notify __("Please select a category") unless cat and cat.id isnt "0"
@openDialog(new BloggerCVSectionDiaglog(@), {
title: __("New section entry for {0}", cat.name)
@ -115,10 +115,10 @@ class Blogger extends this.OS.GUI.BaseApplication
@CVSectionByCID Number(cat.id)
.catch (e) => @error __("Cannot save section: {0}", e.toString()), e
(@find "cv-sec-move").set "onbtclick", (e) =>
sel = (@find "cv-sec-list").get "selectedItem"
(@find "cv-sec-move").onbtclick = (e) =>
sel = (@find "cv-sec-list").selectedItem
return @notify __("Please select a section to move") unless sel
sec = sel.get "data"
sec = sel.data
@fetchCVCat().then (tree) =>
@openDialog(new BloggerCategoryDialog(),{
@ -136,10 +136,10 @@ class Blogger extends this.OS.GUI.BaseApplication
(@find "cv-sec-list").unselect()
.catch (e) => @error __("Cannot move section"), e
(@find "cv-sec-edit").set "onbtclick", (e) =>
sel = (@find "cv-sec-list").get "selectedItem"
(@find "cv-sec-edit").onbtclick = (e) =>
sel = (@find "cv-sec-list").selectedItem
return @notify __("Please select a section to edit") unless sel
sec = sel.get "data"
sec = sel.data
@openDialog(new BloggerCVSectionDiaglog(@), {
title: __("Modify section entry"),
section: sec
@ -153,10 +153,9 @@ class Blogger extends this.OS.GUI.BaseApplication
@CVSectionByCID Number(sec.cid)
.catch (e) => return @error __("Cannot save section: {0}", e.toString()), e
@seclist .set "onitemclose", (e) =>
@seclist.onitemclose = (e) =>
return unless e
data = e.data.item.get "data"
console.log data
data = e.data.item.data
@openDialog("YesNoDialog", {
iconclass: "fa fa-question-circle",
text: __("Do you really want to delete: {0}?", data.title)
@ -164,7 +163,7 @@ class Blogger extends this.OS.GUI.BaseApplication
return unless b
@cvsecdb.delete data.id
.then (r) =>
@seclist.remove e.data.item
@seclist.delete e.data.item
.catch (e) => @error __("Cannot delete the section: {0}", e.toString()), e
return false
@ -227,35 +226,35 @@ class Blogger extends this.OS.GUI.BaseApplication
name: __("Send mail"),
className: "fa fa-paper-plane",
action: (e) =>
sel = @bloglist.get "selectedItem"
sel = @bloglist.selectedItem
return @error __("No post selected") unless sel
data = sel.get "data"
data = sel.data
@openDialog(new BloggerSendmailDiaglog(@), {
title: __("Send mail"),
content: @editor.value(),
id: data.id
})
.then (d) ->
console.log "test"
console.log "Email sent"
}
]
@bloglist.set "onlistselect", (e) =>
el = @bloglist.get "selectedItem"
@bloglist.onlistselect = (e) =>
el = @bloglist.selectedItem
return unless el
sel = el.get "data"
sel = el.data
return unless sel
@blogdb.get Number(sel.id)
.then (r) =>
@editor.value atob(r.content)
@inputtags.value = r.tags
(@find "blog-publish").set "swon", (if Number(r.publish) then true else false)
(@find "blog-publish").swon = if Number(r.publish) then true else false
.catch (e) =>
@error __("Cannot fetch the entry content"), e
@bloglist.set "onitemclose", (e) =>
@bloglist.onitemclose = (e) =>
return unless e
el = e.data.item
data = el.get "data"
data = el.data
@openDialog("YesNoDialog", {
title: __("Delete a post"),
iconclass: "fa fa-question-circle",
@ -264,15 +263,15 @@ class Blogger extends this.OS.GUI.BaseApplication
return unless b
@blogdb.delete data.id
.then (r) =>
@bloglist.remove el
@bloglist.delete el
@bloglist.unselect()
@clearEditor()
return false
@bindKey "CTRL-S", () =>
sel = @tabcontainer.get "selectedTab"
return unless sel and sel.container.aid() is "blog-container"
sel = @tabcontainer.selectedTab
return unless sel and sel.container.aid is "blog-container"
@saveBlog()
@on "vboxchange", () =>
@resizeContent()
@ -310,14 +309,14 @@ class Blogger extends this.OS.GUI.BaseApplication
# PORFOLIO TAB
refreshCVCat: () ->
@fetchCVCat().then (data) =>
@cvlist.set "data", data
@cvlist.data = data
@cvlist.expandAll()
.catch (e) => @error __("Unable to load categories"), e
fetchCVCat: () ->
new Promise (resolve, reject) =>
data =
name: "Porfolio",
text: "Porfolio",
id:"0",
nodes: []
cnd =
@ -336,6 +335,7 @@ class Blogger extends this.OS.GUI.BaseApplication
return data.nodes = null if result.length is 0
for v in result
v.nodes = []
v.text = v.name
@catListToTree table, v, v.id
#v.nodes = null if v.nodes.length is 0
data.nodes.push v
@ -354,7 +354,7 @@ class Blogger extends this.OS.GUI.BaseApplication
cond = ({ "=": { id: v } } for v in ids)
@cvcatdb.delete({ "or": cond }).then (re) =>
@refreshCVCat()
@seclist.set "data", []
@seclist.data=[]
.catch (e) =>
@error __("Cannot delete the category: {0} [{1}]", cat.name, e.toString()), e
.catch (e) =>
@ -369,7 +369,7 @@ class Blogger extends this.OS.GUI.BaseApplication
start: "DESC"
@cvsecdb.find(cond).then (d) =>
items = []
(@find "cv-sec-status").set "text", __("Found {0} sections", d.length)
(@find "cv-sec-status").text = __("Found {0} sections", d.length)
for v in d
v.closable = true
v.tag = "afx-blogger-cvsection-item"
@ -378,14 +378,14 @@ class Blogger extends this.OS.GUI.BaseApplication
v.start = undefined if v.start < 1000
v.end = undefined if v.end < 1000
items.push v
@seclist.set "data", items
@seclist.data = items
.catch (e) => @error e.toString(), e
# blog
saveBlog: () ->
sel = undefined
selel = @bloglist.get "selectedItem"
sel = selel.get "data" if selel
selel = @bloglist.selectedItem
sel = selel.data if selel
tags = @inputtags.value
content = @editor.value()
title = (new RegExp "^#+(.*)\n", "g").exec content
@ -401,7 +401,7 @@ class Blogger extends this.OS.GUI.BaseApplication
utime: d.timestamp()
utimestr: d.toString()
rendered: @process(@editor.options.previewRender(content))
publish: if ((@find "blog-publish").get "swon") then 1 else 0
publish: if (@find "blog-publish").swon then 1 else 0
data.id = sel.id if sel
#save the data
@blogdb.save data
@ -438,11 +438,11 @@ class Blogger extends this.OS.GUI.BaseApplication
clearEditor:() ->
@.editor.value ""
@.inputtags.value = ""
(@.find "blog-publish").set "swon", false
(@.find "blog-publish").swon = false
# load blog
loadBlogs: () ->
selidx = -1
el = @bloglist.get "selectedItem"
el = @bloglist.selectedItem
selidx = $(el).index()
cond =
order:
@ -458,12 +458,12 @@ class Blogger extends this.OS.GUI.BaseApplication
@blogdb.find cond
.then (r) =>
v.tag = "afx-blogger-post-item" for v in r
@bloglist.set "data", r
@bloglist.data = r
if selidx isnt -1
@bloglist.set "selected", selidx
@bloglist.selected = selidx
else
@clearEditor()
@bloglist.set "selected", -1
@bloglist.selected = -1
.catch (e) => @error __("No post found: {0}", e.toString()), e
resizeContent: () ->

View File

@ -25,7 +25,7 @@ afx-app-window[data-id="blogger-win"] afx-hbox[data-id="user-container"] afx-lab
afx-app-window .lbl-header i.label-text{
font-weight: bold;
}
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="cv-container"] afx-label.cat-header{
afx-app-window[data-id="blogger-win"] afx-hbox[data-id="cv-container"] .cat-header{
border-bottom: 1px solid #cbcbcb;
text-align: center;
}

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.7-a",
"version":"0.0.9-a",
"category":"Internet",
"iconclass":"fa fa-book",
"mimes":["none"]

View File

@ -10,7 +10,7 @@
"api/sendmail.lua",
"sendmail.html",
"package.json",
"README.md",
"katex/fonts"
"katex/fonts",
"README.md"
]
}

View File

@ -1,22 +1,24 @@
Ant = this
class CVSectionListItemTag extends this.OS.GUI.tag["afx-list-item-proto"]
constructor: (r, o) ->
super r, o
class CVSectionListItemTag extends this.OS.GUI.tag.ListViewItemTag
constructor: () ->
super()
__data__: (v) ->
return unless v
ondatachange: () ->
return unless @data
v = @data
nativel = ["content", "start", "end" ]
@set "closable", v.closable
@closable = v.closable
for k, el of @refs
if v[k] and v[k] isnt ""
if nativel.includes k
$(el).text v[k]
else
el.set "text", v[k]
__selected: (v) ->
@get("data").selected = v
el.text = v[k]
reload: () ->
init:() ->
itemlayout: () ->
@ -31,25 +33,26 @@ class CVSectionListItemTag extends this.OS.GUI.tag["afx-list-item-proto"]
{ el: "afx-label", ref: "location", class: "afx-cv-sec-loc" }
] }
this.OS.GUI.define "afx-blogger-cvsection-item", CVSectionListItemTag
this.OS.GUI.tag.define "afx-blogger-cvsection-item", CVSectionListItemTag
class BlogPostListItemTag extends this.OS.GUI.tag["afx-list-item-proto"]
constructor: (r, o) ->
super r, o
class BlogPostListItemTag extends this.OS.GUI.tag.ListViewItemTag
constructor: () ->
super()
__data__: (v) ->
return unless v
ondatachange: (v) ->
return unless @data
v = @data
v.closable = true
@set "closable", v.closable
@refs.title.set "text", v.title
@refs.ctimestr.set "text", __("Created: {0}", v.ctimestr)
@refs.utimestr.set "text", __("Updated: {0}", v.utimestr)
__selected: (v) ->
@get("data").selected = v
@closable = v.closable
@refs.title.text = v.title
@refs.ctimestr.text = __("Created: {0}", v.ctimestr)
@refs.utimestr.text = __("Updated: {0}", v.utimestr)
reload: () ->
init:() ->
itemlayout: () ->
{ el: "div", children: [
{ el: "afx-label", ref: "title", class: "afx-blogpost-title" },
@ -57,4 +60,4 @@ class BlogPostListItemTag extends this.OS.GUI.tag["afx-list-item-proto"]
{ el: "afx-label", ref: "utimestr", class: "blog-dates" },
] }
this.OS.GUI.define "afx-blogger-post-item", BlogPostListItemTag
this.OS.GUI.tag.define "afx-blogger-post-item", BlogPostListItemTag

View File

@ -1,3 +1,4 @@
#LuaPlayground
Application for serverside code testing and analytics tool
Application for serverside code testing and analytics tool.
It allows to execute lua code on the server from the browser

View File

@ -1,4 +1,4 @@
<afx-app-window apptitle="Lua Playground" width="500" height="400" data-id="LuaPlayground">
<afx-app-window apptitle="Lua Playground" width="500" height="400" data-id="Lua Playground">
<afx-hbox >
<div data-id="editorea" data-width="250"></div>
<afx-resizer data-width="3"></afx-resizer>

View File

@ -1,4 +1,4 @@
(function(){var e,i,n;e=class{constructor(t){this.target=t,this.el=$("<canvas>").attr("class","viewer")[0],this.offset=10,this.points=[],this.preprocess(),this.getBound(),this.prepare(),this.render()}canvasPoint(e){return new t.Point(e[0]/this.target.resolution+this.base.x,-e[1]/this.target.resolution+this.base.y)}preprocess(){return this.points=this.target.data}getBound(){var t,e,i,n,r,s,a,o;for(n={x:0,y:0},i={x:0,y:0},t=0,e=(r=this.points).length;t<e;t++)a=(s=r[t])[0]/this.target.resolution,o=s[1]/this.target.resolution,a<n.x&&(n.x=a),o<n.y&&(n.y=o),a>i.x&&(i.x=a),o>i.y&&(i.y=o);return this.bound=[n,i],this.base={x:0-this.bound[0].x+this.offset,y:this.bound[1].y+this.offset},this.width=i.x-n.x+2*this.offset,this.height=i.y-n.y+2*this.offset}drawPoint(e,i,n){return new t.Path.Circle({center:this.canvasPoint(e),radius:n,fillColor:i})}drawGrid(e,i){var n,r,s,a,o,h;for(h=this.target.resolution*e,r=Math.ceil(this.bound[0].x/e);r*e<this.bound[1].x;)a=new t.Point(r*e+this.base.x,-this.bound[0].y+this.base.y),n=new t.Point(r*e+this.base.x,-this.bound[1].y+this.base.y),(s=new t.Path).strokeColor=i,s.moveTo(a),s.lineTo(n),r++;for(r=Math.ceil(this.bound[0].y/e);r*e<this.bound[1].y;)a=new t.Point(this.bound[0].x+this.base.x,-r*e+this.base.y),n=new t.Point(this.bound[1].x+this.base.x,-r*e+this.base.y),(s=new t.Path).strokeColor=i,s.moveTo(a),s.lineTo(n),r++;return(o=new t.PointText(this.bound[0].x+this.base.x,this.base.y-this.bound[1].y+this.offset)).justification="left",o.fillColor="#494949",o.content=`Resolution: ${this.target.resolution}, grid size: ${h} mm`}drawAxis(e){var i,n,r;return(n=new t.Path).strokeColor=e,r=new t.Point(this.bound[0].x+this.base.x,this.base.y),i=new t.Point(this.bound[1].x+this.base.x,this.base.y),n.moveTo(r),n.lineTo(i),(n=new t.Path).strokeColor=e,r=new t.Point(this.base.x,-this.bound[0].y+this.base.y),i=new t.Point(this.base.x,-this.bound[1].y+this.base.y),n.moveTo(r),n.lineTo(i),this.drawPoint([0,0],e,3)}prepare(){var e;return(e=this.el.getContext("2d")).translate(this.base.x,this.base.y),e.canvas.width=this.width,e.canvas.height=this.height,t.setup(this.el)}render(){}},n=class extends e{constructor(t){super(t)}p2c(t,e){var i;return i=e*Math.PI/180,[t*Math.cos(i),t*Math.sin(i)]}preprocess(){var t,e,i,n,r,s;if("polar"!==this.target.coordinate)return this.points=this.target.data;for(this.point=[],t=0,r=[],e=0,i=(n=this.target.data).length;e<i;e++)s=n[e],this.points.push(this.p2c(s,this.target.start+t*this.target.angularResolution)),r.push(t+=1);return r}render(){var e,i,n,r,s,a,o;for(this.drawGrid(20,"#DBDBDB"),this.drawAxis("#0A84FF"),i=0,n=(s=this.points).length;i<n;i++)o=s[i],"polar"===this.target.coordinate&&((r=new t.Path).strokeColor="#c2a10e",a=this.canvasPoint([0,0]),e=this.canvasPoint(o),r.moveTo(a),r.lineTo(e)),this.drawPoint(o,"red",3);return t.view.draw()}},(i=class extends this.OS.GUI.BaseApplication{constructor(t){super("LuaPlayground",t)}main(){return this.datarea=this.find("editorea"),this.output=this.find("output"),ace.config.set("basePath","/scripts/ace"),this.editor=ace.edit(this.datarea),this.editor.setOptions({enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,highlightActiveLine:!0,highlightSelectedWord:!0,behavioursEnabled:!0,wrap:!0,fontSize:"11pt",showInvisibles:!0}),this.editor.getSession().setUseWrapMode(!0),this.editor.session.setMode("ace/mode/lua"),this.editor.setTheme("ace/theme/monokai"),this.on("vboxchange",()=>this.editor.resize()),this.find("log-clear").set("onbtclick",t=>this.log("clean")),this.find("code-run").set("onbtclick",t=>this.run()),this.find("code-stop").set("onbtclick",t=>{if(this.socket)return this.socket.close()}),this.socket=null,this.bindKey("CTRL-R",()=>this.run())}menu(){return[{text:"__(Code)",child:[{text:"__(Run)",dataid:this.name+"-Run",shortcut:"C-R"}],onchildselect:t=>this.run()}]}log(t,e){var i;return"clean"===t?$(this.output).empty():(i=$("<p>").attr("class",t.toLowerCase())[0],$(i).html(`${t}: ${e.__()}`),$(this.output).append(i),$(this.output).scrollTop(this.output.scrollHeight))}run(){var t;if((t=this.editor.getValue().trim())&&""!==t)return this.stream().then(e=>(this.socket=e,this.socket.onopen=()=>this.socket.send(JSON.stringify({code:t})),this.socket.onmessage=t=>{var e,i;if(t.data)try{if(i=JSON.parse(t.data),!this.view(i))return this.log("INFO",t.data)}catch(i){return e=i,this.log("INFO",t.data),console.log(e)}},this.socket.onclose=()=>(this.socket=null,console.log("socket closed")))).catch(t=>this.error(__("Unable to get websocket stream")))}view(t){var e,i;return!!(t&&t.type&&this[t.type])&&(e=this[t.type](t).el,i=$("<p>").attr("class","info")[0],$(i).append(e),$(this.output).append(i),$(this.output).scrollTop(this.output.scrollHeight),!0)}pc(t){return new n(t)}cleanup(t){if(this.socket)return this.socket.close()}}).dependencies=["os://scripts/ace/ace.js"],this.OS.register("LuaPlayground",i)}).call(this);
(function(){var e,i,n;e=class{constructor(t){this.target=t,this.el=$("<canvas>").attr("class","viewer")[0],this.offset=10,this.points=[],this.preprocess(),this.getBound(),this.prepare(),this.render()}canvasPoint(e){return new t.Point(e[0]/this.target.resolution+this.base.x,-e[1]/this.target.resolution+this.base.y)}preprocess(){return this.points=this.target.data}getBound(){var t,e,i,n,r,s,a,o;for(n={x:0,y:0},i={x:0,y:0},t=0,e=(r=this.points).length;t<e;t++)a=(s=r[t])[0]/this.target.resolution,o=s[1]/this.target.resolution,a<n.x&&(n.x=a),o<n.y&&(n.y=o),a>i.x&&(i.x=a),o>i.y&&(i.y=o);return this.bound=[n,i],this.base={x:0-this.bound[0].x+this.offset,y:this.bound[1].y+this.offset},this.width=i.x-n.x+2*this.offset,this.height=i.y-n.y+2*this.offset}drawPoint(e,i,n){return new t.Path.Circle({center:this.canvasPoint(e),radius:n,fillColor:i})}drawGrid(e,i){var n,r,s,a,o,h;for(h=this.target.resolution*e,r=Math.ceil(this.bound[0].x/e);r*e<this.bound[1].x;)a=new t.Point(r*e+this.base.x,-this.bound[0].y+this.base.y),n=new t.Point(r*e+this.base.x,-this.bound[1].y+this.base.y),(s=new t.Path).strokeColor=i,s.moveTo(a),s.lineTo(n),r++;for(r=Math.ceil(this.bound[0].y/e);r*e<this.bound[1].y;)a=new t.Point(this.bound[0].x+this.base.x,-r*e+this.base.y),n=new t.Point(this.bound[1].x+this.base.x,-r*e+this.base.y),(s=new t.Path).strokeColor=i,s.moveTo(a),s.lineTo(n),r++;return(o=new t.PointText(this.bound[0].x+this.base.x,this.base.y-this.bound[1].y+this.offset)).justification="left",o.fillColor="#494949",o.content=`Resolution: ${this.target.resolution}, grid size: ${h} mm`}drawAxis(e){var i,n,r;return(n=new t.Path).strokeColor=e,r=new t.Point(this.bound[0].x+this.base.x,this.base.y),i=new t.Point(this.bound[1].x+this.base.x,this.base.y),n.moveTo(r),n.lineTo(i),(n=new t.Path).strokeColor=e,r=new t.Point(this.base.x,-this.bound[0].y+this.base.y),i=new t.Point(this.base.x,-this.bound[1].y+this.base.y),n.moveTo(r),n.lineTo(i),this.drawPoint([0,0],e,3)}prepare(){var e;return(e=this.el.getContext("2d")).translate(this.base.x,this.base.y),e.canvas.width=this.width,e.canvas.height=this.height,t.setup(this.el)}render(){}},n=class extends e{constructor(t){super(t)}p2c(t,e){var i;return i=e*Math.PI/180,[t*Math.cos(i),t*Math.sin(i)]}preprocess(){var t,e,i,n,r,s;if("polar"!==this.target.coordinate)return this.points=this.target.data;for(this.point=[],t=0,r=[],e=0,i=(n=this.target.data).length;e<i;e++)s=n[e],this.points.push(this.p2c(s,this.target.start+t*this.target.angularResolution)),r.push(t+=1);return r}render(){var e,i,n,r,s,a,o;for(this.drawGrid(20,"#DBDBDB"),this.drawAxis("#0A84FF"),i=0,n=(s=this.points).length;i<n;i++)o=s[i],"polar"===this.target.coordinate&&((r=new t.Path).strokeColor="#c2a10e",a=this.canvasPoint([0,0]),e=this.canvasPoint(o),r.moveTo(a),r.lineTo(e)),this.drawPoint(o,"red",3);return t.view.draw()}},(i=class extends this.OS.application.BaseApplication{constructor(t){super("LuaPlayground",t)}main(){return this.datarea=this.find("editorea"),this.output=this.find("output"),ace.config.set("basePath","/scripts/ace"),this.editor=ace.edit(this.datarea),this.editor.setOptions({enableBasicAutocompletion:!0,enableLiveAutocompletion:!0,highlightActiveLine:!0,highlightSelectedWord:!0,behavioursEnabled:!0,wrap:!0,fontSize:"11pt",showInvisibles:!0}),this.editor.getSession().setUseWrapMode(!0),this.editor.session.setMode("ace/mode/lua"),this.editor.setTheme("ace/theme/monokai"),this.on("vboxchange",()=>this.editor.resize()),this.find("log-clear").onbtclick=t=>this.log("clean"),this.find("code-run").onbtclick=t=>this.run(),this.find("code-stop").onbtclick=t=>{if(this.socket)return this.socket.close()},this.socket=null,this.bindKey("CTRL-R",()=>this.run())}menu(){return[{text:"__(Code)",nodes:[{text:"__(Run)",dataid:this.name+"-Run",shortcut:"C-R"}],onchildselect:t=>this.run()}]}log(t,e){var i;return"clean"===t?$(this.output).empty():(i=$("<p>").attr("class",t.toLowerCase())[0],$(i).html(`${t}: ${e.__()}`),$(this.output).append(i),$(this.output).scrollTop(this.output.scrollHeight))}run(){var t;if((t=this.editor.getValue().trim())&&""!==t)return this.stream().then(e=>(this.socket=e,this.socket.onopen=()=>this.socket.send(JSON.stringify({code:t})),this.socket.onmessage=t=>{var e,i;if(t.data)try{if(i=JSON.parse(t.data),!this.view(i))return this.log("INFO",t.data)}catch(i){return e=i,this.log("INFO",t.data),console.log(e)}},this.socket.onclose=()=>(this.socket=null,console.log("socket closed")))).catch(t=>this.error(__("Unable to get websocket stream")))}view(t){var e,i;return!!(t&&t.type&&this[t.type])&&(e=this[t.type](t).el,i=$("<p>").attr("class","info")[0],$(i).append(e),$(this.output).append(i),$(this.output).scrollTop(this.output.scrollHeight),!0)}pc(t){return new n(t)}cleanup(t){if(this.socket)return this.socket.close()}}).dependencies=["os://scripts/ace/ace.js"],this.OS.register("LuaPlayground",i)}).call(this);
/*!
* Paper.js v0.12.0 - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LEs",
"email": "xsang.le@gmail.com"
},
"version":"0.0.3-a",
"version":"0.0.4-a",
"category":"System",
"iconclass":"fa fa-adn",
"mimes":["none"]

View File

@ -1,4 +1,4 @@
<afx-app-window apptitle="Lua Playground" width="500" height="400" data-id="LuaPlayground">
<afx-app-window apptitle="Lua Playground" width="500" height="400" data-id="Lua Playground">
<afx-hbox >
<div data-id="editorea" data-width="250"></div>
<afx-resizer data-width="3"></afx-resizer>

View File

@ -142,7 +142,7 @@ class PointCloudViewer extends DataViewer
class LuaPlayground extends this.OS.GUI.BaseApplication
class LuaPlayground extends this.OS.application.BaseApplication
constructor: ( args ) ->
super "LuaPlayground", args
@ -166,12 +166,12 @@ class LuaPlayground extends this.OS.GUI.BaseApplication
@editor.setTheme "ace/theme/monokai"
@on "vboxchange", () =>
@editor.resize()
(@find "log-clear").set "onbtclick", (e) =>
(@find "log-clear").onbtclick = (e) =>
@log "clean"
(@find "code-run").set "onbtclick", (e) =>
(@find "code-run").onbtclick = (e) =>
@run()
(@find "code-stop").set "onbtclick", (e) =>
(@find "code-stop").onbtclick = (e) =>
@socket.close() if @socket
@socket = null
@ -179,7 +179,7 @@ class LuaPlayground extends this.OS.GUI.BaseApplication
menu: () ->
menu = [{
text: "__(Code)",
child: [
nodes: [
{ text: "__(Run)", dataid: "#{@name}-Run", shortcut: "C-R" }
],
onchildselect: (e) => @run()

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LEs",
"email": "xsang.le@gmail.com"
},
"version":"0.0.3-a",
"version":"0.0.4-a",
"category":"System",
"iconclass":"fa fa-adn",
"mimes":["none"]

View File

@ -1,3 +1,3 @@
# MarkOn markdown editor
markdown editor for antOS
Simple Markdown editor for antOS

View File

@ -1 +1,243 @@
(function(){var e;(e=class extends this.OS.GUI.BaseApplication{constructor(e){super("MarkOn",e)}main(){var e;return e=this.find("markarea"),this.container=this.find("mycontainer"),this.previewOn=!1,this.args&&this.args.length>0?this.currfile=this.args[0].path.asFileHandle():this.currfile="Untitled".asFileHandle(),this.editormux=!1,this.editor=new SimpleMDE({element:e,autoDownloadFontAwesome:!1,autofocus:!0,tabSize:4,indentWithTabs:!0,toolbar:["bold","italic","heading","|","quote","code","unordered-list","ordered-list","|","link","image","table","horizontal-rule","|",{name:"preview",className:"fa fa-eye no-disable",action:e=>(this.previewOn=!this.previewOn,SimpleMDE.togglePreview(e))}]}),this.editor.codemirror.on("change",()=>{if(!this.editormux)return!1===this.currfile.dirty?(this.currfile.dirty=!0,this.scheme.set("apptitle",this.currfile.basename+"*")):void 0}),this.on("hboxchange",e=>this.resizeContent()),this.bindKey("ALT-N",()=>this.actionFile(this.name+"-New")),this.bindKey("ALT-O",()=>this.actionFile(this.name+"-Open")),this.bindKey("CTRL-S",()=>this.actionFile(this.name+"-Save")),this.bindKey("ALT-W",()=>this.actionFile(this.name+"-Saveas")),this.resizeContent(),this.open(this.currfile)}resizeContent(){var e,t,i,s,a;return t=$(this.container).children(),s=$(this.scheme).find(".afx-window-top")[0],a=t[1],i=t[4],e=$(this.scheme).height()-$(s).height()-$(a).height()-$(i).height()-40,$(t[2]).css("height",e+"px")}open(e){if("Untitled"!==e.path)return e.dirty=!1,e.read().then(t=>(this.currfile=e,this.editormux=!0,this.editor.value(t),this.scheme.set("apptitle",""+this.currfile.basename),this.editormux=!1)).catch(t=>this.error(__("Unable to open: {0}",e.path),t))}save(e){return e.write("text/plain").then(t=>t.error?this.error(__("Error saving file {0}: {1}",e.basename,t.error)):(e.dirty=!1,e.text=e.basename,this.scheme.set("apptitle",""+this.currfile.basename))).catch(t=>this.error(__("Unable to save file: {0}",e.path),t))}menu(){return[{text:"__(File)",child:[{text:"__(New)",dataid:this.name+"-New",shortcut:"A-N"},{text:"__(Open)",dataid:this.name+"-Open",shortcut:"A-O"},{text:"__(Save)",dataid:this.name+"-Save",shortcut:"C-S"},{text:"__(Save as)",dataid:this.name+"-Saveas",shortcut:"A-W"}],onchildselect:e=>this.actionFile(e.data.item.get("data").dataid)}]}actionFile(e){var t;switch(t=()=>this.openDialog("FileDialog",{title:__("Save as"),file:this.currfile}).then(e=>{var t;return t=e.file.path.asFileHandle(),"file"===e.file.type&&(t=t.parent()),this.currfile.setPath(`${t.path}/${e.name}`),this.save(this.currfile)}),e){case this.name+"-Open":return this.openDialog("FileDialog",{title:__("Open file")}).then(e=>this.open(e.file.path.asFileHandle()));case this.name+"-Save":return this.currfile.cache=this.editor.value(),this.currfile.basename?this.save(this.currfile):t();case this.name+"-Saveas":return this.currfile.cache=this.editor.value(),t();case this.name+"-New":return this.currfile="Untitled".asFileHandle(),this.currfile.cache="",this.editor.value("")}}cleanup(e){if(this.currfile.dirty)return e.preventDefault(),this.openDialog("YesNoDialog",{title:__("Quit"),text:__("Quit without saving ?")}).then(e=>{if(e)return this.currfile.dirty=!1,this.quit()})}}).dependencies=["os://scripts/mde/simplemde.min.js","os://scripts/mde/simplemde.min.css"],this.OS.register("MarkOn",e)}).call(this);
(function() {
// Copyright 2017-2018 Xuan Sang LE <xsang.le AT gmail DOT com>
// AnTOS Web desktop is is licensed under the GNU General Public
// License v3.0, see the LICENCE file for more information
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public License
//along with this program. If not, see https://www.gnu.org/licenses/.
var MarkOn;
MarkOn = class MarkOn extends this.OS.application.BaseApplication {
constructor(args) {
super("MarkOn", args);
}
main() {
var markarea;
markarea = this.find("markarea");
this.container = this.find("mycontainer");
this.previewOn = false;
if (this.args && this.args.length > 0) {
this.currfile = this.args[0].path.asFileHandle();
} else {
this.currfile = "Untitled".asFileHandle();
}
this.editormux = false;
this.editor = new SimpleMDE({
element: markarea,
autoDownloadFontAwesome: false,
autofocus: true,
tabSize: 4,
indentWithTabs: true,
toolbar: [
"bold",
"italic",
"heading",
"|",
"quote",
"code",
"unordered-list",
"ordered-list",
"|",
"link",
"image",
"table",
"horizontal-rule",
"|",
{
name: "preview",
className: "fa fa-eye no-disable",
action: (e) => {
this.previewOn = !this.previewOn;
return SimpleMDE.togglePreview(e);
}
}
]
});
//if(self.previewOn) toggle the highlight
//{
// var container = self._scheme.find(self,"Text")
// .$element.getElementsByClassName("editor-preview");
// if(container.length == 0) return;
// var codes = container[0].getElementsByTagName('pre');
// codes.forEach(function(el){
// hljs.highlightBlock(el);
// });
// //console.log(code);
//}
this.editor.codemirror.on("change", () => {
if (this.editormux) {
return;
}
if (this.currfile.dirty === false) {
this.currfile.dirty = true;
return this.scheme.apptitle = `${this.currfile.basename}*`;
}
});
this.on("hboxchange", (e) => {
return this.resizeContent();
});
this.bindKey("ALT-N", () => {
return this.actionFile(`${this.name}-New`);
});
this.bindKey("ALT-O", () => {
return this.actionFile(`${this.name}-Open`);
});
this.bindKey("CTRL-S", () => {
return this.actionFile(`${this.name}-Save`);
});
this.bindKey("ALT-W", () => {
return this.actionFile(`${this.name}-Saveas`);
});
this.resizeContent();
return this.open(this.currfile);
}
resizeContent() {
var cheight, children, statusbar, titlebar, toolbar;
children = ($(this.container)).children();
titlebar = (($(this.scheme)).find(".afx-window-top"))[0];
toolbar = children[1];
statusbar = children[4];
cheight = ($(this.scheme)).height() - ($(titlebar)).height() - ($(toolbar)).height() - ($(statusbar)).height() - 40;
return ($(children[2])).css("height", cheight + "px");
}
open(file) {
//find table
if (file.path === "Untitled") {
return;
}
file.dirty = false;
return file.read().then((d) => {
this.currfile = file;
this.editormux = true;
this.editor.value(d);
this.scheme.apptitle = `${this.currfile.basename}`;
return this.editormux = false;
}).catch((e) => {
return this.error(__("Unable to open: {0}", file.path), e);
});
}
save(file) {
return file.write("text/plain").then((d) => {
if (d.error) {
return this.error(__("Error saving file {0}: {1}", file.basename, d.error));
}
file.dirty = false;
file.text = file.basename;
return this.scheme.apptitle = `${this.currfile.basename}`;
}).catch((e) => {
return this.error(__("Unable to save file: {0}", file.path), e);
});
}
menu() {
var menu;
menu = [
{
text: "__(File)",
nodes: [
{
text: "__(New)",
dataid: `${this.name}-New`,
shortcut: "A-N"
},
{
text: "__(Open)",
dataid: `${this.name}-Open`,
shortcut: "A-O"
},
{
text: "__(Save)",
dataid: `${this.name}-Save`,
shortcut: "C-S"
},
{
text: "__(Save as)",
dataid: `${this.name}-Saveas`,
shortcut: "A-W"
}
],
onchildselect: (e) => {
return this.actionFile(e.data.item.data.dataid);
}
}
];
return menu;
}
actionFile(e) {
var saveas;
saveas = () => {
return this.openDialog("FileDialog", {
title: __("Save as"),
file: this.currfile
}).then((f) => {
var d;
d = f.file.path.asFileHandle();
if (f.file.type === "file") {
d = d.parent();
}
this.currfile.setPath(`${d.path}/${f.name}`);
return this.save(this.currfile);
});
};
switch (e) {
case `${this.name}-Open`:
return this.openDialog("FileDialog", {
title: __("Open file")
}).then((f) => {
return this.open(f.file.path.asFileHandle());
});
case `${this.name}-Save`:
this.currfile.cache = this.editor.value();
if (this.currfile.basename) {
return this.save(this.currfile);
}
return saveas();
case `${this.name}-Saveas`:
this.currfile.cache = this.editor.value();
return saveas();
case `${this.name}-New`:
this.currfile = "Untitled".asFileHandle();
this.currfile.cache = "";
return this.editor.value("");
}
}
cleanup(evt) {
if (!this.currfile.dirty) {
return;
}
evt.preventDefault();
return this.openDialog("YesNoDialog", {
title: __("Quit"),
text: __("Quit without saving ?")
}).then((d) => {
if (d) {
this.currfile.dirty = false;
return this.quit();
}
});
}
};
MarkOn.dependencies = ["os://scripts/mde/simplemde.min.js", "os://scripts/mde/simplemde.min.css"];
this.OS.register("MarkOn", MarkOn);
}).call(this);

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.4-a",
"version":"0.0.6-a",
"category":"Utils",
"iconclass":"fa fa-leanpub",
"mimes":["text/.*"]

Binary file not shown.

View File

@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
class MarkOn extends this.OS.GUI.BaseApplication
class MarkOn extends this.OS.application.BaseApplication
constructor: (args) ->
super "MarkOn", args
@ -63,7 +63,7 @@ class MarkOn extends this.OS.GUI.BaseApplication
return if @editormux
if @currfile.dirty is false
@currfile.dirty = true
@scheme.set "apptitle", "#{@currfile.basename}*"
@scheme.apptitle = "#{@currfile.basename}*"
@on "hboxchange", (e) => @resizeContent()
@bindKey "ALT-N", () => @actionFile "#{@name}-New"
@bindKey "ALT-O", () => @actionFile "#{@name}-Open"
@ -89,7 +89,7 @@ class MarkOn extends this.OS.GUI.BaseApplication
@currfile = file
@editormux = true
@editor.value d
@scheme.set "apptitle", "#{@currfile.basename}"
@scheme.apptitle = "#{@currfile.basename}"
@editormux = false
.catch (e) => @error __("Unable to open: {0}", file.path), e
@ -100,19 +100,19 @@ class MarkOn extends this.OS.GUI.BaseApplication
return @error __("Error saving file {0}: {1}", file.basename, d.error) if d.error
file.dirty = false
file.text = file.basename
@scheme.set "apptitle", "#{@currfile.basename}"
@scheme.apptitle = "#{@currfile.basename}"
.catch (e) => @error __("Unable to save file: {0}", file.path), e
menu: () ->
menu = [{
text: "__(File)",
child: [
nodes: [
{ 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" }
],
onchildselect: (e) => @actionFile e.data.item.get("data").dataid
onchildselect: (e) => @actionFile e.data.item.data.dataid
}]
menu

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.4-a",
"version":"0.0.6-a",
"category":"Utils",
"iconclass":"fa fa-leanpub",
"mimes":["text/.*"]

View File

@ -1,3 +1,3 @@
# Preview
Image and PDF file viewer for antOS
Image and PDF file viewer for AntOS

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.5-a",
"version":"0.0.7-a",
"category":"Utils",
"iconclass":"fa fa-eye",
"mimes":["[^\/]*/.*pdf", "image/.*"]

Binary file not shown.

View File

@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/.
class Preview extends this.OS.GUI.BaseApplication
class Preview extends this.OS.application.BaseApplication
constructor: (args) ->
super "Preview", args
@ -31,18 +31,18 @@ class Preview extends this.OS.GUI.BaseApplication
@btreset = @find "btreset"
@txtpage = @find "txtpage"
@zoom.set "onchange", (e) => @setViewScale e.data
@zoom.onvaluechange = (e) => @setViewScale e.data
@btreset.set "onbtclick", (e) =>
@zoom.set "value", 100
@btreset.onbtclick = (e) =>
@zoom.value = 100
@setViewScale 100
@btnext.set "onbtclick", (e) =>
@btnext.onbtclick = (e) =>
val = parseInt $(@txtpage).val()
return if isNaN val
$(@txtpage).val val + 1
@gotoPage()
@btprev.set "onbtclick", (e) =>
@btprev.onbtclick = (e) =>
val = parseInt $(@txtpage).val()
return if isNaN val
$(@txtpage).val val - 1
@ -59,8 +59,8 @@ class Preview extends this.OS.GUI.BaseApplication
@bindKey "ALT-O", () => @actionFile "#{@name}-Open"
@bindKey "CTRL-X", () => @actionFile "#{@name}-Close"
@zoom.set "max", 200
@zoom.set "value", 100
@zoom.max = 200
@zoom.value = 100
@open @currfile
@ -80,7 +80,7 @@ class Preview extends this.OS.GUI.BaseApplication
return if isNaN(val)
return if val <= 0 or val > @pdf.numPages
($ @view).empty()
@renderPDFPages val, (@zoom.get("value") / 100), false
@renderPDFPages val, (@zoom.value / 100), false
.catch (e) => @error __("Unable to render page {0}", val), e
renderFile: () ->
@ -89,7 +89,7 @@ class Preview extends this.OS.GUI.BaseApplication
@pdf = undefined
@img = undefined
($ @view).empty()
@zoom.set "value", 100
@zoom.value = 100
if mime.match /^[^\/]+\/.*pdf.*/g
@renderPDF()
else if mime.match /image\/.*svg.*/g
@ -209,11 +209,11 @@ class Preview extends this.OS.GUI.BaseApplication
menu: () ->
menu = [{
text: "__(File)",
child: [
nodes: [
{ text: "__(Open)", dataid: "#{@name}-Open", shortcut: "A-O" },
{ text: "__(Close)", dataid: "#{@name}-Close", shortcut: "C-X" },
],
onchildselect: (e) => @actionFile e.data.item.get("data").dataid
onchildselect: (e) => @actionFile e.data.item.data.dataid
}]
menu

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.5-a",
"version":"0.0.7-a",
"category":"Utils",
"iconclass":"fa fa-eye",
"mimes":["[^\/]*/.*pdf", "image/.*"]

View File

@ -1,7 +1,7 @@
<afx-app-window data-id="example-show-case" apptitle="AntOS GUI widgets" width="650" height="500">
<afx-vbox>
<afx-menu data-height="30" data-id="menu" />
<afx-tab-container data-id="tabctn" tabbarheight= "30">
<afx-tab-container data-id="tabctn" dir = "column" tabbarheight= "30">
<afx-hbox tabname="Widgets">
<afx-vbox data-width="150">

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@
"email": "xsang.le@gmail.com",
"licences": "GPLv3"
},
"version":"0.0.3-a",
"version":"0.0.4-a",
"category":"Other",
"mimes":["none"],
"iconclass": "fa fa-delicious",

View File

@ -1,7 +1,7 @@
<afx-app-window data-id="example-show-case" apptitle="AntOS GUI widgets" width="650" height="500">
<afx-vbox>
<afx-menu data-height="30" data-id="menu" />
<afx-tab-container data-id="tabctn" tabbarheight= "30">
<afx-tab-container data-id="tabctn" dir = "column" tabbarheight= "30">
<afx-hbox tabname="Widgets">
<afx-vbox data-width="150">

Binary file not shown.

View File

@ -1,23 +1,18 @@
Ant = this
class ShowCase extends this.OS.GUI.BaseApplication
class ShowCase extends this.OS.application.BaseApplication
constructor: (args) ->
super "ShowCase", args
main: () ->
bt = @find 'bttest'
bt.set "onbtclick", (e) =>
@error "test error"
@observable.on "btclick", (e) =>
@notify "button clicked"
@observable.on "menuselect", (e) =>
@notify e.id
list = @find 'list'
list.set "data", [
list.data = [
{ text: "some thing with avery long text" },
{ text: "some thing 1", closable: true },
{ text: "some thing 2", iconclass: "fa fa-camera-retro fa-lg" },
@ -25,70 +20,60 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "some thing 4" },
{ text: "some thing 5" }
]
list.unshift { text: "shifted el" }
list.set "onlistselect", (e) => @notify(e.data.items)
list.onlistselect = (e) => @notify(e.data.items)
sw = @find 'switch'
sw.set "onchange", (e) =>
sw.onswchange = (e) =>
@notify e.data
spin = @find 'spin'
spin.set "onchange", (e) =>
spin.onvaluechange = (e) =>
@notify e.data
menu = @find 'menu'
menu.set "items", @menu()
menu.items = @menu()
list.contextmenuHandle = (e, m) =>
m.set "items", @menu()
m.items = @menu()
m.show e
grid = @find 'grid'
grid.set "oncelldbclick", (e) =>
grid.oncelldbclick = (e) =>
@notify "on dbclick", e
grid.set "onrowselect", (e) =>
@notify "on rowselect", e.data.items
grid.onrowselect = (e) =>
@notify "on rowselect"
@observable.on "cellselect", (e) ->
console.log "observable", e
grid.set "header", [{ text: "header1", width: 80 }, { text: "header2" }, { text: "header3" }]
grid.set "rows", [
grid.header = [{ text: "header1", width: 80 }, { text: "header2" }, { text: "header3" }]
grid.rows = [
[{ text: "text 1" }, { text: "text 2" }, { text: "text 3" }],
[{ text: "text 4" }, { text: "text 5" }, { text: "text 6" }],
[{ text: "text 7" }, { text: "text 8" }, { text: "text 9" }],
[{ text: "text 7" }, { text: "Subgrid on columns and rows. Subgrid on columns, implicit grid rows. Subgrid on rows, defined column tracks" }, { text: "text 9" }],
[{ text: "text 7" }, { text: "text 8" }, { text: "text 9" }],
[{ text: "text 7" }, { text: "text 8" }, { text: "text 9" }],
[{ text: "text 7" }, { text: "text 8" }, { text: "text 9" }],
[{ text: "text 7" }, { text: "text 8" }, { text: "text 9" }],
[{ text: "text 7" }, { text: "text 8" }, { text: "text 9" }],
[{ text: "text 7" }, { text: "text 8" }, { text: "text 9" }],
[{ text: "text 7" }, { text: "text 8" }, { text: "text 9" }]
[{ text: "text 10" }, { text: "this is a long text" }, { text: "text 11" }]
]
tdata = {
name: 'My Tree',
text: 'Tree root',
nodes: [
{ name: 'hello', iconclass:'fa fa-car'},
{ name: 'wat' },
{ text: 'leaf 1', iconclass:'fa fa-car'},
{ text: 'leaf 2' },
{
name: 'child folder',
text: 'sub tree 1',
nodes: [
{
name: 'child folder',
text: 'sub sub tree 1',
nodes: [
{ name: 'hello' },
{ name: 'wat' }
{ text: 'leaf 1 of sub sub tree 1' },
{ text: 'leaf 2 of sub sub tree 1' }
]
},
{ name: 'hello' },
{ name: 'wat' },
{ text: 'leaf 1 of sub tree' },
{ text: 'leaf 2 of sub tree' },
{
name: 'child folder',
text: 'sub sub tree 2',
nodes: [
{ name: 'hello' },
{ name: 'wat' }
{ text: 'leaf 1 of sub sub tree 2' },
{ text: 'leaf 2 of sub sub tree 2' }
]
}
]
@ -97,30 +82,28 @@ class ShowCase extends this.OS.GUI.BaseApplication
}
tree = @find 'tree'
tree.set "data", tdata
tree.set "ontreeselect", (e) =>
@notify e.data.item.get "treepath"
tree.set "ontreedbclick", (e) =>
@notify "treedbclick", e
tree.data = tdata
tree.ontreeselect = (e) =>
@notify e.data.item.treepath
tree.ontreedbclick = (e) =>
@notify "treedbclick"
@observable.on "treedbclick", (e) =>
@notify "observable treedbclick", e
@notify "observable treedbclick"
slider = @find 'slider'
slider.set "onchange", (v) =>
slider.onvaluechange = (v) =>
@notify v
cal = @find 'cal'
cal.set "ondateselect", (e) =>
@notify e
cal.ondateselect = (e) =>
@notify e.data.toString()
pk = @find 'cpk'
pk.set "oncolorselect", (e) =>
@notify e
pk.set "oncolorselect", (e) =>
@notify e
pk.oncolorselect = (e) =>
@notify JSON.stringify(e)
fileview = @find 'fileview'
fileview.set "fetch", (path) ->
fileview.fetch = (path) ->
new Promise (resolve, reject) ->
dir = path.asFileHandle()
dir.read().then (d) ->
@ -130,22 +113,22 @@ class ShowCase extends this.OS.GUI.BaseApplication
return reject d.error if d.error
d.result.unshift p
resolve d.result
fileview.set "path", "home:///"
fileview.path = "home:///"
viewoption = @find 'viewoption'
viewoption.set "data", [
viewoption.data = [
{ text: "icon" },
{ text: "list" },
{ text: "tree" }
]
viewoption.set "onlistselect", (e) =>
@notify e.data.item.get("data").text
fileview.set "view", e.data.item.get("data").text
viewoption.onlistselect = (e) =>
@notify e.data.item.data.text
fileview.view = e.data.item.data.text
dllist = @find "dialoglist"
btrun = @find "btrundia"
dllist.set "data", [
dllist.data = [
{ text: "Prompt dialog", id: "prompt" },
{ text: "Calendar dialog", id: "calendar" },
{ text: "Color picker dialog", id: "colorpicker" },
@ -157,10 +140,10 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "Text dialog", id: "text" }
]
btrun.set "onbtclick", (e) =>
item = dllist.get "selectedItem"
btrun.onbtclick = (e) =>
item = dllist.selectedItem
return unless item
switch item.get("data").id
switch item.data.id
when "prompt"
@openDialog("PromptDialog", {
title: "Prompt review",
@ -171,14 +154,14 @@ class ShowCase extends this.OS.GUI.BaseApplication
@notify d
when "calendar"
@openDialog("CalendarDialog", {
title: "Calendar"
title: "Calendar dialog"
})
.then (d) =>
@notify d
@notify d.toString()
when "colorpicker"
@openDialog("ColorPickerDialog")
.then (d) =>
@notify d
@notify JSON.stringify(d)
when "info"
@openDialog("InfoDialog", {
title: "Info application",
@ -233,7 +216,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
#@notify file
arr = {
text: "__(File)",
child: [
nodes: [
{ text: "__(New file)", dataid: "#{@name}-mkf", shortcut: 'C-F' },
{ text: "__(New folder)", dataid: "#{@name}-mkdir", shortcut: 'C-D' },
{ text: "__(Open with)", dataid: "#{@name}-open", child: @apps },
@ -241,20 +224,20 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "__(Download)", dataid: "#{@name}-download" },
{ text: "__(Share file)", dataid: "#{@name}-share", shortcut: 'C-S' },
{ text: "__(Properties)", dataid: "#{@name}-info", shortcut: 'C-I' }
], onchildselect: (e) => @notify "child", e
], onchildselect: (e) => @notify e.data.item.data.text
}
return arr
mnEdit: () ->
{
text: "__(Edit)",
child: [
nodes: [
{ text: "__(Rename)", dataid: "#{@name}-mv", shortcut: 'C-R' },
{ text: "__(Delete)", dataid: "#{@name}-rm", shortcut: 'C-M' },
{ text: "__(Cut)", dataid: "#{@name}-cut", shortcut: 'C-X' },
{ text: "__(Copy)", dataid: "#{@name}-copy", shortcut: 'C-C' },
{ text: "__(Paste)", dataid: "#{@name}-paste", shortcut: 'C-P' }
], onchildselect: (e) => console.log "child", e
], onchildselect: (e) => @notify e.data.item.data.text
}
menu: () ->
@ -263,8 +246,8 @@ class ShowCase extends this.OS.GUI.BaseApplication
@mnEdit(),
{
text: "__(View)",
child: [
{ text: "__(Refresh)", dataid: "#{@name}-refresh", onmenuselect: (e) -> console.log "select", e },
nodes: [
{ text: "__(Refresh)", dataid: "#{@name}-refresh"},
{ text: "__(Sidebar)", switch: true, checked: true },
{ text: "__(Navigation bar)", switch: true, checked: false },
{ text: "__(Hidden files)", switch: true, checked: true, dataid: "#{@name}-hidden" },
@ -272,9 +255,9 @@ class ShowCase extends this.OS.GUI.BaseApplication
{ text: "__(Icon view)", radio: true, checked: true, dataid: "#{@name}-icon", type: 'icon' },
{ text: "__(List view)", radio:true, checked: false, dataid: "#{@name}-list", type: 'list' },
{ text: "__(Tree view)", radio:true, checked: false, dataid: "#{@name}-tree", type: 'tree' }
], onchildselect: (e) -> console.log "child", e
], onchildselect: (e) -> @notify e.data.item.data.text
},
], onchildselect: (e) => console.log "child", e
], onchildselect: (e) => @notify e.data.item.data.text
},
]
menu

View File

@ -7,7 +7,7 @@
"email": "xsang.le@gmail.com",
"licences": "GPLv3"
},
"version":"0.0.3-a",
"version":"0.0.4-a",
"category":"Other",
"mimes":["none"],
"iconclass": "fa fa-delicious",

View File

@ -1,3 +1,3 @@
# TinyEditor
This is the example project for the tutorial: [https://blog.lxsang.me/post/id/20](https://blog.lxsang.me/post/id/20)
This is the example project for the tutorial: [https://blog.lxsang.me/post/id/20](https://blog.lxsang.me/post/id/20). The tutorial is outdated, it is no longer compatible with the new antos API

View File

@ -1 +1 @@
(function(){var e;e=class extends this.OS.GUI.BaseApplication{constructor(e){super("TinyEditor",e)}main(){return this.editor=this.find("editor"),this.bindKey("ALT-N",()=>this.newFile()),this.bindKey("ALT-O",()=>this.openFile()),this.bindKey("CTRL-S",()=>this.saveFile()),this.filehandle=this.args&&this.args.length>0?this.args[0].path.asFileHandle():null,$(this.editor).on("input",e=>{if(!0!==this.filehandle.dirty)return this.filehandle.dirty=!0,this.scheme.set("apptitle",this.filehandle.path+"*")}),this.read()}menu(){return[{text:"__(File)",child:[{text:"__(New)",dataid:"new",shortcut:"A-N"},{text:"__(Open)",dataid:"open",shortcut:"A-O"},{text:"__(Save)",dataid:"save",shortcut:"C-S"}],onchildselect:e=>{switch(e.data.item.get("data").dataid){case"new":return this.newFile();case"open":return this.openFile();case"save":return this.saveFile()}}}]}newFile(){return this.filehandle=null,this.read()}openFile(){return this.openDialog("FileDialog",{title:__("Open file")}).then(e=>(this.filehandle=e.file.path.asFileHandle(),this.read()))}saveFile(){return this.filehandle.cache=this.editor.value,"Untitled"!==this.filehandle.path?this.write():this.openDialog("FileDialog",{title:__("Save as"),file:this.filehandle}).then(e=>{var t;return t=e.file.path.asFileHandle(),"file"===e.file.type&&(t=t.parent()),this.filehandle.setPath(`${t.path}/${e.name}`),this.write()})}read(){return this.editor.value="",null===this.filehandle?(this.filehandle="Untitled".asFileHandle(),void this.scheme.set("apptitle","Untitled")):this.filehandle.read().then(e=>(this.scheme.set("apptitle",this.filehandle.path),this.editor.value=e)).catch(e=>this.error(__("Unable to read file content")))}write(){return this.filehandle.write("text/plain").then(e=>(this.filehandle.dirty=!1,this.scheme.set("apptitle",""+this.filehandle.path))).catch(e=>this.error(__("Error saving file {0}",this.filehandle.path),e))}cleanup(e){if(this.filehandle.dirty)return e.preventDefault(),this.ask({title:"__(Quit)",text:"__(Quit without saving?)"}).then(()=>(this.filehandle.dirty=!1,this.quit()))}},this.OS.register("TinyEditor",e)}).call(this);
(function(){var e;e=class extends this.OS.application.BaseApplication{constructor(e){super("TinyEditor",e)}main(){return this.editor=this.find("editor"),this.bindKey("ALT-N",()=>this.newFile()),this.bindKey("ALT-O",()=>this.openFile()),this.bindKey("CTRL-S",()=>this.saveFile()),this.filehandle=this.args&&this.args.length>0?this.args[0].path.asFileHandle():null,$(this.editor).on("input",e=>{if(!0!==this.filehandle.dirty)return this.filehandle.dirty=!0,this.scheme.apptitle=this.filehandle.path+"*"}),this.read()}menu(){return[{text:"__(File)",nodes:[{text:"__(New)",dataid:"new",shortcut:"A-N"},{text:"__(Open)",dataid:"open",shortcut:"A-O"},{text:"__(Save)",dataid:"save",shortcut:"C-S"}],onchildselect:e=>{switch(e.data.item.data.dataid){case"new":return this.newFile();case"open":return this.openFile();case"save":return this.saveFile()}}}]}newFile(){return this.filehandle=null,this.read()}openFile(){return this.openDialog("FileDialog",{title:__("Open file")}).then(e=>(this.filehandle=e.file.path.asFileHandle(),this.read()))}saveFile(){return this.filehandle.cache=this.editor.value,"Untitled"!==this.filehandle.path?this.write():this.openDialog("FileDialog",{title:__("Save as"),file:this.filehandle}).then(e=>{var t;return t=e.file.path.asFileHandle(),"file"===e.file.type&&(t=t.parent()),this.filehandle.setPath(`${t.path}/${e.name}`),this.write()})}read(){return this.editor.value="",null===this.filehandle?(this.filehandle="Untitled".asFileHandle(),void(this.scheme.apptitle="Untitled")):this.filehandle.read().then(e=>(this.scheme.apptitle=this.filehandle.path,this.editor.value=e)).catch(e=>this.error(__("Unable to read file content")))}write(){return this.filehandle.write("text/plain").then(e=>(this.filehandle.dirty=!1,this.scheme.apptitle=""+this.filehandle.path)).catch(e=>this.error(__("Error saving file {0}",this.filehandle.path),e))}cleanup(e){if(this.filehandle.dirty)return e.preventDefault(),this.ask({title:"__(Quit)",text:"__(Quit without saving?)"}).then(e=>{if(e)return this.filehandle.dirty=!1,this.quit()})}},this.OS.register("TinyEditor",e)}).call(this);

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.3-a",
"version":"0.0.4-a",
"category":"Other",
"iconclass":"fa fa-adn",
"mimes":["text/.*"]

View File

@ -1,4 +1,4 @@
class TinyEditor extends this.OS.GUI.BaseApplication
class TinyEditor extends this.OS.application.BaseApplication
constructor: ( args ) ->
super "TinyEditor", args
@ -11,20 +11,20 @@ class TinyEditor extends this.OS.GUI.BaseApplication
$(@editor).on 'input', (e) =>
return if @filehandle.dirty is true
@filehandle.dirty = true
@scheme.set "apptitle", "#{@filehandle.path}*"
@scheme.apptitle = "#{@filehandle.path}*"
@read()
menu: () ->
m = [
{
text: "__(File)",
child: [
nodes: [
{ text: "__(New)", dataid :"new", shortcut: 'A-N' },
{ text: "__(Open)", dataid :"open", shortcut: 'A-O' },
{ text: "__(Save)", dataid :"save", shortcut: 'C-S' }
],
onchildselect: (e) =>
switch e.data.item.get("data").dataid
switch e.data.item.data.dataid
when "new" then @newFile()
when "open" then @openFile()
when "save" then @saveFile()
@ -59,17 +59,17 @@ class TinyEditor extends this.OS.GUI.BaseApplication
@editor.value = ""
if @filehandle is null
@filehandle = "Untitled".asFileHandle()
@scheme.set "apptitle", "Untitled"
@scheme.apptitle = "Untitled"
return
@filehandle.read().then (d) =>
@scheme.set "apptitle", @filehandle.path
@scheme.apptitle = @filehandle.path
@editor.value = d
.catch (e) => @error __("Unable to read file content")
write: () ->
@filehandle.write("text/plain").then (d) =>
@filehandle.dirty = false
@scheme.set "apptitle", "#{@filehandle.path}"
@scheme.apptitle = "#{@filehandle.path}"
.catch (e) => @error __("Error saving file {0}", @filehandle.path), e
@ -77,7 +77,8 @@ class TinyEditor extends this.OS.GUI.BaseApplication
return unless @filehandle.dirty
e.preventDefault()
@ask { title: "__(Quit)", text: "__(Quit without saving?)" }
.then () =>
.then (d) =>
return unless d
@filehandle.dirty = false
@quit()

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.3-a",
"version":"0.0.4-a",
"category":"Other",
"iconclass":"fa fa-adn",
"mimes":["text/.*"]

View File

@ -5,7 +5,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/About/README.md",
"category": "Other",
"author": "Xuan Sang LE",
"version": "0.0.2-a",
"version": "0.0.3-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/About/build/release/About.zip"
},
{
@ -14,7 +14,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ActivityMonitor/README.md",
"category": "System",
"author": "Xuan Sang LE",
"version": "0.0.2-a",
"version": "0.0.4-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ActivityMonitor/build/release/ActivityMonitor.zip"
},
{
@ -23,7 +23,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Blogger/README.md",
"category": "Internet",
"author": "Xuan Sang LE",
"version": "0.0.7-a",
"version": "0.0.9-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Blogger/build/release/Blogger.zip"
},
{
@ -32,7 +32,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/LuaPlayground/README.md",
"category": "System",
"author": "Xuan Sang LEs",
"version": "0.0.3-a",
"version": "0.0.4-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/LuaPlayground/build/release/LuaPlayground.zip"
},
{
@ -41,7 +41,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/MarkOn/README.md",
"category": "Utils",
"author": "Xuan Sang LE",
"version": "0.0.4-a",
"version": "0.0.6-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/MarkOn/build/release/MarkOn.zip"
},
{
@ -50,7 +50,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Preview/README.md",
"category": "Utils",
"author": "Xuan Sang LE",
"version": "0.0.5-a",
"version": "0.0.7-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/Preview/build/release/Preview.zip"
},
{
@ -59,7 +59,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ShowCase/README.md",
"category": "Other",
"author": "Xuan Sang LE",
"version": "0.0.3-a",
"version": "0.0.4-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/ShowCase/build/release/ShowCase.zip"
},
{
@ -68,7 +68,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/TinyEditor/README.md",
"category": "Other",
"author": "Xuan Sang LE",
"version": "0.0.3-a",
"version": "0.0.4-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/TinyEditor/build/release/TinyEditor.zip"
},
{
@ -77,7 +77,7 @@
"description": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/wTerm/README.md",
"category": "System",
"author": "Xuan Sang LE",
"version": "0.0.4-a",
"version": "0.0.5-a",
"download": "https://raw.githubusercontent.com/lxsang/antosdk-apps/master/wTerm/build/release/wTerm.zip"
}

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.4-a",
"version":"0.0.5-a",
"category":"System",
"iconclass":"fa fa-terminal",
"mimes":["none"],

Binary file not shown.

View File

@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
#along with this program. If not, see https://www.gnu.org/licenses/
class wTerm extends this.OS.GUI.BaseApplication
class wTerm extends this.OS.application.BaseApplication
constructor: (args) ->
super "wTerm", args
@ -35,13 +35,13 @@ class wTerm extends this.OS.GUI.BaseApplication
@on "focus", () => @term.focus()
@mterm.contextmenuHandle = (e, m) =>
m.set "items", [
m.items = [
{ text: "__(Copy)", id: "copy" },
{ text: "__(Paste)", id: "paste"}
]
m.set "onmenuselect", (e) =>
m.onmenuselect = (e) =>
return unless e
@mctxHandle e.data.item.get "data"
@mctxHandle e.data.item.data
m.show e
@resizeContent()
@openSession()
@ -100,7 +100,7 @@ class wTerm extends this.OS.GUI.BaseApplication
menu: () ->
{
text: "__(Edit)",
child: [
nodes: [
{ text: "__(Terminal URI)", dataid: "#{@name}-termuri" }
],
onchildselect: (e) => @configure()

View File

@ -6,7 +6,7 @@
"author": "Xuan Sang LE",
"email": "xsang.le@gmail.com"
},
"version":"0.0.4-a",
"version":"0.0.5-a",
"category":"System",
"iconclass":"fa fa-terminal",
"mimes":["none"],