mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
added ability to remove files
This commit is contained in:
parent
5d40f47165
commit
601f7507bd
4 changed files with 74 additions and 6 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
69
client.js
69
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)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html manifest=cloudcmd.appcache>
|
||||
<html manifest=/cloudcmd.appcache>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<!-- mobile first design -->
|
||||
|
|
|
|||
|
|
@ -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){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue