diff --git a/viz/app/item_page.js b/viz/app/item_page.js index e83fbf5..9574d0b 100644 --- a/viz/app/item_page.js +++ b/viz/app/item_page.js @@ -231,9 +231,11 @@ export async function renderItem($app, skuInput) { `; document.getElementById("back").addEventListener("click", () => { - location.hash = "#/"; + const last = sessionStorage.getItem("viz:lastRoute"); + if (last && last !== location.hash) location.hash = last; + else location.hash = "#/"; }); - + const $title = document.getElementById("title"); const $links = document.getElementById("links"); const $status = document.getElementById("status"); diff --git a/viz/app/search_page.js b/viz/app/search_page.js index 9dfecc9..1fd8e42 100644 --- a/viz/app/search_page.js +++ b/viz/app/search_page.js @@ -131,7 +131,7 @@ export function renderSearch($app) {
${esc(it.name || "(no name)")}
${esc(displaySku(it.sku))} + )}" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation()">${esc(displaySku(it.sku))}
${esc(price)} @@ -149,6 +149,7 @@ export function renderSearch($app) { const sku = el.getAttribute("data-sku") || ""; if (!sku) return; saveQuery($q.value); + sessionStorage.setItem("viz:lastRoute", location.hash); location.hash = `#/item/${encodeURIComponent(sku)}`; }); } @@ -419,7 +420,7 @@ export function renderSearch($app) {
${esc(r.name || "(no name)")}
${esc(displaySku(sku))} + )}" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation()">${esc(displaySku(sku))}
${esc(kindLabel)} @@ -440,6 +441,7 @@ export function renderSearch($app) { const sku = el.getAttribute("data-sku") || ""; if (!sku) return; saveQuery($q.value); + sessionStorage.setItem("viz:lastRoute", location.hash); location.hash = `#/item/${encodeURIComponent(sku)}`; }); } diff --git a/viz/app/store_page.js b/viz/app/store_page.js index 52a89db..c13abb8 100644 --- a/viz/app/store_page.js +++ b/viz/app/store_page.js @@ -69,7 +69,10 @@ export async function renderStore($app, storeLabelRaw) {
`; - document.getElementById("back").addEventListener("click", () => (location.hash = "#/")); + document.getElementById("back").addEventListener("click", () => { + sessionStorage.setItem("viz:lastRoute", location.hash); + location.hash = "#/" +}); const $q = document.getElementById("q"); const $status = document.getElementById("status"); @@ -230,7 +233,7 @@ export async function renderStore($app, storeLabelRaw) {
${esc(it.name || "(no name)")}
- ${esc( + ${esc( displaySku(it.sku) )}
@@ -294,6 +297,7 @@ export async function renderStore($app, storeLabelRaw) { if (!el) return; const sku = el.getAttribute("data-sku") || ""; if (!sku) return; + sessionStorage.setItem("viz:lastRoute", location.hash); location.hash = `#/item/${encodeURIComponent(sku)}`; }); diff --git a/viz/style.css b/viz/style.css index c03734e..51f5c65 100644 --- a/viz/style.css +++ b/viz/style.css @@ -245,12 +245,15 @@ a.skuLink:hover { text-decoration: underline; cursor: pointer; } margin-top: 12px; /* slightly more gap from the top text */ } -.storeBar { - display: flex; - gap: 8px; - flex-wrap: wrap; +.storeBar{ + display:flex; + gap:8px; + flex-wrap:wrap; + width:100%; + justify-content: space-between; /* spread each row to fill */ } + .storeBtn { border: 1px solid var(--border); background: #0f1318;