refactored the js

This commit is contained in:
David Kennedy 2025-03-04 14:16:48 -05:00
parent a4e2292798
commit d9cd4aeb4d
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
2 changed files with 4 additions and 15 deletions

View file

@ -458,10 +458,12 @@ export class NameserverForm {
* This ensures that only the latest alert is displayed to the user.
*/
resetAlerts() {
const mainContent = document.querySelector("main#main-content");
const mainContent = document.getElementById("main-content");
if (mainContent) {
// Remove all alert elements within the main content area
mainContent.querySelectorAll(".usa-alert").forEach(alert => alert.remove());
} else {
console.warn("Expecting main-content DOM element");
}
}
@ -474,7 +476,7 @@ export class NameserverForm {
addAlert(level, message) {
this.resetAlerts(); // Remove any existing alerts before adding a new one
const mainContent = document.querySelector("main#main-content");
const mainContent = document.getElementById("main-content");
if (!mainContent) return;
// Create a new alert div with appropriate classes based on alert level

View file

@ -84,19 +84,6 @@ export function getCsrfToken() {
return document.querySelector('input[name="csrfmiddlewaretoken"]').value;
}
/**
* Helper function to submit a form
* @param {} form_id - the id of the form to be submitted
*/
export function submitForm(form_id) {
let form = document.getElementById(form_id);
if (form) {
form.submit();
} else {
console.error("Form '" + form_id + "' not found.");
}
}
/**
* Helper function to strip HTML tags
* THIS IS NOT SUITABLE FOR SANITIZING DANGEROUS STRINGS