add filtering and sorting features; enhance events and articles pages with URL state persistence

This commit is contained in:
ImBenji
2026-04-23 23:03:11 +01:00
parent bec6763191
commit 194442ec4c
8 changed files with 274 additions and 16 deletions
@@ -1,9 +1,21 @@
// intelligence → predictions table
// filter/sort/pagination persisted via url query params
// depends on: app.js, intel-shared.js
let predictionsOffset = 0;
function syncUrl() {
const companyId = document.getElementById("i-company").value;
const sort = document.getElementById("i-sort").value;
queryWrite({
company_id: companyId,
sort: sort && sort !== "id" ? sort : "",
offset: predictionsOffset > 0 ? predictionsOffset : "",
});
}
async function loadPredictions() {
const companyId = document.getElementById("i-company").value;
const sort = document.getElementById("i-sort").value;
@@ -43,19 +55,30 @@ async function loadPredictions() {
document.addEventListener("DOMContentLoaded", async () => {
document.getElementById("iPrevBtn").onclick = () => {
predictionsOffset = Math.max(0, predictionsOffset - PAGE);
syncUrl();
loadPredictions();
};
document.getElementById("iNextBtn").onclick = () => {
predictionsOffset += PAGE;
syncUrl();
loadPredictions();
};
document.getElementById("i-filter-btn").onclick = () => {
predictionsOffset = 0;
syncUrl();
loadPredictions();
};
const ok = await loadIntelStatsRow();
if (!ok) return;
await loadIntelCompanies();
queryApplyToInputs({
"i-company": "company_id",
"i-sort": "sort",
});
predictionsOffset = parseInt(queryGet("offset"), 10) || 0;
loadPredictions();
});