2022-09-04 08:26:20 +00:00
|
|
|
import { NAVIGATE_TO_URI, NEW_TAB_URI } from "./config";
|
|
|
|
|
|
|
|
export const setupEmergencyButton = () => {
|
|
|
|
const btn = <HTMLButtonElement>document.getElementById("emergency-button");
|
|
|
|
btn?.addEventListener("click", () => {
|
|
|
|
// The order of these statements below matter. If we replace the location before opening
|
|
|
|
// the other URL, the "window.open" line would have no effect.
|
|
|
|
window.open(NEW_TAB_URI, "_blank");
|
|
|
|
location.replace(NAVIGATE_TO_URI);
|
|
|
|
});
|
|
|
|
};
|
2022-10-01 10:34:36 +00:00
|
|
|
|
|
|
|
export const setupResetButton = () => {
|
|
|
|
const btn = <HTMLButtonElement>document.getElementById("reset-button");
|
|
|
|
btn?.addEventListener("click", () => {
|
|
|
|
window.location.reload();
|
|
|
|
});
|
2022-10-01 12:44:35 +00:00
|
|
|
};
|
2022-10-25 11:36:49 +00:00
|
|
|
|
2022-10-26 12:25:21 +00:00
|
|
|
export const setupHamburgerButton = () => {
|
|
|
|
let isOpen = false;
|
2022-10-25 11:36:49 +00:00
|
|
|
const header = <HTMLElement>document.getElementById("mobile-header");
|
2022-10-26 12:25:21 +00:00
|
|
|
const hamburger = <HTMLButtonElement>document.getElementById("hamburger-button")!;
|
|
|
|
|
|
|
|
document.querySelectorAll<HTMLButtonElement>(".js-header-button").forEach((btn) =>
|
|
|
|
btn.addEventListener("click", () => {
|
|
|
|
header.classList.toggle("max-md:hidden", isOpen);
|
|
|
|
hamburger.classList.toggle("hidden", !isOpen);
|
|
|
|
isOpen = !isOpen;
|
|
|
|
}),
|
|
|
|
);
|
2022-10-25 11:36:49 +00:00
|
|
|
};
|