🎨 Chore: Format list.js
This commit is contained in:
parent
4527be0328
commit
d28ca728f9
1 changed files with 73 additions and 73 deletions
|
@ -6,16 +6,16 @@
|
||||||
|
|
||||||
// Call the function for each timestamp on page load
|
// Call the function for each timestamp on page load
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
const creationTimeElements = document.querySelectorAll('.creation-time');
|
const creationTimeElements = document.querySelectorAll(".creation-time");
|
||||||
const lastEditedTimeElements = document.querySelectorAll('.last-edited-time');
|
const lastEditedTimeElements = document.querySelectorAll(".last-edited-time");
|
||||||
|
|
||||||
creationTimeElements.forEach(element => {
|
creationTimeElements.forEach((element) => {
|
||||||
const unixTime = parseInt(element.getAttribute('data-unix'));
|
const unixTime = parseInt(element.getAttribute("data-unix"));
|
||||||
convertUnixTimeToLocalTime(unixTime, element);
|
convertUnixTimeToLocalTime(unixTime, element);
|
||||||
});
|
});
|
||||||
|
|
||||||
lastEditedTimeElements.forEach(element => {
|
lastEditedTimeElements.forEach((element) => {
|
||||||
const unixTime = parseInt(element.getAttribute('data-unix'));
|
const unixTime = parseInt(element.getAttribute("data-unix"));
|
||||||
convertUnixTimeToLocalTime(unixTime, element);
|
convertUnixTimeToLocalTime(unixTime, element);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
const checkAllButton = document.getElementById("checkAll");
|
const checkAllButton = document.getElementById("checkAll");
|
||||||
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
|
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
|
||||||
checkAllButton.addEventListener("click", function () {
|
checkAllButton.addEventListener("click", function () {
|
||||||
checkboxes.forEach(checkbox => {
|
checkboxes.forEach((checkbox) => {
|
||||||
checkbox.checked = true;
|
checkbox.checked = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -37,17 +37,17 @@
|
||||||
const filesToDelete = [];
|
const filesToDelete = [];
|
||||||
|
|
||||||
// Get the filenames of the selected files
|
// Get the filenames of the selected files
|
||||||
checkboxes.forEach(checkbox => {
|
checkboxes.forEach((checkbox) => {
|
||||||
if (checkbox.checked) {
|
if (checkbox.checked) {
|
||||||
filesToDelete.push(checkbox.value);
|
filesToDelete.push(checkbox.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log(filesToDelete);
|
||||||
|
|
||||||
// Call the deleteFiles function to send the request to the server
|
// Call the deleteFiles function to send the request to the server
|
||||||
deleteFiles(filesToDelete);
|
deleteFiles(filesToDelete);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function deleteFiles(filesToDelete) {
|
function deleteFiles(filesToDelete) {
|
||||||
// Send a POST request to the server to delete the selected files
|
// Send a POST request to the server to delete the selected files
|
||||||
fetch("/delete", {
|
fetch("/delete", {
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ files: filesToDelete }),
|
body: JSON.stringify({ files: filesToDelete }),
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then((response) => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
// Files deleted successfully
|
// Files deleted successfully
|
||||||
location.reload(); // Refresh the page to reflect the changes
|
location.reload(); // Refresh the page to reflect the changes
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
console.error("Error deleting files");
|
console.error("Error deleting files");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch((error) => {
|
||||||
console.error("Error deleting files:", error);
|
console.error("Error deleting files:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue