49 lines
2.7 KiB
HTML
49 lines
2.7 KiB
HTML
|
|
<!doctype html>
|
||
|
|
<html><head><meta charset="utf-8">
|
||
|
|
<style>
|
||
|
|
:root { color-scheme: light dark; font-family: system-ui, sans-serif; }
|
||
|
|
html, body { margin: 0; background: transparent; }
|
||
|
|
.menu { background: #1c222c; border: 1px solid #ffffff26; border-radius: 10px; box-shadow: 0 12px 34px #000c; overflow: hidden; color: #e7eaf1; }
|
||
|
|
.item { display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #ffffff08; }
|
||
|
|
.item:last-child { border-bottom: 0; }
|
||
|
|
.item:hover, .item.on { background: #ffffff12; }
|
||
|
|
.item .ic { flex: none; font-size: 12px; color: #7f8aa0; width: 14px; text-align: center; }
|
||
|
|
.item .txt { flex: 1; overflow: hidden; }
|
||
|
|
.item .url { color: #e7eaf1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
|
||
|
|
.item .ttl { color: #7f8aa0; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||
|
|
.empty { padding: 14px; color: #7f8aa0; font-size: 12.5px; text-align: center; }
|
||
|
|
@media (prefers-color-scheme: light) {
|
||
|
|
.menu { background: #ffffff; border-color: rgba(0,0,0,.15); color: #1a1f28; }
|
||
|
|
.item:hover, .item.on { background: rgba(0,0,0,.05); }
|
||
|
|
.item { border-bottom-color: rgba(0,0,0,.06); }
|
||
|
|
.item .url { color: #1a1f28; }
|
||
|
|
.item .ttl, .item .ic, .empty { color: #7b8494; }
|
||
|
|
}
|
||
|
|
</style></head>
|
||
|
|
<body>
|
||
|
|
<div class="menu"><div id="list"></div></div>
|
||
|
|
<script>
|
||
|
|
const $ = (id) => document.getElementById(id);
|
||
|
|
const esc = (s) => String(s || "").replace(/</g, "<").replace(/"/g, """);
|
||
|
|
let items = []; let cursor = -1;
|
||
|
|
function report() { requestAnimationFrame(() => { try { window.picker.resize(document.querySelector(".menu").offsetHeight); } catch (e) {} }); }
|
||
|
|
function paint() {
|
||
|
|
const list = $("list");
|
||
|
|
if (!items.length) { list.innerHTML = `<div class="empty">No history yet.</div>`; report(); return; }
|
||
|
|
list.innerHTML = items.map((h, i) =>
|
||
|
|
`<div class="item ${i === cursor ? "on" : ""}" data-url="${esc(h.url)}"><span class="ic">🕘</span><span class="txt"><div class="url">${esc(h.url)}</div>${h.title ? `<div class="ttl">${esc(h.title)}</div>` : ""}</span></div>`
|
||
|
|
).join("");
|
||
|
|
list.querySelectorAll(".item").forEach((el) => el.onclick = () => window.picker.pick(el.dataset.url));
|
||
|
|
report();
|
||
|
|
}
|
||
|
|
window.picker.onSuggestions((data) => { items = data.suggestions || []; cursor = -1; paint(); });
|
||
|
|
window.picker.onCursor((dir) => {
|
||
|
|
if (!items.length) return;
|
||
|
|
if (dir === "next") cursor = (cursor + 1) % items.length;
|
||
|
|
else if (dir === "prev") cursor = (cursor - 1 + items.length) % items.length;
|
||
|
|
else if (dir === "enter") { if (cursor >= 0) window.picker.pick(items[cursor].url); return; }
|
||
|
|
paint();
|
||
|
|
});
|
||
|
|
</script>
|
||
|
|
</body></html>
|