From 9412071926999fb4744a05e49fbae1a997476bcd Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 2 Oct 2013 13:05:16 +0000 Subject: [PATCH] feature(config) add online --- README.md | 1 + lib/client/dom.js | 43 ++++++++++++++++++++++++----------------- lib/client/listeners.js | 5 ++++- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index ee901c88..5c0689e6 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,7 @@ All main configuration could be done via [config.json](json/config.json "Config" "html" : true, "img" : false }, + "online" : true, /* load js files from cdn or local path */ "cache" : true, "logs" : false, /* logs or console ouput */ "show_keys_panel" : true, /* show classic panel with buttons of keys */ diff --git a/lib/client/dom.js b/lib/client/dom.js index f98fc816..2d78f7d5 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1053,26 +1053,33 @@ var CloudCmd, Util, DOM, CloudFunc; * @param pCallBack */ this.jqueryLoad = function(pCallBack) { - Loader.jquery({ - onload: pCallBack, + CloudCmd.getConfig(function(config) { + var online = config.online; - onerror: function() { - Loader.jsload('/lib/client/jquery.js', { - onload: pCallBack + Util.ifExec(!online, + function() { + Loader.jsload('/lib/client/jquery.js', { + onload: pCallBack + }); + + /* if could not load jquery from google server + * maybe we offline, load font from local + * directory */ + Loader.cssSet({ + id :'local-droids-font', + element : document.head, + inner : '@font-face {font-family: "Droid Sans Mono";' + + 'font-style: normal;font-weight: normal;' + + 'src: local("Droid Sans Mono"), local("DroidSansMono"),'+ + ' url("/font/DroidSansMono.woff") format("woff");}' + }); + }, + function(callback) { + Loader.jquery({ + onload: pCallBack, + onerror: callback + }); }); - - /* if could not load jquery from google server - * maybe we offline, load font from local - * directory */ - Loader.cssSet({ - id :'local-droids-font', - element : document.head, - inner : '@font-face {font-family: "Droid Sans Mono";' + - 'font-style: normal;font-weight: normal;' + - 'src: local("Droid Sans Mono"), local("DroidSansMono"),'+ - ' url("/font/DroidSansMono.woff") format("woff");}' - }); - } }); }; diff --git a/lib/client/listeners.js b/lib/client/listeners.js index f74dbcb9..6aa2f731 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -12,7 +12,10 @@ var Util, DOM, CloudCmd; this.analytics = function() { getConfig(function(config) { - if (config.analytics) { + var analytics = config.analytics, + online = config.online; + + if (analytics && online) { Events.addOneTime('mousemove', function(){ var FIVE_SECONDS = 5000, lUrl = CloudCmd.LIBDIRCLIENT + 'analytics.js';