diff --git a/README.md b/README.md index dcf038a0..73875bab 100644 --- a/README.md +++ b/README.md @@ -56,11 +56,21 @@ you can just type in cloudcmd directory: Additional modules: --------------- -**Cloud Commander** not using additional modules for main functionality. +**Cloud Commander's Server Side** not using additional modules for main functionality. But for minification and optimization tricks optional can be assingned (and installed) module: [Minify] (https://github.com/coderaiser/minify "Minify"). Install addtitional modules: git submodule init - git submodule update \ No newline at end of file + git submodule update + +**Cloud Commander's Client Side** use module jquery for ajaxing. +We could not use this module, but this way is fast: +- google cdn +- gzip +- cache + +Perhaps in the future, it will not be used, but so far it has no effect on +start loading of Cloud Commander Client Side and do things fast and stable +it is using now. \ No newline at end of file diff --git a/client.js b/client.js index a071c62d..03ec22bf 100644 --- a/client.js +++ b/client.js @@ -133,7 +133,7 @@ CloudClient.Cache.clear=(function(){ CloudClient.keyBinding=(function(){ /* loading keyBinding module and start it */ CloudClient.jsload(CloudClient.LIBDIRCLIENT+'keyBinding.js',function(){ - CloudCommander.keyBinding(); + CloudCommander.keyBinding(); }); }); @@ -282,7 +282,6 @@ CloudClient._currentToParent = (function(pDirName){ var LoadingImage; var ErrorImage; -var $; var CloudFunc; /* Конструктор CloudClient, который * выполняет весь функционал по @@ -298,28 +297,25 @@ CloudClient.init=(function() if(lTitle.length>0)lTitle[0].textContent='Cloud Commander'; /* загружаем jquery: */ - CloudClient.jsload('//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',function(){ - /* сохраняем переменную jQuery себе в область видимости */ - $=window.jQuery; - if(!window.jQuery)CloudClient.jsload('jquery.min.js', - function(){ - $=window.jQuery; - }); + CloudClient.jsload('//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',{ + onerror: function(){ + CloudClient.jsload('lib/client/jquery.min.js'); + } }); /* загружаем общие функции для клиента и сервера*/ CloudClient.jsload(CloudClient.LIBDIR+'cloudfunc.js',function(){ - /* берём из обьекта window общий с сервером функционал */ - CloudFunc=window.CloudFunc; + /* берём из обьекта window общий с сервером функционал */ + CloudFunc=window.CloudFunc; - /* меняем ссылки на ajax'овые*/ - CloudClient._changeLinks(CloudFunc.LEFTPANEL); - CloudClient._changeLinks(CloudFunc.RIGHTPANEL); - - /* устанавливаем переменную доступности кэша*/ - CloudClient.Cache.isAllowed(); - /* Устанавливаем кэш корневого каталога */ - if(!CloudClient.Cache.get('/'))CloudClient.Cache.set('/',CloudClient._getJSONfromFileTable()); + /* меняем ссылки на ajax'овые*/ + CloudClient._changeLinks(CloudFunc.LEFTPANEL); + CloudClient._changeLinks(CloudFunc.RIGHTPANEL); + + /* устанавливаем переменную доступности кэша*/ + CloudClient.Cache.isAllowed(); + /* Устанавливаем кэш корневого каталога */ + if(!CloudClient.Cache.get('/'))CloudClient.Cache.set('/',CloudClient._getJSONfromFileTable()); } ); @@ -570,7 +566,9 @@ CloudClient._createFileTable = function(pElem,pJSON) * загружает файл с src. * @pName - название тэга * @pSrc - путь к файлу - * @pFunc - функци + * @pFunc - обьект, содержаий одну из функций + * или сразу две onload и onerror + * {onload: function(){}, onerror: function();} * @pStyle - стиль * @pId - id * @pElement - элемент, дочерним которо будет этот @@ -589,16 +587,24 @@ CloudClient._anyload = function(pName,pSrc,pFunc,pStyle,pId,pElement) { var element = document.createElement(pName); element.src = pSrc; - element.id=lID; + element.id=lID; if(arguments.length>=3){ - element.onload=pFunc; + /* if passed arguments function + * then it's onload by default + */ + if(typeof pFunc === 'function'){ + element.onload=pFunc; + /* if object - then onload or onerror */ + }else if (typeof pFunc === 'object'){ + if(pFunc.onload)element.onload = pFunc.onload; + if(pFunc.onerror)element.onerror=pFunc.onerror; + } if(arguments.length>=4){ element.style.cssText=pStyle; } - } - //document.body - pElement.appendChild(element); - return element;//'elem '+src+' loaded'; + } + pElement.appendChild(element); + return element; } /* если js-файл уже загружен * запускаем функцию onload @@ -683,20 +689,22 @@ CloudClient._getJSONfromFileTable=function() * можна заменить на любой другой код */ if(!document.getElementsByClassName){ - CloudClient.jsload('//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',function(){ - /* сохраняем переменную jQuery себе в область видимости */ - document.getElementsByClassName=function(pClassName){ - return $('.'+pClassName)[0]; - }; - $=window.jQuery; - if(!window.jQuery)CloudClient.jsload('jquery.min.js', - function(){ - $=window.jQuery; - document.getElementsByClassName=function(pClassName){ - return $('.'+pClassName)[0]; - }; - }); - }); + CloudClient.jsload('//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',{ + onload: function(){ + /* сохраняем переменную jQuery себе в область видимости */ + document.getElementsByClassName=function(pClassName){ + return window.jQuery('.'+pClassName)[0]; + }; + }, + onerror: function(){ + CloudClient.jsload(CloudClient.LIBDIRCLIENT + 'jquery.min.js', + function(){ + document.getElementsByClassName=function(pClassName){ + return window.jQuery('.'+pClassName)[0]; + }; + }); + } + }); } return CloudClient; diff --git a/config.json b/config.json index 66993965..263dbdb4 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { - "cache" : {"allowed" : true}, + "cache" : {"allowed" : false}, "minification" : { - "js" : true, + "js" : false, "css" : true, "html" : true, "img" : true diff --git a/lib/server/minify b/lib/server/minify index 9182145c..f1b68d37 160000 --- a/lib/server/minify +++ b/lib/server/minify @@ -1 +1 @@ -Subproject commit 9182145ca9e60dd4aaf1729eb6dbc450641a80e6 +Subproject commit f1b68d371b7b26da14d0e2b6e3e5f9923c8fa0e4