From 1e3ec14e92d6bd73fb62580fbeb86e44269dfb1a Mon Sep 17 00:00:00 2001 From: Henrique Dias <hacdias@gmail.com> Date: Thu, 23 Jun 2016 08:26:44 +0100 Subject: [PATCH] add travis [ciskip] --- README.md | 1 + assets/public/js/application.js | 57 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/README.md b/README.md index c363f776..8ec04f55 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # filemanager - a caddy plugin +[](https://travis-ci.org/hacdias/caddy-filemanager) [](https://forum.caddyserver.com) [](http://godoc.org/github.com/hacdias/caddy-filemanager) diff --git a/assets/public/js/application.js b/assets/public/js/application.js index 9a556aca..d6a72e76 100644 --- a/assets/public/js/application.js +++ b/assets/public/js/application.js @@ -264,7 +264,64 @@ var uploadEvent = function (event) { let button = document.getElementById("upload-input"); button.click(); + button.addEventListener("change", (event) => { + event.preventDefault(); + let html = button.changeToLoading(); + let files = event.target.files; + + let data = new FormData(); + + /* + event.preventDefault(); + files = event.target.files; + + $('#loading').fadeIn(); + + // Create a formdata object and add the files + var data = new FormData(); + $.each(files, function(key, value) { + data.append(key, value); + }); + + $.ajax({ + url: window.location.pathname, + type: 'POST', + data: data, + cache: false, + dataType: 'json', + headers: { + 'X-Upload': 'true', + }, + processData: false, + contentType: false, + }).done(function(data) { + notification({ + text: "File(s) uploaded successfully.", + type: 'success', + timeout: 5000 + }); + + $('#loading').fadeOut(); + + $.pjax({ + url: window.location.pathname, + container: '#content' + }) + }).fail(function(data) { + $('#loading').fadeOut(); + + notification({ + text: 'Something went wrong.', + type: 'error' + }); + console.log(data); + }); + + + return false; + */ + }); return false; }