diff --git a/index.html b/index.html index c38fd3f..ebb3fdd 100644 --- a/index.html +++ b/index.html @@ -1146,8 +1146,7 @@ if (lightboxItem && lightboxItem.skillId) params.set("skill", lightboxItem.skillId); if (lightboxIndustry.name) params.set("industry", lightboxIndustry.name); const target = "/generate" + (params.toString() ? "?" + params.toString() : ""); - const loggedIn = !!localStorage.getItem("access_token"); - window.location.href = loggedIn ? target : "/login/?redirect=" + encodeURIComponent(target); + goEntry(target); } function closeLightbox() { @@ -1366,6 +1365,34 @@ window.clearTimeout(resizeTimer); resizeTimer = window.setTimeout(measure, 120); }); + + function isLoggedIn() { + return !!localStorage.getItem("access_token"); + } + + function goEntry(target) { + const dest = target || "/generate"; + if (isLoggedIn()) { + window.location.href = dest; + return; + } + const params = new URLSearchParams({ v: "20261107", redirect: dest }); + window.location.href = "/login/?" + params.toString(); + } + + document.querySelectorAll("a.pill--login, a.pill--signup").forEach(function (link) { + link.addEventListener("click", function (event) { + event.preventDefault(); + goEntry("/generate"); + }); + }); + + document.querySelectorAll('a[href="/generate"]').forEach(function (link) { + link.addEventListener("click", function (event) { + event.preventDefault(); + goEntry(link.getAttribute("href") || "/generate"); + }); + }); })();