Skip to content

Commit

Permalink
add user feedback while uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
Haldenwat committed Dec 16, 2018
1 parent 4330e8f commit fec446e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions resources/views/files/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,19 @@ function verifyCbx() {
mdeditor.codemirror.on("paste", function (data, e) {
console.log("paste");
getFileTransferData(data, e);
});
mdeditor.codemirror.on("drop", function(data, e){
console.log("drop");
getFileTransferData(data, e);
mdeditor.codemirror.replaceRange(' **Uploading image...** ', {line: Infinity});
});
let urlGetImgurURL = "{{route("uploadImage")}}";
function getFileTransferData(data, e){
let files = e.dataTransfer.files;
if(files.length > 0){
let file = files[0];
console.log(file);
fetch(urlGetImgurURL, {
method: 'POST',
headers: {
Expand All @@ -144,6 +142,7 @@ function getFileTransferData(data, e){
let jsonData = response.json();
jsonData.then( jsonData => {
console.log(jsonData.link);
mdeditor.codemirror.undo();
mdeditor.codemirror.replaceRange(' ![](' + jsonData.link + ') ', {line: Infinity});
})
})
Expand Down

0 comments on commit fec446e

Please sign in to comment.