From 91ac8802fe9bd3eecbb5bbfb74ea5b65d1e07f66 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 29 Nov 2012 07:34:39 -0500 Subject: [PATCH] added debug method to util --- cloudcmd.js | 4 ++-- config.json | 2 +- lib/client/dom.js | 8 +++---- lib/client/storage/_github.js | 1 + lib/util.js | 39 +++++++++++++++++++++++++++++++---- 5 files changed, 43 insertions(+), 11 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 3c9c2603..7c7707ad 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -1,6 +1,6 @@ (function(){ "use strict"; - + var DIR = __dirname + '/', main = require(DIR + 'lib/server/main'), @@ -46,7 +46,7 @@ * минифицированый */ if(srv.Minify._allowed.css){ - var lPath = srv.Minify.MinFolder.replace(DIR, ''); + var lPath = '/' + srv.Minify.MinFolder.replace(DIR, ''); lReplace_s = ''; diff --git a/config.json b/config.json index 76111b3e..a5664801 100644 --- a/config.json +++ b/config.json @@ -2,7 +2,7 @@ "cache" : {"allowed" : false}, "appcache" : false, "minification" : { - "js" : true, + "js" : false, "css" : true, "html" : true, "img" : true diff --git a/lib/client/dom.js b/lib/client/dom.js index e598b802..468c54e3 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -180,8 +180,7 @@ var CloudCommander, Util, DOM, CloudFunc; */ DOM.Cache = function(){ /* приватный переключатель возможности работы с кэшем */ - var CacheAllowed, - Data = {}; + var CacheAllowed; /* функция проверяет возможно ли работать с кэшем каким-либо образом */ this.isAllowed = function(){ @@ -265,6 +264,7 @@ var CloudCommander, Util, DOM, CloudFunc; DOM.Cache = new DOM.Cache(); + /** * Function gets id by src * @param pSrc @@ -721,14 +721,14 @@ var CloudCommander, Util, DOM, CloudFunc; */ DOM.getCurrentFile = function(){ var lCurrent = DOM.getByClass(getCurrentFile())[0]; - if(!lCurrent) + if(!lCurrent){ DOM.addCloudStatus({ code : -1, msg : 'Error: can not find ' + 'CurrentFile ' + 'in getCurrentFile' }); - + } return lCurrent; }; diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js index 798fb7b3..ffdf9bdd 100644 --- a/lib/client/storage/_github.js +++ b/lib/client/storage/_github.js @@ -110,6 +110,7 @@ var CloudCommander, Util, DOM, $, Github, cb; }); } else + //window.open('welcome.html', 'welcome','width=300,height=200,menubar=yes,status=yes')"> window.location = 'https://github.com/login/oauth/authorize?client_id=' + CLIENT_ID + '&&scope=repo,user,gist'; diff --git a/lib/util.js b/lib/util.js index eb2c2f7e..7d5c16c2 100644 --- a/lib/util.js +++ b/lib/util.js @@ -6,9 +6,11 @@ var Util, exports; (function(){ "use strict"; - + Util = exports || {}; + var Scope = exports ? global : window; + /** setting function context * @param {function} pFunction * @param {object} pContext @@ -22,6 +24,16 @@ var Util, exports; return lRet; }; + Util.breakpoint = function(){ + var lRet = Util.tryCatch(function(){ + debugger; + }); + + Util.log(lRet); + + return lRet; + }; + /** * Функция ищет в имени файла расширение * и если находит возвращает true @@ -82,9 +94,11 @@ var Util, exports; * @param pArg */ Util.log = function(pArg){ - var lRet = pArg; - if(pArg) - console.log(pArg); + var lRet = pArg, + lConsole = Scope.console; + + if(lConsole && pArg) + lConsole.log(pArg); return lRet; }; @@ -285,6 +299,21 @@ var Util, exports; return lRet; }; + /** + * function execute param function in + * try...catch block and log result + * + * @param pCallBack + */ + Util.tryCatchDebug = function(pCallBack){ + var lRet = Util.tryCatch(pCallBack); + + if(lRet) + Util.debug(); + + return lRet; + }; + /** * function execute param function in * try...catch block and log result @@ -298,6 +327,7 @@ var Util, exports; return Util.log(lRet); }; + /** * function do save exec of function * @param pCallBack @@ -326,4 +356,5 @@ var Util, exports; return hours + ":" + minutes + ":" + seconds; }; + })(); \ No newline at end of file