Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
(function () {
|
|
document.querySelectorAll(".setting-switch").forEach(function (btn) {
|
|
btn.addEventListener("click", function () {
|
|
var on = btn.classList.toggle("setting-switch--on");
|
|
btn.setAttribute("aria-pressed", on ? "true" : "false");
|
|
});
|
|
});
|
|
|
|
var logoutBtn = document.querySelector("[data-auth-logout]");
|
|
if (logoutBtn) {
|
|
logoutBtn.addEventListener("click", function () {
|
|
function done() {
|
|
if (window.AuthAPI && typeof AuthAPI.markGuestLogout === "function") {
|
|
AuthAPI.markGuestLogout();
|
|
}
|
|
if (window.CookieUtil && typeof CookieUtil.clearAuth === "function") {
|
|
CookieUtil.clearAuth();
|
|
}
|
|
try {
|
|
document.dispatchEvent(new CustomEvent("auth:logout"));
|
|
} catch (e) {}
|
|
window.location.href = "/";
|
|
}
|
|
|
|
if (window.HttpRequest) {
|
|
HttpRequest.post("/api/auth/logout", {})
|
|
.catch(function () {})
|
|
.then(done);
|
|
} else {
|
|
done();
|
|
}
|
|
});
|
|
}
|
|
})();
|