add Market Place

This commit is contained in:
Xuan Sang LE
2018-03-05 00:20:25 +01:00
parent b9a4448cb8
commit 98d57e0bd3
10 changed files with 175 additions and 51 deletions

View File

@ -19,6 +19,12 @@ String.prototype.unescape = () ->
d = d.replace /\\f/g, "\f"
d = d.replace /\\r/g, "\r"
d
String.prototype.asUnit8Array = () ->
bytes = []
for i in [0..(@length - 1)]
bytes.push @charCodeAt i
bytes = new Uint8Array(bytes)
return bytes
Date.prototype.toString = () ->
dd = @getDate()
@ -202,11 +208,11 @@ self.OS.API =
packages:
fetch: (f) ->
_API.handler.packages {
command: "list", args: { paths: _OS.setting.system.pkgpaths }
command: "list", args: { paths: (v for k, v of _OS.setting.system.pkgpaths) }
}, f
cache: (f) ->
_API.handler.packages {
command: "cache", args: { paths: _OS.setting.system.pkgpaths }
command: "cache", args: { paths: (v for k, v of _OS.setting.system.pkgpaths) }
}, f
search: (text) ->

View File

@ -7,6 +7,16 @@ self.OS.GUI =
CTRL: {}
SHIFT: {}
META: {}
SYS_MENU: [
{
text: "Applications",
child: [],
dataid: "sys-apps"
iconclass: "fa fa-adn",
onmenuselect: (d) ->
_GUI.launch d.item.data.app
}
]
htmlToScheme: (html, app, parent) ->
scheme = $.parseHTML html
($ parent).append scheme
@ -324,38 +334,32 @@ self.OS.GUI =
alert "System fall: Cannot init desktop manager"
console.log s, e
refreshSystemMenu: () ->
_GUI.SYS_MENU.length = 1
_GUI.SYS_MENU[0].child.length = 0
_GUI.SYS_MENU[0].child.push v for k, v of _OS.setting.system.packages when (v and v.app)
_GUI.SYS_MENU.push v for k, v of _OS.setting.system.menu
_GUI.SYS_MENU.push
text: "Toggle Full screen",
dataid: "os-fullsize",
iconclass: "fa fa-tv"
_GUI.SYS_MENU.push
text: "Log out",
dataid: "sys-logout",
iconclass: "fa fa-user-times"
buildSystemMenu: () ->
menu =
text: ""
iconclass: "fa fa-eercast"
dataid: "sys-menu-root"
child: [
{
text: "Application",
child: ( v for k, v of _OS.setting.system.packages when v.app ),
dataid: "sys-apps"
iconclass: "fa fa-adn",
onmenuselect: (d) ->
_GUI.launch d.item.data.app
}
]
menu.child = menu.child.concat (v for k, v of _OS.setting.system.menu)
menu.child.push
text: "Toggle Full screen",
dataid: "os-fullsize",
iconclass: "fa fa-tv"
menu.child.push
text: "Log out",
dataid: "sys-logout",
iconclass: "fa fa-user-times"
child: _GUI.SYS_MENU
menu.onmenuselect = (d) ->
return _OS.exit() if d.item.data.dataid is "sys-logout"
return _GUI.toggleFullscreen() if d.item.data.dataid is "os-fullsize"
_GUI.launch d.item.data.app unless d.item.data.dataid
($ "[data-id = 'os_menu']", "#syspanel")[0].set "items", [menu]
menu = [menu]
($ "[data-id = 'os_menu']", "#syspanel")[0].set "items", menu
#console.log menu
@ -399,6 +403,7 @@ self.OS.GUI =
v.mime = "antos/app"
v.iconclass = "fa fa-adn" unless v.iconclass or v.icon
_OS.setting.system.packages = if r.result then r.result else
_GUI.refreshSystemMenu()
_GUI.buildSystemMenu()
# push startup services
# TODO: get services list from user setting

View File

@ -27,10 +27,10 @@
apps: []
} if not _OS.setting.system.startup
_OS.setting.system.pkgpaths = [
"home:///.packages",
"os:///packages"
] unless _OS.setting.system.pkgpaths
_OS.setting.system.pkgpaths = {
user: "home:///.packages",
system: "os:///packages"
} unless _OS.setting.system.pkgpaths
_OS.setting.system.menu = {} unless _OS.setting.system.menu
_OS.setting.system.repositories = [] unless _OS.setting.system.repositories
_OS.setting.appearance.theme = "antos" unless _OS.setting.appearance.theme

View File

@ -163,11 +163,7 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
.then (r) ->
_API.loaded q, "OK"
return f r.body unless p is "binary"
bytes = []
for i in [0..(r.body.length - 1)]
bytes.push r.body.charCodeAt i
bytes = new Uint8Array(bytes)
f bytes
f r.body.asUnit8Array()
.catch (err) ->
_API.loaded q, "FAIL"
_courrier.oserror "VFS cannot get read #{me.path}", (_API.throwe "OS.VFS"), err