Skip to content

Commit

Permalink
2024/03/23 storyinfo view mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sctop committed Mar 23, 2024
1 parent fecb0de commit d82bf63
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,8 @@ code {
}
a > code {
color: inherit;
}

.story-segment-data {
display: none;
}
40 changes: 40 additions & 0 deletions static/js/story_view_mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function setDefaultStoryViewMode() {
const selected_option = document.getElementById("story-view-mode-switcher").value;
localStorage.setItem("story_view_mode", selected_option.toString());
}

function setStoryViewModeSwitchStatus() {
if (localStorage.getItem("story_view_mode") === null) {
setDefaultStoryViewMode();
}

document.getElementById("story-view-mode-switcher").value = localStorage.getItem("story_view_mode");

showStoryByViewMode();
}

function setStoryViewMode(option_element) {
const selected_option = option_element.value;
localStorage.setItem("story_view_mode", selected_option.toString());

showStoryByViewMode();
}

function showStoryByViewMode() {
let preference = localStorage.getItem("story_view_mode");
if (preference === null) {
setDefaultStoryViewMode();
preference = localStorage.getItem("story_view_mode");
}

let storySegs = document.getElementsByClassName("story-segment-data");
for (let i = 0; i < storySegs.length; i++) {
const curr = storySegs[i];
if (preference === "all") {
curr.style.display = "block";
}
else {
curr.style.display = "none";
}
}
}

0 comments on commit d82bf63

Please sign in to comment.