Skip to content

Commit

Permalink
Add sticky weather (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
will-jj authored Jan 27, 2025
1 parent e6e4ddb commit 2b07c2c
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 13 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"GEN9BABYRANDOMBATTLE": false,
"getSelectedTiers": false,
"stickyMoves": false,
"stickyWeather": false,
"allPokemon": false,
"loadCustomList": false,
"loadDefaultLists": false,
Expand Down
8 changes: 8 additions & 0 deletions src/css/dark-theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,11 @@ input.select2-input {
*/
background: url('../js/vendor/select2/select2.png') no-repeat 100% -22px, var(--background);
}

.locked-move:checked + .btn {
background: #00867b;
}

.locked-weather:checked + .btn {
background: #00867b;
}
4 changes: 4 additions & 0 deletions src/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ th {
background: #ffff99;
}

.locked-weather:checked + .btn {
background: #ffff99;
}

.genSelection, .notationSelection, .modeSelection {
display: inline-block;
position: relative;
Expand Down
26 changes: 13 additions & 13 deletions src/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -739,41 +739,41 @@
<div aria-labelledby="selectWeatherInstruction" role="radiogroup">
<span class="visually-hidden" id="selectWeatherInstruction">Select the current weather condition.</span>
<div class="gen-specific g3 g4 g5 g6 g7 g8 g9" style="width: 22.2em; margin: 5px auto;" title="Select the current weather condition.">
<input class="visually-hidden calc-trigger" type="radio" name="weather" value="" id="clear" checked="checked" />
<input class="weather visually-hidden calc-trigger" type="radio" name="weather" value="" id="clear" checked="checked" />
<label class="btn btn-small btn-left" for="clear">None</label>
<input class="visually-hidden calc-trigger" type="radio" name="weather" value="Sun" id="sun" />
<input class="weather visually-hidden calc-trigger" type="radio" name="weather" value="Sun" id="sun" />
<label class="btn btn-small btn-mid" for="sun">Sun</label>
<input class="visually-hidden calc-trigger" type="radio" name="weather" value="Rain" id="rain" />
<input class="weather visually-hidden calc-trigger" type="radio" name="weather" value="Rain" id="rain" />
<label class="btn btn-small btn-mid" for="rain">Rain</label>
<input class="visually-hidden calc-trigger" type="radio" name="weather" value="Sand" id="sand" />
<input class="weather visually-hidden calc-trigger" type="radio" name="weather" value="Sand" id="sand" />
<label class="btn btn-small btn-mid" for="sand">Sand</label>
<span class="gen-specific g3 g4 g5 g6 g7 g8">
<input class="visually-hidden calc-trigger" type="radio" name="weather" value="Hail" id="hail" />
<input class="weather visually-hidden calc-trigger" type="radio" name="weather" value="Hail" id="hail" />
<label class="btn btn-small btn-right" for="hail">Hail</label>
</span>
<span class="gen-specific g9">
<input class="visually-hidden calc-trigger" type="radio" name="weather" value="Snow" id="snow" />
<input class="weather visually-hidden calc-trigger" type="radio" name="weather" value="Snow" id="snow" />
<label class="btn btn-small btn-right" for="snow">Snow</label>
</span>
</div>
<div class="gen-specific g6 g7 g8 g9" title="Select the current weather condition.">
<input class="visually-hidden calc-trigger" type="radio" name="weather" value="Harsh Sunshine" id="harsh-sunshine" />
<input class="weather visually-hidden calc-trigger" type="radio" name="weather" value="Harsh Sunshine" id="harsh-sunshine" />
<label class="btn btn-xxxwide btn-left" for="harsh-sunshine">Harsh Sunshine</label>
<input class="visually-hidden calc-trigger" type="radio" name="weather" value="Heavy Rain" id="heavy-rain" />
<input class="weather visually-hidden calc-trigger" type="radio" name="weather" value="Heavy Rain" id="heavy-rain" />
<label class="btn btn-xxxwide btn-mid" for="heavy-rain">Heavy Rain</label>
<input class="visually-hidden calc-trigger" type="radio" name="weather" value="Strong Winds" id="strong-winds" />
<input class="weather visually-hidden calc-trigger" type="radio" name="weather" value="Strong Winds" id="strong-winds" />
<label class="btn btn-xxxwide btn-right" for="strong-winds">Strong Winds</label>
</div>
</div>
<div aria-labelledby="selectGscWeatherInstruction" class="gen-specific g2 hide" role="radiogroup" style="width: 17.8em; margin: 0 auto 5px;" title="Select the current weather condition.">
<span class="visually-hidden" id="selectGscWeatherInstruction">Select the current weather condition.</span>
<input class="visually-hidden calc-trigger" type="radio" name="gscWeather" value="" id="gscClear" checked="checked" />
<input class="weather visually-hidden calc-trigger" type="radio" name="gscWeather" value="" id="gscClear" checked="checked" />
<label class="btn btn-small btn-left" for="gscClear">None</label>
<input class="visually-hidden calc-trigger" type="radio" name="gscWeather" value="Sun" id="gscSun" />
<input class="weather visually-hidden calc-trigger" type="radio" name="gscWeather" value="Sun" id="gscSun" />
<label class="btn btn-small btn-mid" for="gscSun">Sun</label>
<input class="visually-hidden calc-trigger" type="radio" name="gscWeather" value="Rain" id="gscRain" />
<input class="weather visually-hidden calc-trigger" type="radio" name="gscWeather" value="Rain" id="gscRain" />
<label class="btn btn-small btn-mid" for="gscRain">Rain</label>
<input class="visually-hidden calc-trigger" type="radio" name="gscWeather" value="Sand" id="gscSand" />
<input class="weather visually-hidden calc-trigger" type="radio" name="gscWeather" value="Sand" id="gscSand" />
<label class="btn btn-small btn-right" for="gscSand">Sand</label>
</div>
<div class="gen-specific g5 g6 g7 g8 g9" style="width: 22.2em; margin: 5px auto; display: inline-block;">
Expand Down
25 changes: 25 additions & 0 deletions src/js/shared_controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ $("input[name='weather']").change(function () {
var lastManualWeather = "";
var lastAutoWeather = ["", ""];
function autosetWeather(ability, i) {

if ($('.locked-weather').length) {
return;
}

var currentWeather = $("input:radio[name='weather']:checked").val();
if (lastAutoWeather.indexOf(currentWeather) === -1) {
lastManualWeather = currentWeather;
Expand Down Expand Up @@ -1576,6 +1581,26 @@ function getSelectOptions(arr, sort, defaultOption) {
}
return r;
}

var stickyWeather = (function () {
var lastClicked = '';
$(".weather").click(function () {
if (this.id === lastClicked) {
$(this).toggleClass("locked-weather");
} else {
$('.locked-weather').removeClass('locked-weather');
}
lastClicked = this.id;
});

return {
clearStickyWeather: function () {
lastClicked = null;
$('.locked-weather').removeClass('locked-weather');
}
};
})();

var stickyMoves = (function () {
var lastClicked = 'resultMoveL1';
$(".result-move").click(function () {
Expand Down

0 comments on commit 2b07c2c

Please sign in to comment.