mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 02:29:23 +00:00
feature(cloudcmd) disallow to view and edit ".." directory
This commit is contained in:
parent
68c663b3b2
commit
f19c28f69e
5 changed files with 38 additions and 22 deletions
|
|
@ -29,11 +29,10 @@
|
|||
};
|
||||
|
||||
function getNames() {
|
||||
var name = Info.name,
|
||||
names = DOM.getSelectedNames(),
|
||||
n = names.length;
|
||||
var files = DOM.getActiveFiles(),
|
||||
names = DOM.getSelectedNames(files);
|
||||
|
||||
return n ? names : [name];
|
||||
return names;
|
||||
}
|
||||
|
||||
function addCutClass() {
|
||||
|
|
@ -130,13 +129,13 @@
|
|||
data = json.parse(opData);
|
||||
data.to = path;
|
||||
|
||||
if (data.from === path)
|
||||
if (data.from === path) {
|
||||
Dialog.alert(msg);
|
||||
else
|
||||
} else {
|
||||
Operation.show(opStr, data);
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
clear();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,15 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
DOMProto,
|
||||
|
||||
DialogProto = function() {
|
||||
this.alert = alert.bind(window);
|
||||
this.prompt = prompt.bind(window);
|
||||
this.confirm = confirm.bind(window);
|
||||
var self = this;
|
||||
|
||||
this.alert = alert.bind(window);
|
||||
this.prompt = prompt.bind(window);
|
||||
this.confirm = confirm.bind(window);
|
||||
|
||||
this.alert.noFiles = function() {
|
||||
self.alert('No files selected!');
|
||||
};
|
||||
},
|
||||
|
||||
ImagesProto = function() {
|
||||
|
|
@ -475,7 +481,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
Util.check(arguments, ['operation']);
|
||||
|
||||
if (!names.length) {
|
||||
Dialog.alert('No files selected!');
|
||||
Dialog.alert.noFiles();
|
||||
} else {
|
||||
switch(operation) {
|
||||
case 'extract':
|
||||
|
|
@ -755,6 +761,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
this.getCurrentData = function(callback, currentFile) {
|
||||
var hash,
|
||||
RESTful = DOM.RESTful,
|
||||
Info = DOM.CurrentInfo,
|
||||
current = currentFile || DOM.getCurrentFile(),
|
||||
path = DOM.getCurrentPath(current),
|
||||
isDir = DOM.isCurrentIsDir(current),
|
||||
|
|
@ -773,7 +780,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
Util.exec(callback, null, data);
|
||||
};
|
||||
|
||||
if (isDir)
|
||||
if (Info.name === '..')
|
||||
callback('No files selected!');
|
||||
else if (isDir)
|
||||
RESTful.read(path, func);
|
||||
else
|
||||
DOM.checkStorageHash(path, function(error, equal, hashNew) {
|
||||
|
|
@ -1437,7 +1446,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
|
|||
from = Cmd.getCurrentName(current);
|
||||
|
||||
if (from === '..') {
|
||||
Dialog.alert('No files selected!');
|
||||
Dialog.alert.noFiles();
|
||||
} else {
|
||||
to = Dialog.prompt('Rename', from) || from;
|
||||
isExist = !!DOM.getCurrentByName(to);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward;
|
|||
Edit = this,
|
||||
|
||||
Menu,
|
||||
|
||||
Dialog = DOM.Dialog,
|
||||
Editor = 'edward',
|
||||
|
||||
Images = DOM.Images,
|
||||
|
|
@ -82,7 +82,8 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward;
|
|||
name += '.json';
|
||||
|
||||
if (error) {
|
||||
alert(error);
|
||||
Images.hide();
|
||||
Dialog.alert(error);
|
||||
} else {
|
||||
edward.setValueFirst(path, data);
|
||||
|
||||
|
|
@ -126,7 +127,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward;
|
|||
function getConfig(callback) {
|
||||
DOM.Files.get('config', function(error, config) {
|
||||
if (error)
|
||||
alert(error);
|
||||
Dialog.alert(error);
|
||||
else if (config.editor)
|
||||
Editor = config.editor;
|
||||
|
||||
|
|
@ -196,7 +197,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward;
|
|||
};
|
||||
|
||||
if (error) {
|
||||
alert(error);
|
||||
Dialog.alert(error);
|
||||
} else if (!Menu && MenuIO) {
|
||||
Menu = new MenuIO(Element, options, menuData);
|
||||
Menu.show(position.x, position.y);
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@
|
|||
if (name !== '..')
|
||||
ret = Dialog.confirm(msg);
|
||||
else
|
||||
Dialog.alert('No files selected!');
|
||||
Dialog.alert.noFiles();
|
||||
|
||||
if (ret)
|
||||
deleteSilent(files);
|
||||
|
|
@ -294,7 +294,7 @@
|
|||
sameName = !!DOM.getCurrentByName(name, panel);
|
||||
|
||||
if (name === '..') {
|
||||
Dialog.alert('No files selected!');
|
||||
Dialog.alert.noFiles();
|
||||
} else {
|
||||
if (shouldAsk)
|
||||
to = message(to, names);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
var Name = 'View',
|
||||
Loading = false,
|
||||
Events = DOM.Events,
|
||||
Dialog = DOM.Dialog,
|
||||
Info = DOM.CurrentInfo,
|
||||
Key = CloudCmd.Key,
|
||||
Images = DOM.Images,
|
||||
|
|
@ -129,12 +130,18 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
switch(type) {
|
||||
default:
|
||||
Info.getData(function(error, data) {
|
||||
var element = document.createTextNode(data);
|
||||
var element;
|
||||
if (error) {
|
||||
Images.hide();
|
||||
Dialog.alert(error);
|
||||
} else {
|
||||
element = document.createTextNode(data);
|
||||
/* add margin only for view text documents */
|
||||
Element.css('margin', '2%');
|
||||
|
||||
$.fancybox(Element.append(element), Config);
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue