feature(upload) add

This commit is contained in:
coderaiser 2014-09-30 10:48:22 -04:00
parent c1e0d8bb1b
commit b43c07c56a
5 changed files with 91 additions and 2 deletions

1
html/upload.html Normal file
View file

@ -0,0 +1 @@
<input type="file" name="file" data-name="js-upload-file-button" multiple>

View file

@ -7,6 +7,7 @@
"config",
"contact",
"terminal",
"upload",
"konsole", [{
"name": "remote",
"data": [{

View file

@ -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/',

View file

@ -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
View 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);