mirror of
https://github.com/C4illin/ConvertX.git
synced 2025-11-14 19:05:49 +00:00
@@ -1,8 +1,7 @@
|
|||||||
const webroot = document.querySelector("meta[name='webroot']").content;
|
const webroot = document.querySelector("meta[name='webroot']").content;
|
||||||
|
|
||||||
// Select the file input element
|
|
||||||
const fileInput = document.querySelector('input[type="file"]');
|
const fileInput = document.querySelector('input[type="file"]');
|
||||||
const dropZone = document.getElementById("dropzone");
|
const dropZone = document.getElementById("dropzone");
|
||||||
|
const convertButton = document.querySelector("input[type='submit']");
|
||||||
const fileNames = [];
|
const fileNames = [];
|
||||||
let fileType;
|
let fileType;
|
||||||
|
|
||||||
@@ -28,7 +27,6 @@ const updateSearchBar = () => {
|
|||||||
const convertToGroupElements = document.querySelectorAll(".convert_to_group");
|
const convertToGroupElements = document.querySelectorAll(".convert_to_group");
|
||||||
const convertToGroups = {};
|
const convertToGroups = {};
|
||||||
const convertToElement = document.querySelector("select[name='convert_to']");
|
const convertToElement = document.querySelector("select[name='convert_to']");
|
||||||
const convertButton = document.querySelector("input[type='submit']");
|
|
||||||
|
|
||||||
const showMatching = (search) => {
|
const showMatching = (search) => {
|
||||||
for (const [targets, groupElement] of Object.values(convertToGroups)) {
|
for (const [targets, groupElement] of Object.values(convertToGroups)) {
|
||||||
@@ -100,11 +98,8 @@ const updateSearchBar = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// const convertFromSelect = document.querySelector("select[name='convert_from']");
|
|
||||||
|
|
||||||
// Add a 'change' event listener to the file input element
|
// Add a 'change' event listener to the file input element
|
||||||
fileInput.addEventListener("change", (e) => {
|
fileInput.addEventListener("change", (e) => {
|
||||||
// console.log(e.target.files);
|
|
||||||
// Get the selected files from the event target
|
// Get the selected files from the event target
|
||||||
const files = e.target.files;
|
const files = e.target.files;
|
||||||
|
|
||||||
@@ -197,6 +192,9 @@ const deleteRow = (target) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const uploadFiles = (files) => {
|
const uploadFiles = (files) => {
|
||||||
|
convertButton.disabled = true;
|
||||||
|
convertButton.textContent = "Uploading...";
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
@@ -209,6 +207,8 @@ const uploadFiles = (files) => {
|
|||||||
})
|
})
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
convertButton.disabled = false;
|
||||||
|
convertButton.textContent = "Convert";
|
||||||
console.log(data);
|
console.log(data);
|
||||||
})
|
})
|
||||||
.catch((err) => console.log(err));
|
.catch((err) => console.log(err));
|
||||||
|
|||||||
Reference in New Issue
Block a user