dashboard(items): stronger centered pagination (first/last/jump/disabled)
This commit is contained in:
@@ -86,6 +86,12 @@ tr:last-child td{border-bottom:none}
|
||||
.toolbar button,.toolbar input{background:#1e222b;color:#e8e8ea;border:1px solid #2a2e3a;border-radius:8px;padding:6px 11px;font-size:13px;cursor:pointer}
|
||||
.toolbar button.on{border-color:#4a90d9;color:#fff;background:#24314d}
|
||||
.toolbar input{cursor:text;min-width:220px}
|
||||
.pager{display:flex;justify-content:center;align-items:center;gap:8px;margin:14px 0;flex-wrap:wrap}
|
||||
.pager button{background:#1e222b;color:#e8e8ea;border:1px solid #2a2e3a;border-radius:8px;padding:6px 14px;font-size:13px;cursor:pointer}
|
||||
.pager button:hover:not(:disabled){border-color:#4a90d9;color:#fff}
|
||||
.pager button:disabled{opacity:.4;cursor:default}
|
||||
.pager .pginfo{color:#9aa2b1;font-size:13px;display:flex;align-items:center;gap:6px}
|
||||
.pager input{width:62px;background:#1e222b;color:#e8e8ea;border:1px solid #2a2e3a;border-radius:6px;padding:5px 8px;font-size:13px;text-align:center}
|
||||
.muted{color:#8a94a6}
|
||||
.wrapx{border-radius:10px;overflow:visible}
|
||||
.md{background:#1b1e27;border:1px solid #2a2e3a;border-radius:10px;padding:4px 20px 18px;max-width:920px;margin:16px 0}
|
||||
@@ -240,10 +246,12 @@ BODY_ITEMS = """
|
||||
<span id="count" class="muted"></span>
|
||||
</div>
|
||||
<div class="wrapx"><table id="items"></table></div>
|
||||
<div class="toolbar" style="margin-top:10px">
|
||||
<div class="pager">
|
||||
<button id="first">« 首页</button>
|
||||
<button id="prev">‹ 上一页</button>
|
||||
<span id="pageinfo" class="muted"></span>
|
||||
<span class="pginfo">第 <input id="pageJump" type="number" min="1" value="1"> / <b id="pages">1</b> 页</span>
|
||||
<button id="next">下一页 ›</button>
|
||||
<button id="last">末页 »</button>
|
||||
</div>
|
||||
"""
|
||||
|
||||
@@ -300,7 +308,12 @@ function renderItems() {
|
||||
<td>${badge(i.status)}</td></tr>`).join("")
|
||||
|| `<tr><td colspan="6" class="muted">无</td></tr>`) + `</tbody>`;
|
||||
document.getElementById("count").textContent = `共 ${rows.length} 条`;
|
||||
document.getElementById("pageinfo").textContent = `第 ${page + 1} / ${pages} 页`;
|
||||
const $ = id => document.getElementById(id);
|
||||
$("pages").textContent = pages;
|
||||
$("pageJump").value = page + 1;
|
||||
$("pageJump").max = pages;
|
||||
$("first").disabled = $("prev").disabled = page <= 0;
|
||||
$("next").disabled = $("last").disabled = page >= pages - 1;
|
||||
}
|
||||
document.querySelectorAll(".toolbar button[data-f]").forEach(b => b.onclick = () => {
|
||||
currentFilter = b.dataset.f; page = 0;
|
||||
@@ -308,8 +321,14 @@ document.querySelectorAll(".toolbar button[data-f]").forEach(b => b.onclick = ()
|
||||
renderItems();
|
||||
});
|
||||
document.getElementById("q").oninput = () => { page = 0; renderItems(); };
|
||||
document.getElementById("first").onclick = () => { page = 0; renderItems(); };
|
||||
document.getElementById("prev").onclick = () => { page--; renderItems(); };
|
||||
document.getElementById("next").onclick = () => { page++; renderItems(); };
|
||||
document.getElementById("last").onclick = () => { page = 1e9; renderItems(); };
|
||||
document.getElementById("pageJump").onchange = () => {
|
||||
const n = parseInt(document.getElementById("pageJump").value, 10);
|
||||
if (n) { page = n - 1; renderItems(); }
|
||||
};
|
||||
renderItems();
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user