fix(client) ajaxLoad: do not save path to history if content not load

This commit is contained in:
coderaiser 2014-02-14 10:44:09 -05:00
parent ce31430f52
commit 4b4b71b9d5

View file

@ -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);