Skip to content

Commit

Permalink
Fix js errors on file list page
Browse files Browse the repository at this point in the history
  • Loading branch information
balazs-endresz committed Oct 3, 2024
1 parent 3fdca87 commit 6304a7a
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions rosetta/static/admin/rosetta/js/rosetta.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ document.addEventListener("DOMContentLoaded", () => {
});

// Toggle fuzzy state for all entries on the current page
document.getElementById("action-toggle").addEventListener("change", function () {
document.getElementById("action-toggle")?.addEventListener("change", function () {
const checkboxes = document.querySelectorAll('tbody td.c input[type="checkbox"]');
checkboxes.forEach((checkbox) => (checkbox.checked = this.checked));
});
Expand All @@ -224,13 +224,15 @@ document.addEventListener("DOMContentLoaded", () => {
new FormData(form).forEach((value, key) => (obj[key] = value));
return JSON.stringify(obj);
}
const initialDataJson = formToJsonString();
let isSubmitting = false;
form.addEventListener("submit", () => (isSubmitting = true));
window.addEventListener("beforeunload", (event) => {
if (!isSubmitting && initialDataJson !== formToJsonString()) {
event.preventDefault();
event.returnValue = "";
}
});
if (form) {
const initialDataJson = formToJsonString();
let isSubmitting = false;
form.addEventListener("submit", () => (isSubmitting = true));
window.addEventListener("beforeunload", (event) => {
if (!isSubmitting && initialDataJson !== formToJsonString()) {
event.preventDefault();
event.returnValue = "";
}
});
}
});

0 comments on commit 6304a7a

Please sign in to comment.