refactored

This commit is contained in:
coderaiser 2013-01-31 06:20:37 -05:00
parent 352ca8388e
commit 0472827aa9
4 changed files with 37 additions and 22 deletions

View file

@ -2,7 +2,7 @@
"api_url" : "/api/v1",
"appcache" : false,
"minification" : {
"js" : true,
"js" : false,
"css" : true,
"html" : true,
"img" : true

View file

@ -452,7 +452,7 @@ CloudCmd._changeLinks = function(pPanelID){
lType = lElement.parentElement.nextSibling;
if(lType && lType.textContent === '<dir>'){
lLink = lLink.replace(lNoJS_s,'');
lLink = Util.removeStr(lLink, lNoJS_s);
lName += '.json';
}

View file

@ -262,10 +262,12 @@
AppCache.watch(lName);
Util.log(Path.basename(lName));
var lMin_o = lConfig.minification,
lExt = Util.getExtension(lName),
lResult = lExt === '.js' && lMin_o.js ||
lExt === '.css' && lMin_o.css ||
lExt === '.html' && lMin_o.html;
var lExt = Util.getExtension(lName),
lResult = lExt === '.js' || lExt === '.css' || lExt === '.html';
if(lResult)
lResult = Minify.optimize(lName, {
request : pReq,
@ -279,18 +281,14 @@
response: pRes
});
}else{/* если мы имеем дело с файловой системой*/
/* если путь не начинаеться с no-js - значит
}else{
/* если мы имеем дело с файловой системой
* если путь не начинаеться с no-js - значит
* js включен
*/
/* убираем пометку cloud, без которой c9.io
* не работает поскольку путь из двух слешей
* (/fs/no-js/) - очень короткий, нужно
* длиннее
*/
if(lPath.indexOf(lNoJS_s) !== lFS_s.length && lPath !== '/')
CloudServer.NoJS = false;
CloudServer.NoJS = false;
else{
CloudServer.NoJS = true;
lPath = Util.removeStr(lPath, lNoJS_s);
@ -313,15 +311,8 @@
if(lQuery === 'json')
CloudServer.NoJS = false;
/* если в итоге путь пустой
* делаем его корневым
*/
if (lPath === '')
lPath = '/';
DirPath = lPath;
DirPath = lPath || '/';
CloudServer.Responses[DirPath] = pRes;
CloudServer.Statuses[DirPath] = OK;

View file

@ -176,7 +176,31 @@ Util = exports || {};
* @param pSubStr
*/
Util.removeStr = function(pStr, pSubStr){
return pStr.replace(pSubStr, '');
var lRet;
if( Util.isString(pStr) ){
var n = pSubStr.length;
if( Util.isArray(pSubStr) )
Util.fori(n, function(i){
lRet = pStr = pStr.replace(pSubStr[i], '');
});
else
lRet = pStr.replace(pSubStr, '');
}
return lRet;
};
Util.for = function(pI, pN, pFunc){
if(Util.isFunction(pFunc))
for(var i = pI, n = pN; i < n; i++)
pFunc(i);
};
Util.fori = function(pN, pFunc){
var lRet = Util.for(0, pN, pFunc);
return lRet;
};
/**