Skip to content

Commit e0b0851

Browse files
Support version filter URL parameters
1 parent 4bb4cc6 commit e0b0851

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

util/gh-pages/script.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,16 @@ function updateVersionFilters(elem, skipLintsFiltering) {
435435
console.error(`Failed to get version number from "${value}"`);
436436
return;
437437
}
438+
439+
const counter = document.querySelector("#version-filter .badge");
440+
let count = 0;
441+
onEachLazy(document.querySelectorAll("#version-filter input"), el => {
442+
if (el.value.trim().length !== 0) {
443+
count += 1;
444+
}
445+
});
446+
counter.innerText = count;
447+
438448
const comparisonKind = elem.getAttribute("data-value");
439449
if (filters.version_filter[comparisonKind] !== value) {
440450
filters.version_filter[comparisonKind] = value;
@@ -455,13 +465,15 @@ function clearVersionFilters() {
455465
filters.version_filter[comparisonKind] = null;
456466
}
457467
});
468+
document.querySelector("#version-filter .badge").innerText = 0;
458469
if (needsUpdate) {
459470
filters.filterLints();
460471
}
461472
}
462473

463474
function resetGroupsToDefault() {
464475
let needsUpdate = false;
476+
let count = 0;
465477

466478
onEachLazy(document.querySelectorAll("#lint-groups-selector input"), el => {
467479
const key = el.getAttribute("data-value");
@@ -471,7 +483,11 @@ function resetGroupsToDefault() {
471483
el.checked = value;
472484
needsUpdate = true;
473485
}
486+
if (value) {
487+
count += 1;
488+
}
474489
});
490+
document.querySelector("#lint-groups .badge").innerText = count;
475491
if (needsUpdate) {
476492
filters.filterLints();
477493
}
@@ -592,6 +608,7 @@ function parseURLFilters() {
592608
for (const [kind, value] of settings) {
593609
const elem = document.querySelector(
594610
`#version-filter input[data-value="${VERSIONS_CORRESPONDANCE[kind]}"]`);
611+
elem.value = value;
595612
updateVersionFilters(elem, true);
596613
}
597614
}

0 commit comments

Comments
 (0)