fixed some state-bugs

This commit is contained in:
Jack Case
2025-11-14 01:24:39 +00:00
parent e9169cbcf4
commit b7965bf71d
2 changed files with 12 additions and 11 deletions

View File

@@ -8,7 +8,7 @@
<title>Slop Farmer</title> <title>Slop Farmer</title>
</head> </head>
<body> <body>
<div id="signup" style="visibility: collapse;" <div id="signup" style="visibility: collapse;">
<form id="signup-form"> <form id="signup-form">
<label for="email">email</label> <label for="email">email</label>
<input type="email" name="email" required /> <input type="email" name="email" required />

View File

@@ -10,6 +10,7 @@ class PopupState {
this.logged_in = logged_in this.logged_in = logged_in
this.page_sections = page_sections this.page_sections = page_sections
this.visible_section = visible_section this.visible_section = visible_section
this.setVisibleSection(visible_section)
} }
setVisibleSection(section_id: string) { setVisibleSection(section_id: string) {
@@ -20,14 +21,6 @@ class PopupState {
} }
} }
if (localStorage.getItem("accessToken")) {
login_status.setAttribute("style", "visibility: visible;")
}
login_form.addEventListener("submit", (event) => { event.preventDefault(); submit_login_form() })
signup_form.addEventListener("submit", (event) => { event.preventDefault(); submit_signup_form() })
async function submit_login_form() { async function submit_login_form() {
const login_url = new URL("/login", API_URL) const login_url = new URL("/login", API_URL)
@@ -84,5 +77,13 @@ function initialize_popup() {
page_sections.set("login", login_section) page_sections.set("login", login_section)
page_sections.set("report", report_section) page_sections.set("report", report_section)
const popup_state = new PopupState(false, page_sections, "signup_section") const popup_state = new PopupState(false, page_sections, "signup")
}
login_form.addEventListener("submit", (event) => { event.preventDefault(); submit_login_form() })
signup_form.addEventListener("submit", (event) => { event.preventDefault(); submit_signup_form() })
}
addEventListener("DOMContentLoaded", (event) => {
initialize_popup()
})