0a4659f7e6
Converts Japanese vocab (Kanji/Hiragana/English) to Anki CSV format. Served on port 4002 with a dark-themed two-panel UI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
300 lines
7.9 KiB
HTML
300 lines
7.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Anki Flashcard Creator</title>
|
|
<style>
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
:root {
|
|
--bg: #0f1117;
|
|
--surface: #1a1d27;
|
|
--border: #2a2d3a;
|
|
--accent: #6c63ff;
|
|
--accent-dim: #4a43cc;
|
|
--text: #e2e4f0;
|
|
--muted: #7a7d94;
|
|
--success: #4caf82;
|
|
--radius: 10px;
|
|
}
|
|
|
|
body {
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
font-family: 'Segoe UI', system-ui, sans-serif;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
padding: 2.5rem 1rem;
|
|
}
|
|
|
|
header {
|
|
text-align: center;
|
|
margin-bottom: 2.5rem;
|
|
}
|
|
|
|
header h1 {
|
|
font-size: 2rem;
|
|
font-weight: 700;
|
|
letter-spacing: -0.5px;
|
|
background: linear-gradient(135deg, #6c63ff, #a78bfa);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
}
|
|
|
|
header p {
|
|
margin-top: 0.5rem;
|
|
color: var(--muted);
|
|
font-size: 0.95rem;
|
|
}
|
|
|
|
.container {
|
|
width: 100%;
|
|
max-width: 900px;
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 1.5rem;
|
|
}
|
|
|
|
@media (max-width: 640px) {
|
|
.container { grid-template-columns: 1fr; }
|
|
}
|
|
|
|
.panel {
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
overflow: hidden;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.panel-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 0.85rem 1.1rem;
|
|
border-bottom: 1px solid var(--border);
|
|
font-size: 0.8rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.08em;
|
|
color: var(--muted);
|
|
}
|
|
|
|
.badge {
|
|
background: var(--border);
|
|
border-radius: 20px;
|
|
padding: 0.15rem 0.55rem;
|
|
font-size: 0.72rem;
|
|
}
|
|
|
|
textarea {
|
|
flex: 1;
|
|
background: transparent;
|
|
border: none;
|
|
outline: none;
|
|
resize: none;
|
|
color: var(--text);
|
|
font-family: 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
|
|
font-size: 0.88rem;
|
|
line-height: 1.7;
|
|
padding: 1rem 1.1rem;
|
|
min-height: 340px;
|
|
}
|
|
|
|
textarea::placeholder { color: var(--muted); opacity: 0.6; }
|
|
|
|
.actions {
|
|
display: flex;
|
|
gap: 0.75rem;
|
|
margin-top: 1.5rem;
|
|
width: 100%;
|
|
max-width: 900px;
|
|
}
|
|
|
|
button {
|
|
cursor: pointer;
|
|
border: none;
|
|
border-radius: var(--radius);
|
|
font-size: 0.9rem;
|
|
font-weight: 600;
|
|
padding: 0.7rem 1.4rem;
|
|
transition: opacity 0.15s, transform 0.1s;
|
|
}
|
|
|
|
button:active { transform: scale(0.97); }
|
|
|
|
.btn-primary {
|
|
background: var(--accent);
|
|
color: #fff;
|
|
flex: 1;
|
|
}
|
|
|
|
.btn-primary:hover { background: var(--accent-dim); }
|
|
|
|
.btn-secondary {
|
|
background: var(--surface);
|
|
color: var(--text);
|
|
border: 1px solid var(--border);
|
|
}
|
|
|
|
.btn-secondary:hover { border-color: var(--accent); }
|
|
|
|
.btn-secondary:disabled {
|
|
opacity: 0.35;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.format-hint {
|
|
width: 100%;
|
|
max-width: 900px;
|
|
margin-top: 1.5rem;
|
|
padding: 1rem 1.25rem;
|
|
background: var(--surface);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius);
|
|
font-size: 0.82rem;
|
|
color: var(--muted);
|
|
line-height: 1.7;
|
|
}
|
|
|
|
.format-hint strong { color: var(--text); }
|
|
|
|
.format-hint code {
|
|
font-family: 'Cascadia Code', 'Fira Code', monospace;
|
|
background: var(--border);
|
|
border-radius: 4px;
|
|
padding: 0 4px;
|
|
font-size: 0.82rem;
|
|
}
|
|
|
|
.toast {
|
|
position: fixed;
|
|
bottom: 1.5rem;
|
|
left: 50%;
|
|
transform: translateX(-50%) translateY(60px);
|
|
background: var(--success);
|
|
color: #fff;
|
|
padding: 0.6rem 1.2rem;
|
|
border-radius: 30px;
|
|
font-size: 0.85rem;
|
|
font-weight: 600;
|
|
opacity: 0;
|
|
transition: opacity 0.2s, transform 0.2s;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.toast.show {
|
|
opacity: 1;
|
|
transform: translateX(-50%) translateY(0);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>Anki Flashcard Creator</h1>
|
|
<p>Convert Japanese vocabulary lists into Anki-ready CSV</p>
|
|
</header>
|
|
|
|
<div class="container">
|
|
<div class="panel">
|
|
<div class="panel-header">
|
|
<span>Input</span>
|
|
<span class="badge">Kanji · Hiragana · English</span>
|
|
</div>
|
|
<textarea id="input" placeholder="食べる たべる to eat 飲む のむ to drink ..."></textarea>
|
|
</div>
|
|
|
|
<div class="panel">
|
|
<div class="panel-header">
|
|
<span>Output</span>
|
|
<span class="badge" id="card-count">0 cards</span>
|
|
</div>
|
|
<textarea id="output" readonly placeholder="Converted flashcards will appear here..."></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="actions">
|
|
<button class="btn-primary" onclick="convert()">Convert</button>
|
|
<button class="btn-secondary" id="copy-btn" onclick="copyOutput()" disabled>Copy</button>
|
|
<button class="btn-secondary" id="download-btn" onclick="downloadOutput()" disabled>Download CSV</button>
|
|
</div>
|
|
|
|
<div class="format-hint">
|
|
<strong>Input format</strong> — one entry per four lines (blank line between entries):<br />
|
|
<code>漢字</code> → kanji or word<br />
|
|
<code>ひらがな</code> → reading (hiragana / romaji)<br />
|
|
<code>English; alt1; alt2</code> → translation (semicolon-separated alternatives)<br />
|
|
<code>(blank line)</code><br /><br />
|
|
<strong>Output format</strong> — two CSV rows per entry (recognition card + production card)
|
|
</div>
|
|
|
|
<div class="toast" id="toast"></div>
|
|
|
|
<script>
|
|
function readyForImport(l1, l2, l3) {
|
|
var front = l1 + ",\"" + l2 + "\n" + l3 + "\"";
|
|
var back = l3 + ",\"" + l1 + "\n" + l2 + "\"";
|
|
return "\n" + front + "\n" + back;
|
|
}
|
|
|
|
function convert() {
|
|
const raw = document.getElementById('input').value.trim();
|
|
if (!raw) return;
|
|
|
|
const lines = raw.split("\n");
|
|
let result = "";
|
|
let count = 0;
|
|
|
|
for (let i = 0; i < lines.length; i += 4) {
|
|
const l1 = (lines[i] || "").trim();
|
|
const l2 = (lines[i + 1] || "").trim();
|
|
const l3 = (lines[i + 2] || "").trim();
|
|
if (!l1 && !l2 && !l3) continue;
|
|
result += readyForImport(l1, l2, l3);
|
|
count++;
|
|
}
|
|
|
|
result = result.substring(1); // strip leading newline
|
|
|
|
document.getElementById('output').value = result;
|
|
document.getElementById('card-count').textContent = count + (count === 1 ? " card" : " cards");
|
|
document.getElementById('copy-btn').disabled = !result;
|
|
document.getElementById('download-btn').disabled = !result;
|
|
}
|
|
|
|
function copyOutput() {
|
|
const text = document.getElementById('output').value;
|
|
if (!text) return;
|
|
navigator.clipboard.writeText(text).then(() => showToast("Copied to clipboard"));
|
|
}
|
|
|
|
function downloadOutput() {
|
|
const text = document.getElementById('output').value;
|
|
if (!text) return;
|
|
const blob = new Blob([text], { type: 'text/plain', endings: 'native' });
|
|
const a = document.createElement('a');
|
|
a.href = URL.createObjectURL(blob);
|
|
a.download = 'anki-cards.csv';
|
|
a.click();
|
|
URL.revokeObjectURL(a.href);
|
|
showToast("Downloaded anki-cards.csv");
|
|
}
|
|
|
|
function showToast(msg) {
|
|
const t = document.getElementById('toast');
|
|
t.textContent = msg;
|
|
t.classList.add('show');
|
|
setTimeout(() => t.classList.remove('show'), 2200);
|
|
}
|
|
|
|
document.getElementById('input').addEventListener('keydown', e => {
|
|
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') convert();
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|