Funktion dropzone_toggle()
This commit is contained in:
parent
394a770a26
commit
37efdc7c81
26
script.js
26
script.js
|
@ -4,23 +4,19 @@ filetypes = ['image/png', 'image/jpeg', 'image/gif'];
|
|||
|
||||
dropzone.addEventListener('dragover', function(e) {
|
||||
e.preventDefault();
|
||||
this.classList.remove('inactive');
|
||||
this.classList.add('active');
|
||||
dropzone_toggle("on");
|
||||
});
|
||||
|
||||
dropzone.addEventListener('dragleave', function(e) {
|
||||
this.classList.remove('active');
|
||||
this.classList.add('inactive');
|
||||
dropzone_toggle("off");
|
||||
});
|
||||
|
||||
dropzone.addEventListener('mousedown', function(e) {
|
||||
this.classList.remove('inactive');
|
||||
this.classList.add('active');
|
||||
dropzone_toggle("on");
|
||||
});
|
||||
|
||||
dropzone.addEventListener('mouseup', function(e) {
|
||||
this.classList.remove('active');
|
||||
this.classList.add('inactive');
|
||||
dropzone_toggle("off");
|
||||
});
|
||||
|
||||
dropzone.addEventListener('click', function(e) {
|
||||
|
@ -38,9 +34,7 @@ dropzone.addEventListener('click', function(e) {
|
|||
|
||||
dropzone.addEventListener('drop', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
this.classList.remove('active');
|
||||
this.classList.add('inactive');
|
||||
dropzone_toggle("off");
|
||||
|
||||
file = e.dataTransfer.files[0];
|
||||
if(filetypes.includes(file.type)) {
|
||||
|
@ -48,6 +42,16 @@ dropzone.addEventListener('drop', function(e) {
|
|||
}
|
||||
});
|
||||
|
||||
function dropzone_toggle(state) {
|
||||
if(state == "on") {
|
||||
dropzone.classList.remove('inactive');
|
||||
dropzone.classList.add('active');
|
||||
} else if(state == "off") {
|
||||
dropzone.classList.remove('active');
|
||||
dropzone.classList.add('inactive');
|
||||
}
|
||||
}
|
||||
|
||||
function upload(file) {
|
||||
const data = new FormData();
|
||||
data.append('upload', file)
|
||||
|
|
Loading…
Reference in New Issue