add filtering and sorting features; enhance events and articles pages with URL state persistence
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user