mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(upload) add
This commit is contained in:
parent
c1e0d8bb1b
commit
b43c07c56a
5 changed files with 91 additions and 2 deletions
1
html/upload.html
Normal file
1
html/upload.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<input type="file" name="file" data-name="js-upload-file-button" multiple>
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
"config",
|
||||
"contact",
|
||||
"terminal",
|
||||
"upload",
|
||||
"konsole", [{
|
||||
"name": "remote",
|
||||
"data": [{
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ var Util, DOM, CloudCmd;
|
|||
Files = this,
|
||||
FILES_JSON = 'config|modules|ext|edit',
|
||||
FILES_HTML = 'file|path|link|pathLink|media',
|
||||
FILES_HTML_ROOT = 'view/media-tmpl|config-tmpl',
|
||||
FILES_HTML_ROOT = 'view/media-tmpl|config-tmpl|upload',
|
||||
funcs = [],
|
||||
Data = {},
|
||||
DIR_HTML = '/html/',
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO;
|
|||
'New' : {
|
||||
'File' : DOM.promptNewFile,
|
||||
'Directory' : DOM.promptNewDir,
|
||||
'From FilePicker' : getFromPicker
|
||||
'From FilePicker' : getFromPicker,
|
||||
},
|
||||
'(Un)Select All': DOM.toggleAllSelectedFiles
|
||||
};
|
||||
|
|
@ -144,6 +144,9 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO;
|
|||
'Delete' : DOM.promptDelete,
|
||||
'Pack' : getActiveFunc(DOM.pack),
|
||||
'Unpack' : getActiveFunc(DOM.unpack),
|
||||
'Upload' : function() {
|
||||
CloudCmd.Upload.show();
|
||||
},
|
||||
'Upload To' : {},
|
||||
'Download' : download,
|
||||
'Cut' : Buffer.cut,
|
||||
|
|
|
|||
84
lib/client/upload.js
Normal file
84
lib/client/upload.js
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
var CloudCmd, Util, DOM;
|
||||
|
||||
(function(CloudCmd, Util, DOM){
|
||||
'use strict';
|
||||
|
||||
CloudCmd.Upload = UploadProto;
|
||||
|
||||
function UploadProto() {
|
||||
var Images = DOM.Images,
|
||||
RESTful = DOM.RESTful,
|
||||
Files = DOM.Files,
|
||||
|
||||
Upload = this;
|
||||
|
||||
function init() {
|
||||
Images.showLoad({
|
||||
top: true
|
||||
});
|
||||
|
||||
Util.exec.series([
|
||||
CloudCmd.View,
|
||||
Upload.show
|
||||
]);
|
||||
}
|
||||
|
||||
this.show = function() {
|
||||
Images.showLoad({
|
||||
top: true
|
||||
});
|
||||
|
||||
Files.get('upload', function(error, data) {
|
||||
CloudCmd.View.show(data, {
|
||||
autoSize : true,
|
||||
afterShow : afterShow
|
||||
});
|
||||
});
|
||||
|
||||
DOM.load.style({
|
||||
id : 'js-upload',
|
||||
inner : '[data-name=js-upload-file-button] {' +
|
||||
'font-family: "Droid Sans Mono", "Ubuntu Mono", "Consolas", monospace;' +
|
||||
'font-size: 20px;' +
|
||||
'}'
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
this.hide = function() {
|
||||
CloudCmd.View.hide();
|
||||
};
|
||||
|
||||
function afterShow() {
|
||||
var button = DOM.getByDataName('js-upload-file-button');
|
||||
|
||||
Images.hide();
|
||||
|
||||
DOM.Events.add('change', button, uploadFiles);
|
||||
}
|
||||
|
||||
function uploadFiles(event) {
|
||||
var path,
|
||||
func = CloudCmd.refresh,
|
||||
dir = DOM.CurrentInfo.dirPath,
|
||||
files = event.target.files,
|
||||
n = files.length;
|
||||
|
||||
Upload.hide();
|
||||
|
||||
if (n)
|
||||
Util.forEach(files, function(file) {
|
||||
var name = file.name;
|
||||
path = dir + name;
|
||||
|
||||
Images.showLoad({top: true});
|
||||
Images.setProgress(0, name);
|
||||
|
||||
RESTful.write(path, file, func);
|
||||
});
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
})(CloudCmd, Util, DOM);
|
||||
Loading…
Add table
Add a link
Reference in a new issue