diff --git a/client.js b/client.js index ce3e32da..c15d6101 100644 --- a/client.js +++ b/client.js @@ -495,7 +495,7 @@ CloudClient._changeLinks = function(pPanelID) if(a[i].target !== '_blank') { /* убираем адрес хоста*/ - var link='/'+a[i].href.replace(document.location.href,''); + var link='/'+a[i].href.replace(document.location.href,''); /* убираем значения, которые говорят, * об отсутствии js */ @@ -635,7 +635,7 @@ CloudClient._ajaxLoad=function(path, pNeedRefresh) /* переводим таблицу файлов в строку, для * сохранения в localStorage */ - var lJSON_s=JSON.stringify(data); + var lJSON_s = JSON.stringify(data); console.log(lJSON_s.length); /* если размер данных не очень бошьой diff --git a/lib/client/editor.js b/lib/client/editor.js index e2c07755..75938e47 100644 --- a/lib/client/editor.js +++ b/lib/client/editor.js @@ -1,4 +1,4 @@ -var CloudCommander, CodeMirror; +var CloudCommander, CloudFunc, CodeMirror; /* object contains editors CodeMirror * and later will be Ace */ @@ -86,11 +86,32 @@ CloudCommander.Editor.CodeMirror = { var lA; if(lCurrent.length){ lCurrent = lCurrent[0]; - - lA = lCurrent.getElementsByTagName('a'); + + /* getting link */ + lA = lCurrent.getElementsByTagName('a'); + if(!lA.length) + return console.log('Error:' + + 'can not find links in current file'); + + lA = lA[0].href; + /* убираем адрес хоста*/ + lA = '/' + lA.replace(document.location.href,''); + + /* checking is this link is to directory */ + var lSize = lCurrent.getElementsByClassName('size'); + if(lSize){ + lSize = lSize[0].textContent; - if(lA.length) - lA = lA[0].href; + /* if directory - load json + * not html data + */ + if (lSize === ''){ + if (lA.indexOf(CloudFunc.NOJS) === + CloudFunc.FS.length){ + lA = lA.replace(CloudFunc.NOJS, ''); + } + } + } } /* показываем гиф загрузки возле пути папки сверху*/ @@ -116,7 +137,11 @@ CloudCommander.Editor.CodeMirror = { console.log(jqXHR.responseText); }, - success:function(data, textStatus, jqXHR){ + success:function(data, textStatus, jqXHR){ + /* if we got json - show it */ + if(typeof data === 'object') + data = JSON.stringify(data); + initCodeMirror_f(data); CloudCommander.keyBinded = false;