mirror of
https://github.com/lxsang/antd-web-apps
synced 2025-07-27 02:59:47 +02:00
apps
This commit is contained in:
22
apps/assets/coffee/APIManager.coffee
Normal file
22
apps/assets/coffee/APIManager.coffee
Normal 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
|
25
apps/assets/coffee/BaseObject.coffee
Normal file
25
apps/assets/coffee/BaseObject.coffee
Normal 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
|
||||
|
17
apps/assets/coffee/MarkOn.coffee
Normal file
17
apps/assets/coffee/MarkOn.coffee
Normal 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
|
19
apps/assets/coffee/bootstrap.coffee
Normal file
19
apps/assets/coffee/bootstrap.coffee
Normal 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)
|
7
apps/assets/css/style.css
Normal file
7
apps/assets/css/style.css
Normal file
File diff suppressed because one or more lines are too long
145
apps/assets/scripts/main.js
Normal file
145
apps/assets/scripts/main.js
Normal file
@ -0,0 +1,145 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var APIManager, BaseObject, MarkOn,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
|
||||
window.classes = {};
|
||||
|
||||
window.libraries = {};
|
||||
|
||||
window.myuri = "/";
|
||||
|
||||
window.mobilecheck = function() {
|
||||
if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
window.makeclass = function(n, o) {
|
||||
return window.classes[n] = o;
|
||||
};
|
||||
|
||||
window.require = function(lib) {
|
||||
return new Promise(function(r, e) {
|
||||
if (window.libraries[lib]) {
|
||||
return r();
|
||||
}
|
||||
return $.getScript(window.myuri + lib).done(function(d) {
|
||||
window.libraries[lib] = true;
|
||||
return r();
|
||||
}).fail(function(m, s) {
|
||||
return e(m, s);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
BaseObject = (function() {
|
||||
function BaseObject(name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
BaseObject.prototype.ready = function() {
|
||||
var me;
|
||||
me = this;
|
||||
return new Promise(function(r, e) {
|
||||
return me.resolveDep().then(function() {
|
||||
return r();
|
||||
})["catch"](function(m, s) {
|
||||
return e(m, s);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
BaseObject.prototype.resolveDep = function() {
|
||||
var me;
|
||||
me = this;
|
||||
return new Promise(function(r, e) {
|
||||
var dep, fn;
|
||||
dep = window.classes[me.name].dependencies;
|
||||
if (!dep) {
|
||||
r();
|
||||
}
|
||||
fn = function(l, i) {
|
||||
if (i >= dep.length) {
|
||||
return r();
|
||||
}
|
||||
return require(l[i]).then(function() {
|
||||
return fn(l, i + 1);
|
||||
})["catch"](function(m, s) {
|
||||
return e(m, s);
|
||||
});
|
||||
};
|
||||
return fn(dep, 0);
|
||||
});
|
||||
};
|
||||
|
||||
return BaseObject;
|
||||
|
||||
})();
|
||||
|
||||
makeclass("BaseObject", BaseObject);
|
||||
|
||||
APIManager = (function(superClass) {
|
||||
extend(APIManager, superClass);
|
||||
|
||||
function APIManager() {
|
||||
APIManager.__super__.constructor.call(this, "APIManager");
|
||||
}
|
||||
|
||||
APIManager.prototype.init = function(cname) {
|
||||
console.log(cname);
|
||||
return this.ready().then(function() {
|
||||
if (mobilecheck()) {
|
||||
mobileConsole.init();
|
||||
}
|
||||
if (!cname || cname === "") {
|
||||
return;
|
||||
}
|
||||
if (!window.classes[cname]) {
|
||||
return console.error("Cannot find class ", cname);
|
||||
}
|
||||
return (new window.classes[cname]).init();
|
||||
})["catch"](function(m, s) {
|
||||
return console.error(m, s);
|
||||
});
|
||||
};
|
||||
|
||||
return APIManager;
|
||||
|
||||
})(window.classes.BaseObject);
|
||||
|
||||
APIManager.dependencies = ["/assets/scripts/mobile_console.js"];
|
||||
|
||||
makeclass("APIManager", APIManager);
|
||||
|
||||
MarkOn = (function(superClass) {
|
||||
extend(MarkOn, superClass);
|
||||
|
||||
function MarkOn(id) {
|
||||
this.id = id;
|
||||
MarkOn.__super__.constructor.call(this, "MarkOn");
|
||||
}
|
||||
|
||||
MarkOn.prototype.init = function() {
|
||||
var me;
|
||||
me = this;
|
||||
return this.ready().then(function() {
|
||||
return me.editor = new SimpleMDE({
|
||||
element: $(me.id)[0]
|
||||
});
|
||||
})["catch"](function(m, s) {
|
||||
return console.error(m, s);
|
||||
});
|
||||
};
|
||||
|
||||
return MarkOn;
|
||||
|
||||
})(window.classes.BaseObject);
|
||||
|
||||
MarkOn.dependencies = ["/rst/gscripts/mde/simplemde.min.js"];
|
||||
|
||||
makeclass("MarkOn", MarkOn);
|
||||
|
||||
}).call(this);
|
1325
apps/assets/scripts/mobile_console.js
Normal file
1325
apps/assets/scripts/mobile_console.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user