|
|
<!DOCTYPE html> |
|
|
<html lang="en"> |
|
|
<head> |
|
|
<meta charset="UTF-8"> |
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|
|
<title>Genomic Sequence Search</title> |
|
|
<link rel="preconnect" href="https://fonts.googleapis.com"> |
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> |
|
|
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@300;400;500;600;700&display=swap" rel="stylesheet"> |
|
|
<style> |
|
|
:root { |
|
|
--bg-primary: #0a0a0b; |
|
|
--bg-secondary: #111113; |
|
|
--bg-tertiary: #18181b; |
|
|
--bg-hover: #1f1f23; |
|
|
--border: #27272a; |
|
|
--border-focus: #3f3f46; |
|
|
--text-primary: #fafafa; |
|
|
--text-secondary: #a1a1aa; |
|
|
--text-muted: #71717a; |
|
|
--accent: #10b981; |
|
|
--accent-dim: #059669; |
|
|
--accent-glow: rgba(16, 185, 129, 0.15); |
|
|
--dna-a: #22d3ee; |
|
|
--dna-t: #f472b6; |
|
|
--dna-c: #a78bfa; |
|
|
--dna-g: #fbbf24; |
|
|
--success: #4ade80; |
|
|
--error: #f87171; |
|
|
--gradient-1: linear-gradient(135deg, #10b981 0%, #22d3ee 100%); |
|
|
--radius-sm: 6px; |
|
|
--radius-md: 10px; |
|
|
--radius-lg: 16px; |
|
|
} |
|
|
|
|
|
* { |
|
|
margin: 0; |
|
|
padding: 0; |
|
|
box-sizing: border-box; |
|
|
} |
|
|
|
|
|
body { |
|
|
font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif; |
|
|
background: var(--bg-primary); |
|
|
color: var(--text-primary); |
|
|
min-height: 100vh; |
|
|
line-height: 1.6; |
|
|
} |
|
|
|
|
|
body::before { |
|
|
content: ''; |
|
|
position: fixed; |
|
|
top: 0; |
|
|
left: 0; |
|
|
right: 0; |
|
|
bottom: 0; |
|
|
background-image: |
|
|
linear-gradient(rgba(16, 185, 129, 0.03) 1px, transparent 1px), |
|
|
linear-gradient(90deg, rgba(16, 185, 129, 0.03) 1px, transparent 1px); |
|
|
background-size: 40px 40px; |
|
|
pointer-events: none; |
|
|
z-index: 0; |
|
|
} |
|
|
|
|
|
.container { |
|
|
max-width: 1000px; |
|
|
margin: 0 auto; |
|
|
padding: 2rem; |
|
|
position: relative; |
|
|
z-index: 1; |
|
|
} |
|
|
|
|
|
header { |
|
|
text-align: center; |
|
|
padding: 2rem 0 1.5rem; |
|
|
} |
|
|
|
|
|
.logo { |
|
|
display: inline-flex; |
|
|
align-items: center; |
|
|
gap: 0.75rem; |
|
|
margin-bottom: 0.75rem; |
|
|
} |
|
|
|
|
|
.logo-icon { |
|
|
width: 52px; |
|
|
height: 52px; |
|
|
background: var(--gradient-1); |
|
|
border-radius: var(--radius-md); |
|
|
display: flex; |
|
|
align-items: center; |
|
|
justify-content: center; |
|
|
font-size: 1.75rem; |
|
|
} |
|
|
|
|
|
h1 { |
|
|
font-size: 2.25rem; |
|
|
font-weight: 600; |
|
|
letter-spacing: -0.03em; |
|
|
background: var(--gradient-1); |
|
|
-webkit-background-clip: text; |
|
|
-webkit-text-fill-color: transparent; |
|
|
background-clip: text; |
|
|
} |
|
|
|
|
|
.subtitle { |
|
|
color: var(--text-secondary); |
|
|
font-size: 1rem; |
|
|
font-weight: 300; |
|
|
margin-top: 0.25rem; |
|
|
} |
|
|
|
|
|
.stats-bar { |
|
|
display: flex; |
|
|
justify-content: center; |
|
|
gap: 2.5rem; |
|
|
padding: 1rem 0; |
|
|
margin-bottom: 1.5rem; |
|
|
border-bottom: 1px solid var(--border); |
|
|
} |
|
|
|
|
|
.stat { |
|
|
text-align: center; |
|
|
} |
|
|
|
|
|
.stat-value { |
|
|
font-family: 'JetBrains Mono', monospace; |
|
|
font-size: 1.25rem; |
|
|
font-weight: 500; |
|
|
color: var(--accent); |
|
|
} |
|
|
|
|
|
.stat-label { |
|
|
font-size: 0.7rem; |
|
|
color: var(--text-muted); |
|
|
text-transform: uppercase; |
|
|
letter-spacing: 0.08em; |
|
|
margin-top: 0.2rem; |
|
|
} |
|
|
|
|
|
.search-section { |
|
|
background: var(--bg-secondary); |
|
|
border: 1px solid var(--border); |
|
|
border-radius: var(--radius-lg); |
|
|
padding: 1.5rem; |
|
|
margin-bottom: 1.5rem; |
|
|
} |
|
|
|
|
|
.search-label { |
|
|
display: block; |
|
|
font-size: 0.85rem; |
|
|
font-weight: 500; |
|
|
color: var(--text-secondary); |
|
|
margin-bottom: 0.75rem; |
|
|
} |
|
|
|
|
|
.search-textarea { |
|
|
width: 100%; |
|
|
min-height: 120px; |
|
|
padding: 1rem; |
|
|
font-family: 'JetBrains Mono', monospace; |
|
|
font-size: 0.9rem; |
|
|
background: var(--bg-primary); |
|
|
border: 1px solid var(--border); |
|
|
border-radius: var(--radius-md); |
|
|
color: var(--text-primary); |
|
|
resize: vertical; |
|
|
transition: all 0.2s ease; |
|
|
line-height: 1.6; |
|
|
} |
|
|
|
|
|
.search-textarea:focus { |
|
|
outline: none; |
|
|
border-color: var(--accent); |
|
|
box-shadow: 0 0 0 3px var(--accent-glow); |
|
|
} |
|
|
|
|
|
.search-textarea::placeholder { |
|
|
color: var(--text-muted); |
|
|
} |
|
|
|
|
|
.search-controls { |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
margin-top: 1rem; |
|
|
gap: 1rem; |
|
|
} |
|
|
|
|
|
.char-count { |
|
|
font-family: 'JetBrains Mono', monospace; |
|
|
font-size: 0.8rem; |
|
|
color: var(--text-muted); |
|
|
} |
|
|
|
|
|
.search-actions { |
|
|
display: flex; |
|
|
gap: 0.75rem; |
|
|
align-items: center; |
|
|
} |
|
|
|
|
|
.top-k-select { |
|
|
padding: 0.6rem 0.75rem; |
|
|
background: var(--bg-tertiary); |
|
|
border: 1px solid var(--border); |
|
|
border-radius: var(--radius-sm); |
|
|
color: var(--text-primary); |
|
|
font-family: inherit; |
|
|
font-size: 0.85rem; |
|
|
cursor: pointer; |
|
|
} |
|
|
|
|
|
.search-btn { |
|
|
padding: 0.75rem 2rem; |
|
|
background: var(--gradient-1); |
|
|
border: none; |
|
|
border-radius: var(--radius-md); |
|
|
color: var(--bg-primary); |
|
|
font-family: inherit; |
|
|
font-size: 0.95rem; |
|
|
font-weight: 600; |
|
|
cursor: pointer; |
|
|
transition: all 0.2s ease; |
|
|
} |
|
|
|
|
|
.search-btn:hover { |
|
|
opacity: 0.9; |
|
|
transform: scale(1.02); |
|
|
} |
|
|
|
|
|
.search-btn:disabled { |
|
|
opacity: 0.5; |
|
|
cursor: not-allowed; |
|
|
transform: none; |
|
|
} |
|
|
|
|
|
.clear-btn { |
|
|
padding: 0.6rem 1rem; |
|
|
background: transparent; |
|
|
border: 1px solid var(--border); |
|
|
border-radius: var(--radius-sm); |
|
|
color: var(--text-secondary); |
|
|
font-family: inherit; |
|
|
font-size: 0.85rem; |
|
|
cursor: pointer; |
|
|
transition: all 0.2s ease; |
|
|
} |
|
|
|
|
|
.clear-btn:hover { |
|
|
border-color: var(--border-focus); |
|
|
color: var(--text-primary); |
|
|
} |
|
|
|
|
|
.results-container { |
|
|
margin-top: 1rem; |
|
|
} |
|
|
|
|
|
.results-header { |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
margin-bottom: 1rem; |
|
|
padding-bottom: 0.75rem; |
|
|
border-bottom: 1px solid var(--border); |
|
|
} |
|
|
|
|
|
.results-count { |
|
|
color: var(--text-secondary); |
|
|
font-size: 0.9rem; |
|
|
} |
|
|
|
|
|
.results-count strong { |
|
|
color: var(--text-primary); |
|
|
} |
|
|
|
|
|
.result-card { |
|
|
background: var(--bg-secondary); |
|
|
border: 1px solid var(--border); |
|
|
border-radius: var(--radius-md); |
|
|
padding: 1.25rem; |
|
|
margin-bottom: 0.75rem; |
|
|
transition: all 0.2s ease; |
|
|
animation: slideIn 0.3s ease forwards; |
|
|
opacity: 0; |
|
|
transform: translateY(10px); |
|
|
} |
|
|
|
|
|
.result-card:hover { |
|
|
border-color: var(--border-focus); |
|
|
background: var(--bg-tertiary); |
|
|
} |
|
|
|
|
|
@keyframes slideIn { |
|
|
to { |
|
|
opacity: 1; |
|
|
transform: translateY(0); |
|
|
} |
|
|
} |
|
|
|
|
|
.result-header { |
|
|
display: flex; |
|
|
justify-content: space-between; |
|
|
align-items: center; |
|
|
margin-bottom: 0.75rem; |
|
|
} |
|
|
|
|
|
.result-rank { |
|
|
display: inline-flex; |
|
|
align-items: center; |
|
|
justify-content: center; |
|
|
width: 32px; |
|
|
height: 32px; |
|
|
background: var(--bg-primary); |
|
|
border-radius: var(--radius-sm); |
|
|
font-family: 'JetBrains Mono', monospace; |
|
|
font-size: 0.85rem; |
|
|
font-weight: 600; |
|
|
color: var(--text-secondary); |
|
|
} |
|
|
|
|
|
.result-rank.top-3 { |
|
|
background: var(--accent-glow); |
|
|
color: var(--accent); |
|
|
} |
|
|
|
|
|
.result-score { |
|
|
font-family: 'JetBrains Mono', monospace; |
|
|
font-size: 0.85rem; |
|
|
color: var(--accent); |
|
|
background: var(--accent-glow); |
|
|
padding: 0.3rem 0.85rem; |
|
|
border-radius: var(--radius-sm); |
|
|
} |
|
|
|
|
|
.result-sequence { |
|
|
font-family: 'JetBrains Mono', monospace; |
|
|
font-size: 0.85rem; |
|
|
color: var(--text-primary); |
|
|
background: var(--bg-primary); |
|
|
padding: 0.85rem 1rem; |
|
|
border-radius: var(--radius-sm); |
|
|
margin-bottom: 0.75rem; |
|
|
word-break: break-all; |
|
|
line-height: 1.7; |
|
|
max-height: 120px; |
|
|
overflow-y: auto; |
|
|
letter-spacing: 0.5px; |
|
|
} |
|
|
|
|
|
.result-metadata { |
|
|
display: flex; |
|
|
flex-wrap: wrap; |
|
|
gap: 0.5rem; |
|
|
} |
|
|
|
|
|
.metadata-tag { |
|
|
display: inline-flex; |
|
|
align-items: center; |
|
|
gap: 0.4rem; |
|
|
padding: 0.35rem 0.75rem; |
|
|
background: var(--bg-primary); |
|
|
border-radius: var(--radius-sm); |
|
|
font-size: 0.8rem; |
|
|
} |
|
|
|
|
|
.metadata-key { |
|
|
color: var(--text-muted); |
|
|
} |
|
|
|
|
|
.metadata-value { |
|
|
color: var(--text-secondary); |
|
|
font-family: 'JetBrains Mono', monospace; |
|
|
max-width: 200px; |
|
|
overflow: hidden; |
|
|
text-overflow: ellipsis; |
|
|
white-space: nowrap; |
|
|
} |
|
|
|
|
|
.loading { |
|
|
display: flex; |
|
|
flex-direction: column; |
|
|
align-items: center; |
|
|
justify-content: center; |
|
|
gap: 1rem; |
|
|
padding: 3rem; |
|
|
color: var(--text-secondary); |
|
|
} |
|
|
|
|
|
.spinner { |
|
|
width: 32px; |
|
|
height: 32px; |
|
|
border: 3px solid var(--border); |
|
|
border-top-color: var(--accent); |
|
|
border-radius: 50%; |
|
|
animation: spin 0.8s linear infinite; |
|
|
} |
|
|
|
|
|
@keyframes spin { |
|
|
to { transform: rotate(360deg); } |
|
|
} |
|
|
|
|
|
.message { |
|
|
padding: 1rem 1.25rem; |
|
|
border-radius: var(--radius-md); |
|
|
margin-bottom: 1rem; |
|
|
font-size: 0.9rem; |
|
|
} |
|
|
|
|
|
.message.error { |
|
|
background: rgba(248, 113, 113, 0.1); |
|
|
border: 1px solid rgba(248, 113, 113, 0.2); |
|
|
color: var(--error); |
|
|
} |
|
|
|
|
|
.message.info { |
|
|
background: rgba(16, 185, 129, 0.1); |
|
|
border: 1px solid rgba(16, 185, 129, 0.2); |
|
|
color: var(--accent); |
|
|
} |
|
|
|
|
|
.empty-state { |
|
|
text-align: center; |
|
|
padding: 4rem 2rem; |
|
|
color: var(--text-muted); |
|
|
} |
|
|
|
|
|
.empty-state-icon { |
|
|
font-size: 3.5rem; |
|
|
margin-bottom: 1rem; |
|
|
opacity: 0.4; |
|
|
} |
|
|
|
|
|
.empty-state p { |
|
|
font-size: 1rem; |
|
|
} |
|
|
|
|
|
.example-queries { |
|
|
margin-top: 1.5rem; |
|
|
} |
|
|
|
|
|
.example-queries h4 { |
|
|
font-size: 0.8rem; |
|
|
color: var(--text-muted); |
|
|
text-transform: uppercase; |
|
|
letter-spacing: 0.05em; |
|
|
margin-bottom: 0.75rem; |
|
|
} |
|
|
|
|
|
.example-btn { |
|
|
display: inline-block; |
|
|
padding: 0.5rem 1rem; |
|
|
margin: 0.25rem; |
|
|
background: var(--bg-tertiary); |
|
|
border: 1px solid var(--border); |
|
|
border-radius: var(--radius-sm); |
|
|
color: var(--text-secondary); |
|
|
font-family: 'JetBrains Mono', monospace; |
|
|
font-size: 0.75rem; |
|
|
cursor: pointer; |
|
|
transition: all 0.2s ease; |
|
|
} |
|
|
|
|
|
.example-btn:hover { |
|
|
border-color: var(--accent); |
|
|
color: var(--accent); |
|
|
} |
|
|
|
|
|
@media (max-width: 640px) { |
|
|
.container { |
|
|
padding: 1rem; |
|
|
} |
|
|
|
|
|
h1 { |
|
|
font-size: 1.5rem; |
|
|
} |
|
|
|
|
|
.stats-bar { |
|
|
gap: 1.5rem; |
|
|
} |
|
|
|
|
|
.search-controls { |
|
|
flex-direction: column; |
|
|
align-items: stretch; |
|
|
} |
|
|
|
|
|
.search-actions { |
|
|
justify-content: space-between; |
|
|
} |
|
|
} |
|
|
</style> |
|
|
</head> |
|
|
<body> |
|
|
<div class="container"> |
|
|
<header> |
|
|
<div class="logo"> |
|
|
<div class="logo-icon">🧬</div> |
|
|
</div> |
|
|
<h1>Genomic Sequence Search</h1> |
|
|
<p class="subtitle">Find similar sequences using transformer embeddings</p> |
|
|
</header> |
|
|
|
|
|
<div class="stats-bar"> |
|
|
<div class="stat"> |
|
|
<div class="stat-value" id="doc-count">—</div> |
|
|
<div class="stat-label">Sequences</div> |
|
|
</div> |
|
|
<div class="stat"> |
|
|
<div class="stat-value" id="dim-count">—</div> |
|
|
<div class="stat-label">Dimensions</div> |
|
|
</div> |
|
|
<div class="stat"> |
|
|
<div class="stat-value" id="device-info">—</div> |
|
|
<div class="stat-label">Device</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div id="message-container"></div> |
|
|
|
|
|
<div class="search-section"> |
|
|
<label class="search-label">Enter a genomic sequence to search:</label> |
|
|
<textarea |
|
|
class="search-textarea" |
|
|
id="search-input" |
|
|
placeholder="Paste your genomic sequence here (e.g., ATCGATCGATCG...)" |
|
|
spellcheck="false" |
|
|
></textarea> |
|
|
<div class="search-controls"> |
|
|
<span class="char-count"><span id="char-count">0</span> characters</span> |
|
|
<div class="search-actions"> |
|
|
<button class="clear-btn" onclick="clearSearch()">Clear</button> |
|
|
<select class="top-k-select" id="top-k"> |
|
|
<option value="5">Top 5</option> |
|
|
<option value="10" selected>Top 10</option> |
|
|
<option value="20">Top 20</option> |
|
|
<option value="50">Top 50</option> |
|
|
</select> |
|
|
<button class="search-btn" id="search-btn" onclick="search()"> |
|
|
Search |
|
|
</button> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<div class="results-container" id="results-container"> |
|
|
<div class="empty-state"> |
|
|
<div class="empty-state-icon">🔬</div> |
|
|
<p>Enter a sequence above to find similar matches</p> |
|
|
<div class="example-queries"> |
|
|
<h4>Try an example</h4> |
|
|
<button class="example-btn" onclick="loadExample('ATCGATCGATCGATCGATCG')">ATCGATCG...</button> |
|
|
<button class="example-btn" onclick="loadExample('GCTAGCTAGCTAGCTAGCTA')">GCTAGCTA...</button> |
|
|
<button class="example-btn" onclick="loadExample('AAAATTTTCCCCGGGGAAAA')">AAAATTTT...</button> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<script> |
|
|
const API_BASE = ''; |
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => { |
|
|
loadStats(); |
|
|
|
|
|
const input = document.getElementById('search-input'); |
|
|
input.addEventListener('input', updateCharCount); |
|
|
input.addEventListener('keydown', (e) => { |
|
|
if (e.key === 'Enter' && e.ctrlKey) { |
|
|
search(); |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
async function loadStats() { |
|
|
try { |
|
|
const res = await fetch(`${API_BASE}/api/stats`); |
|
|
if (res.ok) { |
|
|
const data = await res.json(); |
|
|
document.getElementById('doc-count').textContent = data.total_documents.toLocaleString(); |
|
|
document.getElementById('dim-count').textContent = data.embedding_dimension; |
|
|
document.getElementById('device-info').textContent = data.device.toUpperCase(); |
|
|
} |
|
|
} catch (e) { |
|
|
console.log('Could not load stats:', e); |
|
|
} |
|
|
} |
|
|
|
|
|
function updateCharCount() { |
|
|
const count = document.getElementById('search-input').value.length; |
|
|
document.getElementById('char-count').textContent = count.toLocaleString(); |
|
|
} |
|
|
|
|
|
function clearSearch() { |
|
|
document.getElementById('search-input').value = ''; |
|
|
updateCharCount(); |
|
|
document.getElementById('results-container').innerHTML = ` |
|
|
<div class="empty-state"> |
|
|
<div class="empty-state-icon">🔬</div> |
|
|
<p>Enter a sequence above to find similar matches</p> |
|
|
<div class="example-queries"> |
|
|
<h4>Try an example</h4> |
|
|
<button class="example-btn" onclick="loadExample('ATCGATCGATCGATCGATCG')">ATCGATCG...</button> |
|
|
<button class="example-btn" onclick="loadExample('GCTAGCTAGCTAGCTAGCTA')">GCTAGCTA...</button> |
|
|
<button class="example-btn" onclick="loadExample('AAAATTTTCCCCGGGGAAAA')">AAAATTTT...</button> |
|
|
</div> |
|
|
</div> |
|
|
`; |
|
|
} |
|
|
|
|
|
function loadExample(seq) { |
|
|
document.getElementById('search-input').value = seq; |
|
|
updateCharCount(); |
|
|
search(); |
|
|
} |
|
|
|
|
|
async function search() { |
|
|
const query = document.getElementById('search-input').value.trim(); |
|
|
if (!query) { |
|
|
showMessage('Please enter a sequence to search', 'error'); |
|
|
return; |
|
|
} |
|
|
|
|
|
const topK = parseInt(document.getElementById('top-k').value); |
|
|
const container = document.getElementById('results-container'); |
|
|
const searchBtn = document.getElementById('search-btn'); |
|
|
|
|
|
container.innerHTML = ` |
|
|
<div class="loading"> |
|
|
<div class="spinner"></div> |
|
|
<span>Encoding sequence and searching...</span> |
|
|
</div> |
|
|
`; |
|
|
searchBtn.disabled = true; |
|
|
|
|
|
try { |
|
|
const res = await fetch(`${API_BASE}/api/search`, { |
|
|
method: 'POST', |
|
|
headers: { 'Content-Type': 'application/json' }, |
|
|
body: JSON.stringify({ query, top_k: topK }) |
|
|
}); |
|
|
|
|
|
const data = await res.json(); |
|
|
|
|
|
if (!res.ok) { |
|
|
container.innerHTML = `<div class="message error">${data.detail}</div>`; |
|
|
return; |
|
|
} |
|
|
|
|
|
if (data.results.length === 0) { |
|
|
container.innerHTML = ` |
|
|
<div class="empty-state"> |
|
|
<div class="empty-state-icon">🤷</div> |
|
|
<p>No similar sequences found</p> |
|
|
</div> |
|
|
`; |
|
|
return; |
|
|
} |
|
|
|
|
|
container.innerHTML = ` |
|
|
<div class="results-header"> |
|
|
<span class="results-count">Found <strong>${data.results.length}</strong> similar sequences</span> |
|
|
<span class="results-count">from ${data.total_indexed.toLocaleString()} indexed</span> |
|
|
</div> |
|
|
${data.results.map((r, i) => ` |
|
|
<div class="result-card" style="animation-delay: ${i * 0.04}s"> |
|
|
<div class="result-header"> |
|
|
<span class="result-rank ${r.rank <= 3 ? 'top-3' : ''}">${r.rank}</span> |
|
|
<span class="result-score">${(r.score * 100).toFixed(2)}%</span> |
|
|
</div> |
|
|
<div class="result-sequence">${escapeHtml(r.sequence)}</div> |
|
|
<div class="result-metadata"> |
|
|
${Object.entries(r.metadata) |
|
|
.filter(([k]) => !k.startsWith('__')) |
|
|
.slice(0, 8) |
|
|
.map(([k, v]) => ` |
|
|
<span class="metadata-tag"> |
|
|
<span class="metadata-key">${escapeHtml(k)}:</span> |
|
|
<span class="metadata-value" title="${escapeHtml(String(v))}">${escapeHtml(String(v).slice(0, 50))}</span> |
|
|
</span> |
|
|
`).join('')} |
|
|
</div> |
|
|
</div> |
|
|
`).join('')} |
|
|
`; |
|
|
} catch (e) { |
|
|
container.innerHTML = `<div class="message error">Search failed: ${e.message}</div>`; |
|
|
} finally { |
|
|
searchBtn.disabled = false; |
|
|
} |
|
|
} |
|
|
|
|
|
function showMessage(text, type = 'info') { |
|
|
const container = document.getElementById('message-container'); |
|
|
container.innerHTML = `<div class="message ${type}">${text}</div>`; |
|
|
setTimeout(() => container.innerHTML = '', 4000); |
|
|
} |
|
|
|
|
|
function escapeHtml(text) { |
|
|
const div = document.createElement('div'); |
|
|
div.textContent = text; |
|
|
return div.innerHTML; |
|
|
} |
|
|
</script> |
|
|
</body> |
|
|
</html> |