added getCurrentPath function to Util module

This commit is contained in:
coderaiser 2012-12-05 06:55:32 -05:00
parent 71919aa206
commit 4a2b975d09
4 changed files with 28 additions and 22 deletions

View file

@ -162,6 +162,8 @@ Added dropbox_id option.
* Added ability to upload file to gists on github thru menu.
* Added getCurrentPath function to Util module.
2012.10.01, Version 0.1.7

View file

@ -888,6 +888,21 @@ var CloudCommander, Util, DOM, CloudFunc;
return lRet;
};
/**
* get link from current (or param) file
*
* @param pCurrentFile - current file by default
*/
DOM.getCurrentPath = function(pCurrentFile){
var lCurrent = pCurrentFile || DOM.getCurrentFile(),
lPath = DOM.getCurrentLink(lCurrent).href;
/* убираем адрес хоста*/
lPath = Util.removeStr(lPath, CloudCommander.HOST);
lPath = Util.removeStr(lPath, CloudFunc.NOJS);
return lPath;
};
/**
* get name from current (or param) file
*

View file

@ -123,28 +123,20 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror;
/* getting link */
var lCurrentFile = DOM.getCurrentFile(),
lA = DOM.getCurrentLink(lCurrentFile);
lA = lA.href;
/* убираем адрес хоста*/
lA = Util.removeStr(lA, cloudcmd.HOST);
lPath = DOM.getCurrentPath(lCurrentFile);
/* checking is this link is to directory */
var lSize = DOM.getByClass('size', lCurrentFile);
if(lSize){
lSize = lSize[0].textContent;
/* if directory - load json
* not html data
/* when folder view
* is no need to edit
* data
*/
if (lSize === '<dir>'){
lA = Util.removeStr(lA, CloudFunc.NOJS);
/* when folder view
* is no need to edit
* data
*/
ReadOnly = true;
}
if (lSize === '<dir>')
ReadOnly = true;
}
Loading = true;
@ -155,7 +147,7 @@ var CloudCommander, Util, DOM, CloudFunc, CodeMirror;
/* reading data from current file */
DOM.ajax({
url:lA,
url:lPath,
error: function(jqXHR, textStatus, errorThrown){
Loading = false;
return DOM.Images.showError(jqXHR);

View file

@ -68,14 +68,11 @@ var CloudCommander, Util, DOM, CloudFunc, $;
'upload_to_gist': {name: 'to Gist',
callback: function(key, opt){
var lCurrent = DOM.getCurrentFile(),
lA = DOM.getCurrentLink(lCurrent).href,
lPath = DOM.getCurrentPath(),
lName = DOM.getCurrentName(lCurrent);
/* убираем адрес хоста*/
lA = Util.removeStr(lA, cloudcmd.HOST);
lA = Util.removeStr(lA, CloudFunc.NOJS);
DOM.ajax({
url : lA,
url : lPath,
error : DOM.Images.showError,
success : function(data, textStatus, jqXHR){
if( Util.isObject(data) )