Skip to content

Commit

Permalink
Merge pull request #1 from yigblst/patch-1
Browse files Browse the repository at this point in the history
Update widget.js
  • Loading branch information
OmerWow authored May 11, 2022
2 parents b7f6e30 + 882b70b commit a5e2afb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/widget.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
const dropArea = document.querySelector(".blst-drag-area"),
dragText = dropArea.querySelector(".blst-title"),
button = dropArea.querySelector(".blst-button"),
input = dropArea.querySelector(".blst-input");
let blstFile; //this is a global variable and we'll use it inside multiple functions

input.addEventListener("change", (event) => {
//getting user select file and [0] this means if user select multiple files then we'll select only the first one
blstFile = event.target.files[0];
dropArea.classList.add("active");
showFile();
});
//If user Drag File Over DropArea
dropArea.addEventListener("dragover", (event) => {
event.preventDefault();
dropArea.classList.add("active");
dragText.textContent = "Release to Upload File";
});
//If user leave dragged File from DropArea
dropArea.addEventListener("dragleave", () => {
dropArea.classList.remove("active");
dragText.textContent = "+ Drag & Drop";
});
//If user drop File on DropArea
dropArea.addEventListener("drop", (event) => {
event.preventDefault();
//getting user select file and [0] this means if user select multiple files then we'll select only the first one
blstFile = event.dataTransfer.files[0];
showFile();
});

export function showFile(domain) {
let fileType = blstFile.type;
let validExtensions = ["application/json"];
Expand Down

0 comments on commit a5e2afb

Please sign in to comment.