feat: import mahavivo english-wordlists into me/lang.db (13k words, level=lowest cert); add 'new' status + items pagination
This commit is contained in:
@@ -79,6 +79,7 @@ tr:last-child td{border-bottom:none}
|
||||
.b-known{background:rgba(46,204,113,.15);color:#2ecc71}
|
||||
.b-learning{background:rgba(241,196,15,.15);color:#f1c40f}
|
||||
.b-fix{background:rgba(231,76,60,.15);color:#e74c3c}
|
||||
.b-new{background:#2a2f3a;color:#9aa2b1}
|
||||
.fx{color:#ffb4a8}
|
||||
.toolbar{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-bottom:10px}
|
||||
.toolbar button,.toolbar input{background:#1e222b;color:#e8e8ea;border:1px solid #2a2e3a;border-radius:8px;padding:6px 11px;font-size:13px;cursor:pointer}
|
||||
@@ -225,12 +226,19 @@ BODY_ITEMS = """
|
||||
<h1>词条 <span class="muted" style="font-size:14px">单词 / 词组</span></h1>
|
||||
<div class="toolbar">
|
||||
<button data-f="all" class="on">全部</button>
|
||||
<button data-f="known">已掌握</button>
|
||||
<button data-f="new">未学</button>
|
||||
<button data-f="learning">学习中</button>
|
||||
<button data-f="known">已掌握</button>
|
||||
<button data-f="fix">待修正</button>
|
||||
<input id="q" placeholder="搜索 item / 释义 / 上下文…">
|
||||
<span id="count" class="muted"></span>
|
||||
</div>
|
||||
<div class="wrapx"><table id="items"></table></div>
|
||||
<div class="toolbar" style="margin-top:10px">
|
||||
<button id="prev">‹ 上一页</button>
|
||||
<span id="pageinfo" class="muted"></span>
|
||||
<button id="next">下一页 ›</button>
|
||||
</div>
|
||||
"""
|
||||
|
||||
BODY_GRAMMAR = """
|
||||
@@ -262,7 +270,7 @@ document.getElementById("overview").innerHTML = Object.keys(glyph).map(k => {
|
||||
const o = ov[k];
|
||||
const parts = k === "grammar"
|
||||
? `待修正 ${o.fix} · 已克服 ${o.known||0}`
|
||||
: `已掌握 ${o.known} · 学习中 ${o.learning} · 待修正 ${o.fix}`;
|
||||
: `未学 ${o.new||0} · 学习中 ${o.learning} · 已掌握 ${o.known} · 待修正 ${o.fix}`;
|
||||
return `<div class="card"><div class="k">${glyph[k]}</div>
|
||||
<div class="v">${o.total}</div><div class="c">${parts}</div></div>`;
|
||||
}).join("");
|
||||
@@ -270,29 +278,41 @@ document.getElementById("overview").innerHTML = Object.keys(glyph).map(k => {
|
||||
|
||||
SCRIPT_ITEMS = r"""
|
||||
const KIND = {word:"单词", phrase:"词组", expression:"表达"};
|
||||
let currentFilter = "all";
|
||||
function renderItems() {
|
||||
const PAGE = 200;
|
||||
let currentFilter = "all", page = 0;
|
||||
function filtered() {
|
||||
const f = currentFilter, q = document.getElementById("q").value.trim().toLowerCase();
|
||||
const rows = DATA.items.filter(i =>
|
||||
return DATA.items.filter(i =>
|
||||
(i.kind === "word" || i.kind === "phrase") &&
|
||||
(f === "all" || i.status === f) &&
|
||||
(!q || (i.item + i.meaning + i.context + i.tags).toLowerCase().includes(q)));
|
||||
}
|
||||
function renderItems() {
|
||||
const rows = filtered();
|
||||
const pages = Math.max(1, Math.ceil(rows.length / PAGE));
|
||||
page = Math.min(Math.max(0, page), pages - 1);
|
||||
const slice = rows.slice(page * PAGE, (page + 1) * PAGE);
|
||||
document.getElementById("items").innerHTML =
|
||||
`<thead><tr><th>id</th><th>类型</th><th>条目</th><th>等级</th><th>释义</th>
|
||||
<th>上下文</th><th>状态</th><th>first</th><th>修正</th><th>标签</th></tr></thead><tbody>` +
|
||||
rows.map(i => `<tr>
|
||||
(slice.map(i => `<tr>
|
||||
<td class="mono">${esc(i.id)}</td><td>${KIND[i.kind]||i.kind}</td>
|
||||
<td><b>${esc(i.item)}</b></td><td>${esc(i.level)}</td>
|
||||
<td>${esc(i.meaning)}</td><td class="muted">${esc(i.context)}</td>
|
||||
<td>${badge(i.status)}</td><td class="mono">${esc(i.first)}</td>
|
||||
<td>${fx(i.fix)}</td><td class="muted">${esc(i.tags)}</td></tr>`).join("") + `</tbody>`;
|
||||
<td>${fx(i.fix)}</td><td class="muted">${esc(i.tags)}</td></tr>`).join("")
|
||||
|| `<tr><td colspan="10" class="muted">无</td></tr>`) + `</tbody>`;
|
||||
document.getElementById("count").textContent = `共 ${rows.length} 条`;
|
||||
document.getElementById("pageinfo").textContent = `第 ${page + 1} / ${pages} 页`;
|
||||
}
|
||||
document.querySelectorAll(".toolbar button[data-f]").forEach(b => b.onclick = () => {
|
||||
currentFilter = b.dataset.f;
|
||||
currentFilter = b.dataset.f; page = 0;
|
||||
document.querySelectorAll(".toolbar button[data-f]").forEach(x => x.classList.toggle("on", x === b));
|
||||
renderItems();
|
||||
});
|
||||
document.getElementById("q").oninput = renderItems;
|
||||
document.getElementById("q").oninput = () => { page = 0; renderItems(); };
|
||||
document.getElementById("prev").onclick = () => { page--; renderItems(); };
|
||||
document.getElementById("next").onclick = () => { page++; renderItems(); };
|
||||
renderItems();
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user