Files
vector-search-demo/oravector-demo/frontend/indb/index.html
T
dierk 26ce44e186 Add lightbox to all three frontends — click photo to view full size
Click any result image to open it in a dark overlay. Click anywhere or
press Escape to close. Score colour matches each frontend's accent colour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-19 15:15:52 +02:00

233 lines
6.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vector Image Search — Oracle In-DB</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: #f5f5f5; color: #222; }
header {
background: #7b5ea7;
color: white;
padding: 1.2rem 2rem;
display: flex;
align-items: center;
gap: 1rem;
}
header h1 { font-size: 1.4rem; font-weight: 600; }
.badge {
background: white;
color: #7b5ea7;
font-size: 0.75rem;
font-weight: 700;
padding: 0.2rem 0.6rem;
border-radius: 999px;
}
.search-area {
max-width: 700px;
margin: 2rem auto 1rem;
padding: 0 1rem;
}
.search-row {
display: flex;
gap: 0.5rem;
}
input[type="text"] {
flex: 1;
padding: 0.7rem 1rem;
font-size: 1rem;
border: 1px solid #ccc;
border-radius: 6px;
}
button.search-btn {
padding: 0.7rem 1.4rem;
background: #7b5ea7;
color: white;
border: none;
border-radius: 6px;
font-size: 1rem;
cursor: pointer;
}
button.search-btn:hover { background: #664e8d; }
.chips {
display: flex;
flex-wrap: wrap;
gap: 0.4rem;
margin-top: 0.8rem;
}
.chip {
padding: 0.3rem 0.8rem;
background: white;
border: 1px solid #ccc;
border-radius: 999px;
font-size: 0.85rem;
cursor: pointer;
}
.chip:hover { background: #f3f0f8; border-color: #7b5ea7; }
.stats { text-align: center; color: #666; font-size: 0.85rem; margin-bottom: 1rem; }
.grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
gap: 1rem;
max-width: 1200px;
margin: 0 auto;
padding: 0 1rem 2rem;
}
.card {
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.card img {
width: 100%;
height: 140px;
object-fit: cover;
display: block;
}
.card-info {
padding: 0.5rem 0.7rem;
font-size: 0.8rem;
}
.card-info .score {
font-weight: 700;
color: #7b5ea7;
}
.card-info .name {
color: #555;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.empty { text-align: center; color: #999; margin-top: 3rem; font-size: 1rem; }
.card img { cursor: pointer; }
.card img:hover { opacity: 0.85; }
.lightbox {
display: none;
position: fixed;
inset: 0;
background: rgba(0,0,0,0.85);
z-index: 100;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 0.8rem;
}
.lightbox.open { display: flex; }
.lightbox img {
max-width: 90vw;
max-height: 80vh;
object-fit: contain;
border-radius: 4px;
box-shadow: 0 4px 32px rgba(0,0,0,0.6);
}
.lightbox-info { color: white; font-size: 0.95rem; text-align: center; }
.lightbox-info .lb-score { color: #cba6f7; font-weight: 700; }
.lightbox-close {
position: fixed;
top: 1rem; right: 1.2rem;
color: white; font-size: 2rem;
cursor: pointer; line-height: 1;
}
</style>
</head>
<body>
<header>
<h1>Vector Image Search</h1>
<span class="badge">Oracle In-DB</span>
</header>
<div class="search-area">
<div class="search-row">
<input id="query" type="text" placeholder="Search photos, e.g. trees, water, night…" />
<button class="search-btn" onclick="doSearch()">Search</button>
</div>
<div class="chips">
<span class="chip" onclick="setQuery('trees')">trees</span>
<span class="chip" onclick="setQuery('water')">water</span>
<span class="chip" onclick="setQuery('people')">people</span>
<span class="chip" onclick="setQuery('buildings')">buildings</span>
<span class="chip" onclick="setQuery('sky')">sky</span>
<span class="chip" onclick="setQuery('street')">street</span>
<span class="chip" onclick="setQuery('night')">night</span>
<span class="chip" onclick="setQuery('cars')">cars</span>
</div>
</div>
<p class="stats" id="stats"></p>
<div class="grid" id="grid"><p class="empty">Enter a search term above.</p></div>
<div class="lightbox" id="lightbox" onclick="closeLightbox()">
<span class="lightbox-close" onclick="closeLightbox()"></span>
<img id="lb-img" src="" alt="" />
<div class="lightbox-info">
<span id="lb-name"></span> &nbsp;·&nbsp; <span class="lb-score" id="lb-score"></span>
</div>
</div>
<script>
const API = "http://localhost:8002";
fetch(`${API}/stats`)
.then(r => r.json())
.then(d => document.getElementById("stats").textContent = `${d.count} photos indexed`);
document.getElementById("query").addEventListener("keydown", e => {
if (e.key === "Enter") doSearch();
});
function setQuery(text) {
document.getElementById("query").value = text;
doSearch();
}
function doSearch() {
const q = document.getElementById("query").value.trim();
if (!q) return;
fetch(`${API}/search?q=${encodeURIComponent(q)}&limit=12`)
.then(r => r.json())
.then(renderResults);
}
function renderResults(results) {
const grid = document.getElementById("grid");
if (!results.length) {
grid.innerHTML = '<p class="empty">No results found.</p>';
return;
}
grid.innerHTML = results.map(r => `
<div class="card">
<img src="${API}/photos/${encodeURIComponent(r.filename)}" alt="${r.filename}" loading="lazy"
onclick="openLightbox('${encodeURIComponent(r.filename)}','${r.filename}','${(r.score*100).toFixed(1)}%')" />
<div class="card-info">
<div class="score">${(r.score * 100).toFixed(1)}% match</div>
<div class="name">${r.filename}</div>
</div>
</div>
`).join("");
}
function openLightbox(encoded, name, score) {
document.getElementById("lb-img").src = `${API}/photos/${encoded}`;
document.getElementById("lb-name").textContent = name;
document.getElementById("lb-score").textContent = score + " match";
document.getElementById("lightbox").classList.add("open");
}
function closeLightbox() {
document.getElementById("lightbox").classList.remove("open");
}
document.addEventListener("keydown", e => { if (e.key === "Escape") closeLightbox(); });
</script>
</body>
</html>