368 lines
9.1 KiB
HTML
368 lines
9.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Dictations Viewer</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=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<style>
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
:root {
|
|
--bg: #0f1117;
|
|
--surface: #1a1d27;
|
|
--surface-hover: #242836;
|
|
--border: rgba(255,255,255,0.08);
|
|
--text: #e4e6ed;
|
|
--text-muted: #8b8fa3;
|
|
--accent: #6c5ce7;
|
|
--accent-glow: rgba(108,92,231,0.25);
|
|
--accent-light: #a29bfe;
|
|
--success: #00cec9;
|
|
--danger: #ff7675;
|
|
--radius: 12px;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
min-height: 100dvh;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.container {
|
|
max-width: 720px;
|
|
margin: 0 auto;
|
|
padding: 24px 16px 48px;
|
|
}
|
|
|
|
.header {
|
|
text-align: center;
|
|
margin-bottom: 28px;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 1.5rem;
|
|
font-weight: 700;
|
|
letter-spacing: -0.02em;
|
|
margin-bottom: 4px;
|
|
background: linear-gradient(135deg, var(--accent-light), var(--success));
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
}
|
|
|
|
.header .subtitle {
|
|
font-size: 0.82rem;
|
|
color: var(--text-muted);
|
|
}
|
|
|
|
.dictation-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
}
|
|
|
|
.dictation-item {
|
|
display: block;
|
|
padding: 14px 16px;
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
cursor: pointer;
|
|
transition: background 0.2s, border-color 0.2s, transform 0.15s;
|
|
opacity: 0;
|
|
animation: fadeSlideIn 0.3s ease forwards;
|
|
}
|
|
|
|
.dictation-item:hover {
|
|
background: var(--surface-hover);
|
|
border-color: rgba(108,92,231,0.3);
|
|
transform: translateX(3px);
|
|
}
|
|
|
|
.dictation-item:active {
|
|
transform: translateX(1px);
|
|
}
|
|
|
|
.dictation-item.selected {
|
|
border-color: var(--accent);
|
|
background: var(--surface-hover);
|
|
box-shadow: 0 0 0 3px var(--accent-glow);
|
|
}
|
|
|
|
.dictation-summary {
|
|
font-size: 0.92rem;
|
|
font-weight: 500;
|
|
color: var(--text);
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.dictation-meta {
|
|
display: flex;
|
|
gap: 8px;
|
|
margin-top: 4px;
|
|
font-size: 0.78rem;
|
|
color: var(--text-muted);
|
|
}
|
|
|
|
.dictation-arrow {
|
|
float: right;
|
|
color: var(--text-muted);
|
|
font-size: 0.8rem;
|
|
opacity: 0;
|
|
transition: opacity 0.2s;
|
|
}
|
|
|
|
.dictation-item:hover .dictation-arrow { opacity: 1; }
|
|
|
|
.detail-panel {
|
|
margin-top: 20px;
|
|
padding: 20px;
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
display: none;
|
|
animation: fadeIn 0.25s ease;
|
|
}
|
|
|
|
.detail-panel.visible { display: block; }
|
|
|
|
.detail-title {
|
|
font-size: 1.15rem;
|
|
font-weight: 700;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.detail-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 12px;
|
|
}
|
|
|
|
.copy-btn {
|
|
background: var(--surface-hover);
|
|
border: 1px solid var(--border);
|
|
color: var(--text-muted);
|
|
padding: 6px 12px;
|
|
border-radius: 8px;
|
|
font-family: inherit;
|
|
font-size: 0.78rem;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: background 0.2s, color 0.2s;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.copy-btn:hover {
|
|
background: var(--accent);
|
|
color: #fff;
|
|
}
|
|
|
|
.copy-btn.copied {
|
|
background: var(--success);
|
|
color: #fff;
|
|
border-color: var(--success);
|
|
}
|
|
|
|
.detail-meta {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 6px;
|
|
margin-bottom: 16px;
|
|
margin-top: 8px;
|
|
}
|
|
|
|
.detail-tag {
|
|
font-size: 0.72rem;
|
|
padding: 2px 8px;
|
|
background: rgba(108,92,231,0.15);
|
|
color: var(--accent-light);
|
|
border-radius: 6px;
|
|
}
|
|
|
|
.detail-date {
|
|
font-size: 0.82rem;
|
|
color: var(--text-muted);
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.detail-content {
|
|
font-size: 0.92rem;
|
|
line-height: 1.7;
|
|
color: var(--text);
|
|
white-space: pre-wrap;
|
|
word-wrap: break-word;
|
|
}
|
|
|
|
@keyframes fadeSlideIn {
|
|
from { opacity: 0; transform: translateY(8px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from { opacity: 0; }
|
|
to { opacity: 1; }
|
|
}
|
|
|
|
.spinner {
|
|
width: 36px;
|
|
height: 36px;
|
|
border: 3px solid var(--border);
|
|
border-top-color: var(--accent);
|
|
border-radius: 50%;
|
|
animation: spin 0.7s linear infinite;
|
|
margin: 0 auto 16px;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
.state-message {
|
|
text-align: center;
|
|
padding: 48px 16px;
|
|
color: var(--text-muted);
|
|
font-size: 0.95rem;
|
|
}
|
|
|
|
.error-text { color: var(--danger); }
|
|
|
|
@media (max-width: 400px) {
|
|
.container { padding: 16px 12px 40px; }
|
|
.header h1 { font-size: 1.25rem; }
|
|
.dictation-item { padding: 12px 14px; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="container">
|
|
<header class="header">
|
|
<h1>Dictations</h1>
|
|
<p class="subtitle">Recent voice notes</p>
|
|
</header>
|
|
|
|
<div id="list" class="dictation-list"></div>
|
|
<div id="detail" class="detail-panel"></div>
|
|
</div>
|
|
|
|
<script>
|
|
const API_URL = {{ url_for('list_dictations') | tojson }};
|
|
const API_KEY = {{ api_key | tojson }};
|
|
|
|
let dictations = [];
|
|
let selectedIndex = -1;
|
|
|
|
function escapeHtml(str) {
|
|
if (str == null) return '';
|
|
const d = document.createElement('div');
|
|
d.textContent = str;
|
|
return d.innerHTML;
|
|
}
|
|
|
|
function formatDate(created_at) {
|
|
if (!created_at) return '';
|
|
const parts = created_at.split('-');
|
|
if (parts.length !== 2) return created_at;
|
|
const day = parts[0];
|
|
const time = parts[1];
|
|
if (day.length < 6 || time.length < 4) return created_at;
|
|
const d = day.slice(0, 2);
|
|
const m = day.slice(2, 4);
|
|
const y = day.slice(4);
|
|
const h = time.slice(0, 2);
|
|
const min = time.slice(2);
|
|
return `${m}/${d}/${y} ${h}:${min}`;
|
|
}
|
|
|
|
function renderList() {
|
|
const listEl = document.getElementById('list');
|
|
|
|
if (dictations.length === 0) {
|
|
listEl.innerHTML = '<div class="state-message">No dictations found.</div>';
|
|
return;
|
|
}
|
|
|
|
listEl.innerHTML = dictations.map((d, i) => {
|
|
const selected = i === selectedIndex ? ' selected' : '';
|
|
return `
|
|
<div class="dictation-item${selected}" style="animation-delay: ${i * 40}ms" onclick="selectItem(${i})">
|
|
<span class="dictation-arrow">\u203A</span>
|
|
<div class="dictation-summary">${escapeHtml(d.summary || d.title || 'Untitled')}</div>
|
|
<div class="dictation-meta">
|
|
<span>${escapeHtml(d.title || '')}</span>
|
|
${d.created_at ? `<span>${formatDate(d.created_at)}</span>` : ''}
|
|
</div>
|
|
</div>`;
|
|
}).join('');
|
|
}
|
|
|
|
function selectItem(index) {
|
|
selectedIndex = index;
|
|
renderList();
|
|
|
|
const d = dictations[index];
|
|
const detailEl = document.getElementById('detail');
|
|
|
|
const tags = (d.tags || []).map(t => `<span class="detail-tag">${escapeHtml(t)}</span>`).join('');
|
|
|
|
detailEl.innerHTML = `
|
|
<div class="detail-header">
|
|
<div class="detail-title">${escapeHtml(d.title || 'Untitled')}</div>
|
|
<button class="copy-btn" onclick="copyContent(${index}, this)">Copy</button>
|
|
</div>
|
|
<div class="detail-meta">
|
|
${d.created_at ? `<span class="detail-date">${formatDate(d.created_at)}</span>` : ''}
|
|
${tags}
|
|
</div>
|
|
<div class="detail-content">${escapeHtml(d.content || '')}</div>`;
|
|
|
|
detailEl.classList.add('visible');
|
|
detailEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
}
|
|
|
|
function copyContent(index, btn) {
|
|
const d = dictations[index];
|
|
navigator.clipboard.writeText(d.content || '').then(() => {
|
|
btn.textContent = 'Copied';
|
|
btn.classList.add('copied');
|
|
setTimeout(() => {
|
|
btn.textContent = 'Copy';
|
|
btn.classList.remove('copied');
|
|
}, 1500);
|
|
});
|
|
}
|
|
|
|
async function load() {
|
|
const listEl = document.getElementById('list');
|
|
listEl.innerHTML = '<div class="state-message"><div class="spinner"></div>Loading dictations...</div>';
|
|
|
|
try {
|
|
const res = await fetch(API_URL, { headers: { 'x-api-key': API_KEY } });
|
|
if (!res.ok) throw new Error(`API error: ${res.status}`);
|
|
dictations = await res.json();
|
|
selectedIndex = -1;
|
|
document.getElementById('detail').classList.remove('visible');
|
|
renderList();
|
|
} catch (err) {
|
|
listEl.innerHTML = `
|
|
<div class="state-message">
|
|
<span class="error-text">Failed to load dictations</span><br>
|
|
<small style="color:var(--text-muted)">${escapeHtml(err.message)}</small>
|
|
</div>`;
|
|
}
|
|
}
|
|
|
|
load();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|