Spaces:
Running
Running
Upload 2 files
Browse files- static/app.js +31 -1
- static/style.css +29 -1
static/app.js
CHANGED
|
@@ -400,6 +400,7 @@ function renderResults() {
|
|
| 400 |
DOM.pageTotal.textContent = String(totalPages);
|
| 401 |
DOM.prevPage.disabled = STATE.page <= 1;
|
| 402 |
DOM.nextPage.disabled = STATE.page >= totalPages;
|
|
|
|
| 403 |
DOM.emptyState.style.display = STATE.results.length ? "none" : "flex";
|
| 404 |
DOM.results.innerHTML = STATE.results.map((item) => resultHTML(item)).join("");
|
| 405 |
}
|
|
@@ -524,10 +525,34 @@ function previewTitleHTML(item) {
|
|
| 524 |
|
| 525 |
function previewMetaHTML(item) {
|
| 526 |
const authors = item.authors && item.authors.length ? ` / ${escapeHTML(item.authors.join(", "))}` : "";
|
| 527 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 528 |
return `<div class="preview-path">${escapeHTML(item.publication_name)}${authors}</div>${tags}`;
|
| 529 |
}
|
| 530 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 531 |
function compareSelectHTML(item) {
|
| 532 |
if (!item.variants || !item.variants.length) return "";
|
| 533 |
const options = item.variants.map((variant) => `<option value="${escapeHTML(variant.doc_id)}">${escapeHTML(variant.publication_name)}</option>`).join("");
|
|
@@ -681,6 +706,11 @@ function attachEvents() {
|
|
| 681 |
}
|
| 682 |
});
|
| 683 |
DOM.previewPanel.addEventListener("click", (event) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 684 |
if (event.target.closest("[data-close-preview]")) {
|
| 685 |
STATE.preview = "";
|
| 686 |
restorePreview(false);
|
|
|
|
| 400 |
DOM.pageTotal.textContent = String(totalPages);
|
| 401 |
DOM.prevPage.disabled = STATE.page <= 1;
|
| 402 |
DOM.nextPage.disabled = STATE.page >= totalPages;
|
| 403 |
+
DOM.results.hidden = !STATE.results.length;
|
| 404 |
DOM.emptyState.style.display = STATE.results.length ? "none" : "flex";
|
| 405 |
DOM.results.innerHTML = STATE.results.map((item) => resultHTML(item)).join("");
|
| 406 |
}
|
|
|
|
| 525 |
|
| 526 |
function previewMetaHTML(item) {
|
| 527 |
const authors = item.authors && item.authors.length ? ` / ${escapeHTML(item.authors.join(", "))}` : "";
|
| 528 |
+
const tagNames = item.tag_names || [];
|
| 529 |
+
const pageSize = 8;
|
| 530 |
+
const totalPages = Math.ceil(tagNames.length / pageSize);
|
| 531 |
+
const tagItems = tagNames.map((tag, index) => {
|
| 532 |
+
const page = Math.floor(index / pageSize) + 1;
|
| 533 |
+
const hasNextOnPage = index + 1 < tagNames.length && Math.floor((index + 1) / pageSize) + 1 === page;
|
| 534 |
+
return `<span data-preview-tag-page="${page}" ${page > 1 ? "hidden" : ""}>${escapeHTML(tag)}${hasNextOnPage ? '<span class="path-sep"> / </span>' : ""}</span>`;
|
| 535 |
+
}).join("");
|
| 536 |
+
const pager = totalPages > 1 ? `<div class="preview-tag-pager"><button type="button" class="text-btn-sm" data-preview-tag-page-change="prev" disabled>上一页</button><span><span data-preview-tag-current>1</span> / ${totalPages}</span><button type="button" class="text-btn-sm" data-preview-tag-page-change="next">下一页</button></div>` : "";
|
| 537 |
+
const tags = tagNames.length ? `<div class="preview-tags" data-preview-tags data-total-pages="${totalPages}"><div class="preview-path preview-tag-list">${tagItems}</div>${pager}</div>` : "";
|
| 538 |
return `<div class="preview-path">${escapeHTML(item.publication_name)}${authors}</div>${tags}`;
|
| 539 |
}
|
| 540 |
|
| 541 |
+
function changePreviewTagPage(button) {
|
| 542 |
+
const container = button.closest("[data-preview-tags]");
|
| 543 |
+
if (!container) return;
|
| 544 |
+
const totalPages = parseInt(container.dataset.totalPages || "1", 10);
|
| 545 |
+
const currentNode = container.querySelector("[data-preview-tag-current]");
|
| 546 |
+
const current = parseInt(currentNode?.textContent || "1", 10);
|
| 547 |
+
const next = Math.min(totalPages, Math.max(1, current + (button.dataset.previewTagPageChange === "next" ? 1 : -1)));
|
| 548 |
+
container.querySelectorAll("[data-preview-tag-page]").forEach((tag) => { tag.hidden = parseInt(tag.dataset.previewTagPage, 10) !== next; });
|
| 549 |
+
if (currentNode) currentNode.textContent = String(next);
|
| 550 |
+
const prev = container.querySelector('[data-preview-tag-page-change="prev"]');
|
| 551 |
+
const nextButton = container.querySelector('[data-preview-tag-page-change="next"]');
|
| 552 |
+
if (prev) prev.disabled = next <= 1;
|
| 553 |
+
if (nextButton) nextButton.disabled = next >= totalPages;
|
| 554 |
+
}
|
| 555 |
+
|
| 556 |
function compareSelectHTML(item) {
|
| 557 |
if (!item.variants || !item.variants.length) return "";
|
| 558 |
const options = item.variants.map((variant) => `<option value="${escapeHTML(variant.doc_id)}">${escapeHTML(variant.publication_name)}</option>`).join("");
|
|
|
|
| 706 |
}
|
| 707 |
});
|
| 708 |
DOM.previewPanel.addEventListener("click", (event) => {
|
| 709 |
+
const tagPageButton = event.target.closest("[data-preview-tag-page-change]");
|
| 710 |
+
if (tagPageButton) {
|
| 711 |
+
changePreviewTagPage(tagPageButton);
|
| 712 |
+
return;
|
| 713 |
+
}
|
| 714 |
if (event.target.closest("[data-close-preview]")) {
|
| 715 |
STATE.preview = "";
|
| 716 |
restorePreview(false);
|
static/style.css
CHANGED
|
@@ -548,6 +548,20 @@ ul, li {
|
|
| 548 |
word-break: break-all;
|
| 549 |
}
|
| 550 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 551 |
.preview-body {
|
| 552 |
margin: 0;
|
| 553 |
padding: 14px;
|
|
@@ -570,7 +584,8 @@ ul, li {
|
|
| 570 |
}
|
| 571 |
|
| 572 |
body.mobile .preview-compare-grid {
|
| 573 |
-
|
|
|
|
| 574 |
}
|
| 575 |
|
| 576 |
body.mobile .preview-compare-grid > div:first-child {
|
|
@@ -578,6 +593,15 @@ body.mobile .preview-compare-grid > div:first-child {
|
|
| 578 |
border-bottom: 1px solid var(--outline-variant);
|
| 579 |
}
|
| 580 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 581 |
.result-snippet {
|
| 582 |
margin-top: 6px;
|
| 583 |
font-size: 12px;
|
|
@@ -1241,6 +1265,10 @@ body.mobile .multi-toggle { padding: 1px 4px; font-size: 11px; }
|
|
| 1241 |
overflow-x: hidden;
|
| 1242 |
}
|
| 1243 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1244 |
.preview-panel:not([hidden]) + .results-list {
|
| 1245 |
border-top: 1px solid var(--outline-variant);
|
| 1246 |
}
|
|
|
|
| 548 |
word-break: break-all;
|
| 549 |
}
|
| 550 |
|
| 551 |
+
.preview-tag-pager {
|
| 552 |
+
display: flex;
|
| 553 |
+
align-items: center;
|
| 554 |
+
gap: 8px;
|
| 555 |
+
margin-top: 4px;
|
| 556 |
+
font-size: 11px;
|
| 557 |
+
color: var(--on-surface-variant);
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
.preview-tag-pager .text-btn-sm:disabled {
|
| 561 |
+
opacity: 0.45;
|
| 562 |
+
cursor: not-allowed;
|
| 563 |
+
}
|
| 564 |
+
|
| 565 |
.preview-body {
|
| 566 |
margin: 0;
|
| 567 |
padding: 14px;
|
|
|
|
| 584 |
}
|
| 585 |
|
| 586 |
body.mobile .preview-compare-grid {
|
| 587 |
+
display: block;
|
| 588 |
+
overflow-y: auto;
|
| 589 |
}
|
| 590 |
|
| 591 |
body.mobile .preview-compare-grid > div:first-child {
|
|
|
|
| 593 |
border-bottom: 1px solid var(--outline-variant);
|
| 594 |
}
|
| 595 |
|
| 596 |
+
body.mobile .preview-body.compare-body {
|
| 597 |
+
max-height: none;
|
| 598 |
+
overflow: visible;
|
| 599 |
+
}
|
| 600 |
+
|
| 601 |
+
body.mobile .preview-compare-grid .diff-gap {
|
| 602 |
+
display: none;
|
| 603 |
+
}
|
| 604 |
+
|
| 605 |
.result-snippet {
|
| 606 |
margin-top: 6px;
|
| 607 |
font-size: 12px;
|
|
|
|
| 1265 |
overflow-x: hidden;
|
| 1266 |
}
|
| 1267 |
|
| 1268 |
+
.results-list[hidden] {
|
| 1269 |
+
display: none;
|
| 1270 |
+
}
|
| 1271 |
+
|
| 1272 |
.preview-panel:not([hidden]) + .results-list {
|
| 1273 |
border-top: 1px solid var(--outline-variant);
|
| 1274 |
}
|