1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2025-07-27 02:59:47 +02:00
This commit is contained in:
Xuan Sang LE
2018-08-28 14:49:03 +02:00
parent 692d437c67
commit 0817dd6079
23 changed files with 1632 additions and 92 deletions

View File

@ -0,0 +1,22 @@
class APIManager extends window.classes.BaseObject
constructor: () ->
super "APIManager"
init: (cname) ->
console.log(cname)
@ready()
.then () ->
if mobilecheck()
mobileConsole.init()
# load the class
return if not cname or cname is ""
return console.error("Cannot find class ", cname) unless window.classes[cname]
(new window.classes[cname]).init()
.catch ( m, s ) ->
console.error(m, s)
APIManager.dependencies = [
"/assets/scripts/mobile_console.js"
]
makeclass "APIManager", APIManager

View File

@ -0,0 +1,25 @@
class BaseObject
constructor: (@name) ->
ready: () ->
me = @
return new Promise (r, e) ->
me.resolveDep()
.then () -> r()
.catch (m, s) -> e(m, s)
resolveDep: () ->
me = @
return new Promise (r, e) ->
dep = window.classes[me.name].dependencies
r() unless dep
fn = (l, i) ->
return r() if i >= dep.length
require(l[i])
.then () -> fn(l, i + 1)
.catch (m, s) -> e(m, s)
fn dep, 0
makeclass "BaseObject", BaseObject

View File

@ -0,0 +1,17 @@
class MarkOn extends window.classes.BaseObject
constructor: (@id) ->
super "MarkOn"
init: () ->
me = @
@ready()
.then () ->
me.editor = new SimpleMDE { element: $(me.id)[0] }
.catch (m, s) ->
console.error(m, s)
MarkOn.dependencies = [
"/rst/gscripts/mde/simplemde.min.js"
]
makeclass "MarkOn", MarkOn

View File

@ -0,0 +1,19 @@
window.classes = {}
window.libraries = {}
window.myuri = "/"
window.mobilecheck = () ->
if navigator.userAgent.match(/Android/i) or navigator.userAgent.match(/webOS/i) or navigator.userAgent.match(/iPhone/i) or navigator.userAgent.match(/iPad/i) or navigator.userAgent.match(/iPod/i) or navigator.userAgent.match(/BlackBerry/i) or navigator.userAgent.match(/Windows Phone/i)
return true
return false
window.makeclass = (n, o) -> window.classes[n] = o
window.require = (lib) ->
return new Promise (r, e) ->
return r() if window.libraries[lib]
$.getScript window.myuri + lib
.done (d) ->
window.libraries[lib] = true
r()
.fail (m, s) ->
e(m, s)