diff --git a/ChangeLog b/ChangeLog index 57989950..fc951cef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/lib/client/dom.js b/lib/client/dom.js index 5d30f489..4b19067b 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -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 * diff --git a/lib/client/editor/_codemirror.js b/lib/client/editor/_codemirror.js index b209215c..633480b4 100644 --- a/lib/client/editor/_codemirror.js +++ b/lib/client/editor/_codemirror.js @@ -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 === ''){ - lA = Util.removeStr(lA, CloudFunc.NOJS); - /* when folder view - * is no need to edit - * data - */ - ReadOnly = true; - } + if (lSize === '') + 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); diff --git a/lib/client/menu.js b/lib/client/menu.js index 0d143c26..4ed5b91d 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -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) )