From b201b4978e2dfb4949a6e509be6a4f7ac987da50 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 24 Jul 2012 15:03:23 -0400 Subject: [PATCH] _currentToParent refactored, no more cicles again --- client.js | 43 ++++++++++------------------------------ lib/client/keyBinding.js | 1 - 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/client.js b/client.js index 942f07a8..b9ecddd7 100644 --- a/client.js +++ b/client.js @@ -265,43 +265,20 @@ CloudClient._currentToParent = (function(pDirName){ /* опредиляем в какой мы панели: * правой или левой */ - var lCurrentFile=document.getElementsByClassName(CloudClient.CURRENT_FILE); - var lPanel; - try{ - lPanel=lCurrentFile[0].parentElement.id; - }catch(error){console.log("Current file not found\n"+error);} + var lCurrentFile = document.getElementsByClassName(CloudClient.CURRENT_FILE); + var lPanel = lCurrentFile[0].parentElement; + /* убираем слэш с имени каталога*/ pDirName=pDirName.replace('/',''); - /* ищем файл с таким именем*/ - lPanel=document.getElementById(lPanel); - if(!lPanel)return; - var lLi=lPanel.getElementsByTagName('li'); + var lRootDir = document.getElementById(pDirName + '_' + lPanel.id); - /* если длина названия папки больше - * CloudFunc.SHORTNAMELENGTH уменьшаем её - */ - var pShortDirName = CloudFunc.getShortedName(pDirName); - for(var i=0;i CloudFunc.SHORTNAMELENGTH && - lA[0].title !== pDirName) - continue; - /* если уже выделен какой-то файл, снимаем - * выделение - */ - lCurrentFile=lPanel.getElementsByClassName(CloudClient.CURRENT_FILE); - if(lCurrentFile.length>0)lCurrentFile[0].className=''; - - lLi[i].className=CloudClient.CURRENT_FILE; - - break; - } - } + /* if found li element with ID directory name + * set it to current file + */ + lRootDir && + !(lCurrentFile[0].className = '') && + (lRootDir.className = CloudClient.CURRENT_FILE); }); /* глобальные переменные */ diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 805d7bf2..3a8397fe 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -43,7 +43,6 @@ CloudCommander.keyBinding=(function(){ * moving down the scroolbar */ lTop = lCurrentFile.previousSibling.offsetTop; - console.log(lTop); lTop % (CloudCommander.HEIGHT - CloudCommander.HEIGHT/10) < 70 &&