mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
added ability to add ?json flag only if we work with dir
This commit is contained in:
parent
7ddd67f3b0
commit
0dec6bc042
3 changed files with 32 additions and 28 deletions
|
|
@ -146,6 +146,8 @@ now json data of file structure would be getted from
|
|||
click event with ?json flag. "no-js" part of url
|
||||
would not be supported anymore.
|
||||
|
||||
* Added ability to add ?json flag only if we work with dir.
|
||||
|
||||
|
||||
2012.12.12, Version 0.1.8
|
||||
|
||||
|
|
|
|||
|
|
@ -884,15 +884,11 @@ var CloudCommander, Util,
|
|||
*/
|
||||
DOM.getCurrentFileContent = function(pParams, pCurrentFile){
|
||||
var lRet,
|
||||
lParams = pParams ? pParams : {},
|
||||
/* adding ?json param
|
||||
* if file would be ignored and
|
||||
* if directory would be
|
||||
* geted back in json format
|
||||
*/
|
||||
lPath = DOM.getCurrentPath(pCurrentFile) + '?json',
|
||||
lErrorWas = pParams.error,
|
||||
lError = function(jqXHR){
|
||||
lCurrentFile = pCurrentFile ? pCurrentFile : DOM.getCurrentFile(),
|
||||
lParams = pParams ? pParams : {},
|
||||
lPath = DOM.getCurrentPath(lCurrentFile),
|
||||
lErrorWas = pParams.error,
|
||||
lError = function(jqXHR){
|
||||
Util.exec(lErrorWas);
|
||||
DOM.Images.showError(jqXHR);
|
||||
};
|
||||
|
|
@ -901,6 +897,10 @@ var CloudCommander, Util,
|
|||
|
||||
lParams.error = lError;
|
||||
|
||||
|
||||
if( DOM.isCurrentDir(lCurrentFile) )
|
||||
lPath += '?json';
|
||||
|
||||
if(!lParams.url)
|
||||
lParams.url = lPath;
|
||||
|
||||
|
|
@ -916,9 +916,11 @@ var CloudCommander, Util,
|
|||
* @pCurrentFile
|
||||
*/
|
||||
DOM.getCurrentData = function(pCallBack, pCurrentFile){
|
||||
|
||||
var lParams,
|
||||
lCurrentFile = pCurrentFile ? pCurrentFile : DOM.getCurrentFile(),
|
||||
lFunc = function(pData){
|
||||
var lName = DOM.getCurrentName(pCurrentFile);
|
||||
var lName = DOM.getCurrentName(lCurrentFile);
|
||||
if( Util.isObject(pData) ){
|
||||
pData = Util.stringifyJSON(pData);
|
||||
|
||||
|
|
@ -942,7 +944,7 @@ var CloudCommander, Util,
|
|||
};
|
||||
|
||||
|
||||
return DOM.getCurrentFileContent(lParams, pCurrentFile);
|
||||
return DOM.getCurrentFileContent(lParams, lCurrentFile);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -1042,12 +1044,24 @@ var CloudCommander, Util,
|
|||
* @param pCurrentFile
|
||||
*/
|
||||
DOM.isCurrentFile = function(pCurrentFile){
|
||||
var lCurrentFileClass = pCurrentFile.className,
|
||||
lIsCurrent = lCurrentFileClass.indexOf(CURRENT_FILE) >= 0;
|
||||
var lClass = pCurrentFile && pCurrentFile.className,
|
||||
lIsCurrent = lClass && lClass.indexOf(CURRENT_FILE) >= 0;
|
||||
|
||||
return lIsCurrent;
|
||||
};
|
||||
|
||||
/**
|
||||
* check is current file is a directory
|
||||
*
|
||||
* @param pCurrentFile
|
||||
*/
|
||||
DOM.isCurrentDir = function(pCurrentFile){
|
||||
var lSize = DOM.getCurrentSize(pCurrentFile),
|
||||
lRet = lSize === '<dir>';
|
||||
|
||||
return lRet;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* get link from current (or param) file
|
||||
|
|
|
|||
|
|
@ -212,11 +212,8 @@
|
|||
lJSON[i+1] = lJSONFile;
|
||||
}
|
||||
|
||||
/* если js недоступен
|
||||
* или отключен выcылаем html-код
|
||||
* и прописываем соответствующие заголовки
|
||||
*/
|
||||
if( noJS(lReq) ){
|
||||
/* если js отключен выcылаем html-код */
|
||||
if( main.getQuery(lReq) === 'html' ){
|
||||
var lPanel = CloudFunc.buildFromJSON(lJSON);
|
||||
lList = '<ul id=left class=panel>' + lPanel + '</ul>' +
|
||||
'<ul id=right class=panel>' + lPanel + '</ul>';
|
||||
|
|
@ -385,6 +382,7 @@
|
|||
return lRet;
|
||||
}
|
||||
|
||||
|
||||
function getDirPath(pReq){
|
||||
var lRet = getCleanPath(pReq);
|
||||
|
||||
|
|
@ -394,16 +392,6 @@
|
|||
return lRet;
|
||||
}
|
||||
|
||||
function noJS(pReq){
|
||||
var lNoJS, lPath;
|
||||
if(pReq){
|
||||
lPath = getPath(pReq);
|
||||
|
||||
lNoJS = lPath === '/' || main.getQuery(pReq) === 'html';
|
||||
}
|
||||
|
||||
return lNoJS;
|
||||
}
|
||||
|
||||
function isGZIP(pReq){
|
||||
var lEnc, lGZIP;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue