refactor: establish standalone application boundary
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
window.XiaobaiPageModules.register("popularity", ["popularityView"], {
|
||||
bind: bindPopularityEvents,
|
||||
enter: ["loadPopularity"],
|
||||
});
|
||||
|
||||
/* PRESERVATION-SOURCE-BEGIN app.js:2584-2659 */
|
||||
async function loadPopularity(force = false) {
|
||||
if (state.popularityLoading) return;
|
||||
state.popularityLoading = true;
|
||||
@@ -79,4 +79,22 @@ function renderPopularityTable() {
|
||||
document.querySelector("#popularityEmpty").hidden = rows.length > 0;
|
||||
}
|
||||
|
||||
/* PRESERVATION-SOURCE-END app.js:2584-2659 */
|
||||
|
||||
function bindPopularityEvents() {
|
||||
document.querySelector("#popularityRefreshButton").addEventListener("click", () => loadPopularity(true));
|
||||
document.querySelector("#popularitySearch").addEventListener("input", (event) => {
|
||||
state.popularityQuery = event.target.value.trim().toLocaleLowerCase("zh-CN");
|
||||
renderPopularityTable();
|
||||
});
|
||||
document.querySelectorAll("[data-popularity-source]").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
state.popularitySource = button.dataset.popularitySource || "combined";
|
||||
document.querySelectorAll("[data-popularity-source]").forEach((item) => {
|
||||
const active = item === button;
|
||||
item.classList.toggle("active", active);
|
||||
item.setAttribute("aria-selected", String(active));
|
||||
});
|
||||
renderPopularityTable();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user