Skip to content

Commit

Permalink
Support showing/hiding game divs based on range value for game
Browse files Browse the repository at this point in the history
  • Loading branch information
LegendaryLinux committed Feb 23, 2024
1 parent 9c61e7b commit 0dde475
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions WebHostLib/static/assets/weightedOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ window.addEventListener('load', () => {
if (evt.target.type === 'range') {
// Update span containing range value. All ranges have a corresponding `{rangeId}-value` span
document.getElementById(`${evt.target.id}-value`).innerText = evt.target.value;

// If the changed option was the name of a game, determine whether to show or hide that game's div
if (evt.target.id.startsWith('game||')) {
const gameName = evt.target.id.split('||')[1];
const gameDiv = document.getElementById(`${gameName}-container`);
if (evt.target.value > 0) {
gameDiv.classList.remove('hidden');
} else {
gameDiv.classList.add('hidden');
}
}
}
});

Expand Down
4 changes: 4 additions & 0 deletions WebHostLib/static/styles/weightedOptions/weightedOptions.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions WebHostLib/static/styles/weightedOptions/weightedOptions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ html{
}
}

.hidden{
display: none;
}

@media all and (max-width: 1000px), all and (orientation: portrait){
#weighted-options .game-options{
justify-content: flex-start;
Expand Down
2 changes: 1 addition & 1 deletion WebHostLib/templates/weightedOptions/weightedOptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h2>Game Select</h2>
<div id="games-wrapper">
{% for world_name, world in worlds|dictsort %}
{% if not world.hidden and world.web.options_page == True %}
<div class="world-container">
<div id="{{ world_name }}-container" class="world-container hidden">
<h2 class="world-name">
<label for="{{ world_name }}">
<span class="world-collapse-arrow"></span>
Expand Down

0 comments on commit 0dde475

Please sign in to comment.