|
@@ -21,8 +21,8 @@ window.onload = function () {
|
|
|
|
|
|
if(!localStorage.token){
|
|
|
document.getElementById('tokenContainer').style.display = 'flex'
|
|
|
- document.getElementById("tokenSubmit").addEventListener("click", function(){
|
|
|
- getInfo(document.getElementById("token").value)
|
|
|
+ document.getElementById('tokenSubmit').addEventListener('click', function(){
|
|
|
+ getInfo(document.getElementById('token').value)
|
|
|
});
|
|
|
}else{
|
|
|
getInfo(localStorage.token);
|
|
@@ -32,8 +32,8 @@ window.onload = function () {
|
|
|
|
|
|
function prepareDropzone(){
|
|
|
|
|
|
- var previewNode = document.querySelector("#template");
|
|
|
- previewNode.id = "";
|
|
|
+ var previewNode = document.querySelector('#template');
|
|
|
+ previewNode.id = '';
|
|
|
var previewTemplate = previewNode.parentNode.innerHTML;
|
|
|
previewNode.parentNode.removeChild(previewNode);
|
|
|
|
|
@@ -52,26 +52,36 @@ window.onload = function () {
|
|
|
'auth': localStorage.token
|
|
|
},
|
|
|
init: function() {
|
|
|
- this.on("addedfile", function(file) {
|
|
|
+ this.on('addedfile', function(file) {
|
|
|
document.getElementById('uploads').style.display = 'block';
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// Update the total progress bar
|
|
|
- dropzone.on("uploadprogress", function(file, progress) {
|
|
|
- file.previewElement.querySelector(".progress").style.width = progress + "%";
|
|
|
+ dropzone.on('uploadprogress', function(file, progress) {
|
|
|
+ file.previewElement.querySelector('.progress').style.width = progress + '%';
|
|
|
});
|
|
|
|
|
|
- dropzone.on("success", function(file, response) {
|
|
|
+ dropzone.on('success', function(file, response) {
|
|
|
+
|
|
|
// Handle the responseText here. For example, add the text to the preview element:
|
|
|
+
|
|
|
+ if(response.success === false){
|
|
|
+ var span = document.createElement('span');
|
|
|
+ span.innerHTML = response.description;
|
|
|
+ file.previewTemplate.querySelector('.link').appendChild(span);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
a = document.createElement('a');
|
|
|
- a.href = response.url;
|
|
|
+ a.href = response.files[0].url;
|
|
|
a.target = '_blank';
|
|
|
- a.innerHTML = response.url;
|
|
|
-
|
|
|
- file.previewTemplate.querySelector(".progress").style.display = 'none';
|
|
|
- file.previewTemplate.querySelector(".link").appendChild(a);
|
|
|
+ a.innerHTML = response.files[0].url;
|
|
|
+ file.previewTemplate.querySelector('.link').appendChild(a);
|
|
|
+
|
|
|
+ file.previewTemplate.querySelector('.progress').style.display = 'none';
|
|
|
+
|
|
|
});
|
|
|
|
|
|
}
|