Skip to content

Commit

Permalink
save difficulty preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffrey-wu committed Jul 3, 2023
1 parent d41a353 commit 200cfd0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions client/singleplayer/bonuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ document.getElementById('difficulties').addEventListener('change', function () {
randomQuestions = [];
difficulties = getDropdownValues('difficulties');
loadRandomBonuses(difficulties, validCategories, validSubcategories);
localStorage.setItem('difficultiesBonusSave', JSON.stringify(difficulties));
});


Expand Down Expand Up @@ -491,6 +492,18 @@ window.onload = async () => {
updateStatDisplay();


if (localStorage.getItem('difficultiesBonusSave')) {
difficulties = JSON.parse(localStorage.getItem('difficultiesBonusSave'));
for (let element of document.getElementById('difficulties').children) {
const input = element.querySelector('input');
const difficulty = parseInt(input.value);
if (difficulties.includes(difficulty)) {
element.classList.add('active');
input.checked = true;
}
}
}

if (localStorage.getItem('packetNumberBonusSave')) {
document.getElementById('packet-number').value = localStorage.getItem('packetNumberBonusSave');
}
Expand Down
13 changes: 13 additions & 0 deletions client/singleplayer/tossups.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ document.getElementById('difficulties').addEventListener('change', function () {
randomQuestions = [];
difficulties = getDropdownValues('difficulties');
loadRandomTossups(difficulties, validCategories, validSubcategories);
localStorage.setItem('difficultiesTossupSave', JSON.stringify(difficulties));
});


Expand Down Expand Up @@ -644,6 +645,18 @@ window.onload = async () => {
updateStatDisplay();


if (localStorage.getItem('difficultiesTossupSave')) {
difficulties = JSON.parse(localStorage.getItem('difficultiesTossupSave'));
for (let element of document.getElementById('difficulties').children) {
const input = element.querySelector('input');
const difficulty = parseInt(input.value);
if (difficulties.includes(difficulty)) {
element.classList.add('active');
input.checked = true;
}
}
}

if (localStorage.getItem('packetNumberTossupSave')) {
document.getElementById('packet-number').value = localStorage.getItem('packetNumberTossupSave');
}
Expand Down

0 comments on commit 200cfd0

Please sign in to comment.