Skip to content

Commit

Permalink
Persist setting with session storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Jul 5, 2024
1 parent efbc1cd commit 5df1d0f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion public/js/search.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*global basePath */
function setupSearch() {
let creatorsVisible = false;
let creatorsVisible = sessionStorage.getItem("creators_visible") === "1";
let creatorsLoading = false;
const loadCreators = async function () {
if (!creatorsLoading) {
Expand All @@ -24,12 +24,19 @@ function setupSearch() {
};
}
};
if (creatorsVisible) {
loadCreators();
}
document.querySelectorAll('.search-controls').forEach((element) => {
element.classList.remove('hidden');
});
document.querySelectorAll('.creator-toggle').forEach((element) => {
if (creatorsVisible) {
element.checked = true;
}
element.addEventListener('change', (event) => {
creatorsVisible = element.checked;
sessionStorage.setItem("creators_visible", creatorsVisible ? "1" : "0");
if (creatorsVisible) {
document.querySelectorAll('.creators[data-loaded="1"]').forEach((element) => {
element.classList.remove('hidden');
Expand Down

0 comments on commit 5df1d0f

Please sign in to comment.