diff --git a/lib/client.js b/lib/client.js index 10684cb5..49fa380c 100644 --- a/lib/client.js +++ b/lib/client.js @@ -409,9 +409,6 @@ CloudCmd._changeLinks = function(pPanelID){ var lPanel = DOM.getById(pPanelID), a = lPanel.getElementsByTagName('a'), - /* номер ссылки иконки обновления страницы */ - lREFRESHICON = 0, - /* right mouse click function varible */ lOnContextMenu_f = function(pEvent){ var lReturn_b = true; @@ -475,7 +472,9 @@ CloudCmd._changeLinks = function(pPanelID){ lUrl = CloudCmd.HOST; - var lLoadDirOnce = CloudCmd._loadDir(); + var lLoadDirOnce = CloudCmd._loadDir(), + /* номер ссылки иконки обновления страницы */ + lREFRESHICON = 0; for(var i = 0, n = a.length; i < n ; i++){ /* убираем адрес хоста*/ var ai = a[i], @@ -555,7 +554,7 @@ CloudCmd._ajaxLoad = function(pPath, pOptions){ */ var lRet = pOptions.refresh; if(!lRet){ - var lJSON = DOM.Cache.get(pPath); + var lJSON = DOM.Cache.get(lCleanPath); if (lJSON){ /* переводим из текста в JSON */ @@ -587,7 +586,7 @@ CloudCmd._ajaxLoad = function(pPath, pOptions){ /* если размер данных не очень бошьой * * сохраняем их в кэше */ if(lJSON_s.length < 50000 ) - DOM.Cache.set(pPath, lJSON_s); + DOM.Cache.set(lCleanPath, lJSON_s); } }); }; @@ -642,8 +641,7 @@ CloudCmd._getJSONfromFileTable = function(){ }], lLI = lLeft.getElementsByTagName('li'), - - j = 1; /* счётчик реальных файлов */ + i, n, j = 1; /* счётчик реальных файлов */ /* счётчик элементов файлов в DOM */ /* Если путь отличный от корневного @@ -652,46 +650,18 @@ CloudCmd._getJSONfromFileTable = function(){ */ /* пропускам Path и Header*/ - for(var i = 2, n = lLI.length; i < n; i++){ - var lChildren = lLI[i].children, - /* file attributes */ - lAttr = {}; - - /* getting all elements to lAttr object */ - for(var l = 0; l < lChildren.length; l++) - lAttr[lChildren[l].className] = lChildren[l]; - - /* mini-icon */ - var lIsDir = lAttr['mini-icon directory'] ? true : false, - - lName = lAttr.name; - if(lName) - lName = DOM.getByTag('a', lName); - - /* if found link to folder - * cheking is it a full name - * or short - */ - /* if short we got title - * if full - getting textConent - */ - if(lName.length) - lName = lName[0]; - - lName = lName.title || lName.textContent; - - /* если это папка - выводим слово dir вместо размера*/ - var lSize = lIsDir ? 'dir' : lAttr.size.textContent, - lMode = lAttr.mode.textContent; - + for(i = 2, n = lLI.length; i < n; i++){ + var lCurrent = lLI[i], + /* переводим права доступа в цыфровой вид * для хранения в localStorage */ - lMode = CloudFunc.convertPermissionsToNumberic(lMode); + lMode = DOM.getCurrentMode(lCurrent); + lMode = CloudFunc.convertPermissionsToNumberic(lMode); - lFileTable[ j++ ]={ - name: lName, - size: lSize, + lFileTable[ j++ ] = { + name: DOM.getCurrentName(lCurrent), + size: DOM.getCurrentSize(lCurrent), mode: lMode }; } diff --git a/lib/client/dom.js b/lib/client/dom.js index 3a14ee20..af740a4c 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -866,12 +866,30 @@ var CloudCommander, Util, return lRet; }; - + /** + * + * @pCurrentFile + */ DOM.getCurrentSize = function(pCurrentFile){ var lRet, lCurrent = pCurrentFile || DOM.getCurrentFile(), lSize = DOM.getByClass('size', lCurrent); - lRet = lSize[0].textContent; + lSize = lSize[0].textContent; + /* если это папка - возвращаем слово dir вместо размера*/ + lRet = Util.removeStr(lSize, ['<', '>']); + + return lRet; + }; + + /** + * + * @pCurrentFile + */ + DOM.getCurrentMode = function(pCurrentFile){ + var lRet, + lCurrent = pCurrentFile || DOM.getCurrentFile(), + lMode = DOM.getByClass('mode', lCurrent); + lRet = lMode[0].textContent; return lRet; }; @@ -1057,7 +1075,7 @@ var CloudCommander, Util, */ DOM.isCurrentIsDir = function(pCurrentFile){ var lSize = DOM.getCurrentSize(pCurrentFile), - lRet = lSize === '