Automatically set selected current one on highscores filters

This commit is contained in:
slawkens 2024-11-07 14:44:08 +01:00
parent c49c9d99a9
commit e96227fbe4
2 changed files with 7 additions and 5 deletions

View File

@ -35,11 +35,12 @@ $settingHighscoresVocationBox = setting('core.highscores_vocation_box');
$configVocations = config('vocations');
$configVocationsAmount = config('vocations_amount');
if($settingHighscoresVocationBox && $vocation !== 'all')
{
$vocationId = null;
if($settingHighscoresVocationBox && $vocation !== 'all') {
foreach($configVocations as $id => $name) {
if(strtolower($name) == $vocation) {
$add_vocs = array($id);
$vocationId = $id;
$add_vocs = [$id];
$i = $id + $configVocationsAmount;
while(isset($configVocations[$i])) {
@ -287,6 +288,7 @@ $twig->display('highscores.html.twig', [
'skillName' => ($skill == SKILL_FRAGS ? 'Frags' : ($skill == SKILL_BALANCE ? 'Balance' : getSkillName($skill))),
'levelName' => ($skill != SKILL_FRAGS && $skill != SKILL_BALANCE ? 'Level' : ($skill == SKILL_BALANCE ? 'Balance' : 'Frags')),
'vocation' => $vocation !== 'all' ? $vocation : null,
'vocationId' => $vocationId,
'types' => $types,
'linkPreviousPage' => $linkPreviousPage,
'linkNextPage' => $linkNextPage,

View File

@ -11,7 +11,7 @@
<select onchange="location = this.value;" aria-label="skillFilter" id="skillFilter">
{% set i = 0 %}
{% for link, name in types %}
<option value="{{ getLink('highscores') }}/{{ link }}{% if vocation is not null %}{{ vocation }}{% endif %}" class="size_xs">{{ name }}</option>
<option value="{{ getLink('highscores') }}/{{ link }}/{% if vocation is not null %}{{ vocation }}{% endif %}" class="size_xs" {% if list is not null and list == link %}selected{% endif %}>{{ name }}</option>
{% endfor %}
</select>
</td>
@ -21,7 +21,7 @@
<option value="{{ getLink('highscores') }}/{{ list }}" class="size_xs">[ALL]</option>
{% set i = 0 %}
{% for i in 1..config.vocations_amount %}
<option value="{{ getLink('highscores') }}/{{ list }}/{{ config.vocations[i]|lower }}" class="size_xs">{{ config.vocations[i]}}</option>
<option value="{{ getLink('highscores') }}/{{ list }}/{{ config.vocations[i]|lower }}" class="size_xs" {% if vocationId is not null and vocationId == i %}selected{% endif %}>{{ config.vocations[i]}}</option>
{% endfor %}
</select>
</td>