diff --git a/html/upload.html b/html/upload.html
new file mode 100644
index 00000000..651694dd
--- /dev/null
+++ b/html/upload.html
@@ -0,0 +1 @@
+
diff --git a/json/modules.json b/json/modules.json
index f077b40b..1234e068 100644
--- a/json/modules.json
+++ b/json/modules.json
@@ -7,6 +7,7 @@
"config",
"contact",
"terminal",
+ "upload",
"konsole", [{
"name": "remote",
"data": [{
diff --git a/lib/client/files.js b/lib/client/files.js
index c65e6fa3..efeec932 100644
--- a/lib/client/files.js
+++ b/lib/client/files.js
@@ -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/',
diff --git a/lib/client/menu.js b/lib/client/menu.js
index b93eb7b8..743d27f8 100644
--- a/lib/client/menu.js
+++ b/lib/client/menu.js
@@ -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,
diff --git a/lib/client/upload.js b/lib/client/upload.js
new file mode 100644
index 00000000..0e864b7c
--- /dev/null
+++ b/lib/client/upload.js
@@ -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);