diff --git a/lib/client.js b/lib/client.js index 49e81d98..7d3bd0f1 100644 --- a/lib/client.js +++ b/lib/client.js @@ -331,11 +331,23 @@ var Util, DOM, CloudFunc; var json, str, ret = options && options.refresh, SLASH = '/', + dirPath = DOM.getCurrentDirPath(), fsPath = decodeURI(path), noJSONPath = Util.removeStr(fsPath, '?json' ), cleanPath = Util.removeStrOneTime(noJSONPath, CloudFunc.FS) || SLASH, - title = CloudFunc.getTitle(cleanPath), - oldURL = window.location.pathname; + setTitle = function() { + var title; + + dirPath = CloudFunc.rmLastSlash(dirPath) || '/'; + + if (dirPath !== cleanPath) { + if (!options.nohistory) + DOM.setHistory(noJSONPath, null, noJSONPath); + + title = CloudFunc.getTitle(cleanPath); + DOM.setTitle(title); + } + }; if (!options) options = {}; @@ -345,11 +357,6 @@ var Util, DOM, CloudFunc; Util.log ('reading dir: "' + cleanPath + '";'); - if (!options.nohistory) - DOM.setHistory(noJSONPath, null, noJSONPath); - - DOM.setTitle(title); - /* если доступен localStorage и * в нём есть нужная нам директория - * читаем данные с него и @@ -365,6 +372,7 @@ var Util, DOM, CloudFunc; else { json = Util.parseJSON(str); CloudCmd.createFileTable(json); + setTitle(); } } @@ -372,13 +380,12 @@ var Util, DOM, CloudFunc; DOM.getCurrentFileContent({ url : fsPath, dataType : 'json', - error : function() { - DOM.setHistory(oldURL, null, oldURL); - }, success : function(data) { var str = Util.stringifyJSON(data), MAX_SIZE = 50000; + setTitle(); + CloudCmd.createFileTable(data); Util.log(str.length);