-
Notifications
You must be signed in to change notification settings - Fork 1
/
CLFramework.js
66 lines (66 loc) · 1.9 KB
/
CLFramework.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
CL = {}
CL.Framework = {
bundledModules: [
"dynloader",
"shaderloader",
"utils",
"lightBox",
],
bundledModulePaths: {
dynloader: "CLDynamicFileLoader.js",
shaderloader: "CLShaderLoader.js",
utils: "CLUtils.js",
lightBox: "CLLightBox.js",
},
modules: {},
customModules: [],
version: "0.0.1",
modulesDir: "/CL/",
afterInit: null,
addCustomModule: function(name, location) {
this.customModules[name] = location;
},
grabModules: function(init) {
if (!init) { this.loadLoader(); return true; }
for (m in this.bundledModules) {
m = this.bundledModules[m]
if (m != "dynloader") this.modules.dynloader.addLib({"name": m, "location": this.modulesDir + this.bundledModulePaths[m]});
}
this.modules.dynloader.processQueue(CL.Framework.loadModules)
},
loadModules: function(callback) {
for(m in CL.Framework.bundledModules) {
m = CL.Framework.bundledModules[m]
if (m != "dynloader") {
name = CL.Framework.bundledModulePaths[m]
name = name.substr(name.lastIndexOf("CL") + 2)
name = name.substr(0, name.lastIndexOf("."))
CL.Framework.loadModule(m, name)
}
}
CL.Framework.afterInit()
},
loadModule: function(name, module) {
this.modules[name] = CL[module];
if (typeof(CL[module].onModuleLoad) == "function") CL[module].onModuleLoad()
},
loadLoader: function(callback) {
script = document.createElement("script");
script.src = this.modulesDir + this.bundledModulePaths.dynloader;
script.id = "dynloader";
script.type = 'text/javascript';
script.onload = function() {
CL.Framework.loadModule("dynloader", "DynamicFileLoader");
document.head.removeChild(this)
CL.Framework.grabModules(true, callback);
}
document.head.appendChild(script)
return true;
},
init: function(callback){
callback = typeof(callback) == "undefined" ? CL.Framework.nullFunc : callback
CL.Framework.afterInit = callback;
this.grabModules()
},
nullFunc: function() {}
}