feature(modules) add jquery, socket

This commit is contained in:
coderaiser 2014-06-02 06:14:40 -04:00
parent b6f5b45279
commit e25ba0b884
3 changed files with 33 additions and 34 deletions

View file

@ -9,6 +9,19 @@
"socket",
"terminal",
"console", [{
"name": "remote",
"data": [ {
"name": "jquery",
"version": "2.1.1",
"local": "/lib/client/jquery.js",
"remote": "//ajax.googleapis.com/ajax/libs/jquery/{{ version }}/jquery.min.js"
}, {
"name": "socket",
"version": "1.0.0",
"local": "/socket.io/socket.io.js",
"remote": "//cdn.socket.io/socket.io-{{ version }}.js"
}]
}, {
"name": "storage",
"data": [{
"name": "DropBox",

View file

@ -333,16 +333,24 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
return ret;
}
function loadRemote(url, callback) {
Util.checkArgs(arguments, ['url', 'callback']);
function loadRemote(name, callback) {
var getConfig = CloudCmd.getConfig,
getModules = CloudCmd.getModules;
CloudCmd.getConfig(function(config) {
Util.exec.parallel([getConfig, getModules], function(config, modules) {
var load = DOM.load,
online = config.online && navigator.onLine,
local = url.local,
remote = url.remote,
remoteObj = Util.findObjByNameInArr(modules, 'remote'),
jquery = Util.findObjByNameInArr(remoteObj, name),
online = config.online && navigator.onLine,
version = jquery.version,
local = jquery.local,
remoteTmpl = jquery.remote,
remote = Util.render(remoteTmpl, {
version: version
}),
funcON = function() {
load.js(remote, {
@ -366,35 +374,11 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
* @param callback
*/
this.loadJquery = function(callback) {
var VERSION = '2.1.1',
local = '/lib/client/jquery.js',
remoteTemplate = '//ajax.googleapis.com/ajax/libs/jquery/{{ version }}/jquery.min.js',
remote = Util.render(remoteTemplate, {
version: VERSION
});
loadRemote({
local : local,
remote : remote
}, callback);
loadRemote('jquery', callback);
};
this.loadSocket = function(callback) {
var VERSION = '1.0.0',
local = '/socket.io/socket.io.js',
remoteTemplate = 'https://cdn.socket.io/socket.io-{{ version }}.js',
remote = Util.render(remoteTemplate, {
version: VERSION
});
loadRemote({
local : local,
remote : remote
}, callback);
loadRemote('socket', callback);
};
/** function loads css and js of Menu

View file

@ -886,10 +886,12 @@
if (isArray) {
array.some(function(item) {
var is,
var is = item.name === name,
isArray = Util.isArray(item);
if (isArray)
if (is)
ret = item;
else if (isArray)
item.some(function(item) {
is = item.name === name;