Skip to content

Commit a280391

Browse files
Make the index remember the recent/grouped view (w3c#13580)
1 parent d583cff commit a280391

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

bin/build-index.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ def escape_html(text):
644644
});
645645
646646
function sortRecent() {
647+
window.localStorage.setItem('index-sort', 'recent');
647648
specList.querySelectorAll('.group-header').forEach(function(h) { h.remove(); });
648649
specs.sort(function(a, b) {
649650
return parseInt(b.dataset.ts) - parseInt(a.dataset.ts);
@@ -657,6 +658,7 @@ def escape_html(text):
657658
}
658659
659660
function sortGrouped() {
661+
window.localStorage.setItem('index-sort', 'grouped');
660662
specList.querySelectorAll('.group-header').forEach(function(h) { h.remove(); });
661663
specs.sort(function(a, b) {
662664
var c = a.dataset.shortname.localeCompare(b.dataset.shortname);
@@ -685,6 +687,9 @@ def escape_html(text):
685687
686688
btnRecent.addEventListener('click', sortRecent);
687689
btnGrouped.addEventListener('click', sortGrouped);
690+
if (window.localStorage.getItem('index-sort') === 'grouped') {
691+
sortGrouped();
692+
}
688693
689694
// Mobile: tap spec header to expand/collapse (accordion)
690695
specs.forEach(function(el) {

0 commit comments

Comments
 (0)