diff --git a/ChangeLog b/ChangeLog index fecc872a..27b906da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -51,6 +51,8 @@ Start file is - cloudcmd.js * Refactored and fixed old bugs in function generateHeaders (server.js). +* Added ability to remove files. + 2012.08.24, Version 0.1.6 diff --git a/client.js b/client.js index 49058835..26e216d1 100644 --- a/client.js +++ b/client.js @@ -661,7 +661,10 @@ CloudClient.Util = (function(){ if(lCurrentFileWas) this.unSetCurrentFile(lCurrentFileWas); - pCurrentFile.className = CloudCommander.CURRENT_FILE; + var lSpaceChar = ''; + if(pCurrentFile.className) + lSpaceChar = ' '; + pCurrentFile.className += lSpaceChar + CloudCommander.CURRENT_FILE; /* scrolling to current file */ Util.scrollIntoViewIfNeeded(pCurrentFile); @@ -678,8 +681,14 @@ CloudClient.Util = (function(){ 'could not be none' }); var lRet_b = this.isCurrentFile(pCurrentFile); - if(lRet_b) - pCurrentFile.className = ''; + var lCurrentClass = CloudCommander.CURRENT_FILE; + var lCurrentFileClass = pCurrentFile.className; + if(lRet_b){ + if(lCurrentFileClass.length > lCurrentClass.length) + pCurrentFile.className = lCurrentFileClass.replace(lCurrentClass); + else + pCurrentFile.className = ''; + } return lRet_b; }; @@ -693,7 +702,10 @@ CloudClient.Util = (function(){ 'could not be none' }); - return (pCurrentFile.className === CloudCommander.CURRENT_FILE); + var lCurrentClass = CloudCommander.CURRENT_FILE; + var lCurrentFileClass = pCurrentFile.className; + + return ( lCurrentFileClass.indexOf(lCurrentClass) >= 0 ); }; this.getCurrentLink = function(pCurrentFile){ @@ -712,6 +724,22 @@ CloudClient.Util = (function(){ return lLink; }; + this.getCurrentName = function(pCurrentFile){ + var lCurrent = this.getCurrentFile(); + + var lLink; + lLink = this.getCurrentLink(pCurrentFile ? pCurrentFile : lCurrent); + + if(!lLink) + this.addCloudStatus({ + code : -1, + msg : 'Error current element do not contain links' + }); + else lLink = lLink.textContent; + + return lLink; + }; + /* function getting panel active, or passive * @pPanel_o = {active: true} */ @@ -754,6 +782,39 @@ CloudClient.Util = (function(){ lPanel.className = 'panel hidden'; }; + this.removeCurrent = function(pCurrent){ + var lParent = pCurrent.parentElement; + + if(!pCurrent) + pCurrent = this.getCurrentFile(); + var lName = this.getCurrentName(pCurrent); + + if(pCurrent && lParent){ + if(lName !== '..'){ + var lNext = pCurrent.nextSibling; + var lPrevious = pCurrent.previousSibling; + if(lNext) + Util.setCurrentFile(lNext); + else if(lPrevious) + Util.setCurrentFile(lPrevious); + + lParent.removeChild(pCurrent); + } + else + this.addCloudStatus({ + code : -1, + msg : 'Could not remove parrent dir' + }); + } + else + this.addCloudStatus({ + code : -1, + msg : 'Current file (or parent of current) could not be empty' + }); + + return pCurrent; + }; + this.scrollIntoViewIfNeeded = function(pElement){ var lOk = true; if(pElement && pElement.scrollIntoViewIfNeeded) diff --git a/index.html b/index.html index 6bc49df2..c6ad8d22 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,5 @@ - + diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 51aefd08..f5b90754 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -13,13 +13,15 @@ var CloudCommander; ENTER : 13, ESC : 27, - PAGE_UP : 33, + PAGE_UP : 33, PAGE_DOWN : 34, END : 35, HOME : 36, UP : 38, DOWN : 40, + Delete : 46, + D : 68, O : 79, @@ -107,6 +109,9 @@ var CloudCommander; else if(event.keyCode === lKEY.F2){ } + else if(event.keyCode === lKEY.Delete){ + Util.removeCurrent(lCurrentFile); + } /* if f3 or shift+f3 pressed */ else if(event.keyCode === lKEY.F3){