Hide min/max depth inputs when Randomize is toggled on

- Settings modal: wrap min/max selects in #pw_sm_surprise_range_rows div;
  show when randomize is on, hide when off
- Settings modal: add #pw_sm_surprise_fixed_hint showing fixed depth value
  when randomize is off
- settings.html panel: same treatment with #pw_surprise_range_rows and
  #pw_surprise_fixed_hint / #pw_surprise_fixed_depth_label
- Generic toggle handler: show/hide modal range rows on surprise_randomize toggle
- bindSettingsPanelEvents: show/hide panel range rows on randomize change
- syncSettingsToModal: sync range row visibility
- syncSettingsToPanel: sync range row visibility
This commit is contained in:
kiloconnect[bot] 2026-02-27 22:49:53 +00:00
parent 8a53b6dea2
commit 2a86ec4e82
2 changed files with 105 additions and 55 deletions

View file

@ -2508,24 +2508,31 @@ GUIDELINES:
<span class="pw_setting_label"><i class="fa-solid fa-shuffle"></i> Randomize depth</span>
<div class="pw_toggle ${settings.surprise_randomize ? 'active' : ''}" data-setting="surprise_randomize"></div>
</div>
<p class="pw_setting_hint" style="margin: 2px 0 10px 0; font-size: 0.78rem; opacity: 0.8;">
When on, picks a random depth in the range below. When off, uses the minimum value as a fixed depth.
</p>
<div class="pw_setting_row pw_surprise_depth_range_row">
<span class="pw_setting_label"><i class="fa-solid fa-clock-rotate-left"></i> Min messages</span>
<div class="pw_setting_control">
<select id="pw_sm_surprise_depth_min" class="pw_select text_pole">
${[2,3,4,5,6,7,8,9,10,11,12].map(n => `<option value="${n}" ${settings.surprise_depth_min == n ? 'selected' : ''}>${n}</option>`).join('')}
</select>
<div id="pw_sm_surprise_range_rows" style="${settings.surprise_randomize ? '' : 'display:none;'}">
<p class="pw_setting_hint" style="margin: 2px 0 10px 0; font-size: 0.78rem; opacity: 0.8;">
Picks a random depth within this range each time.
</p>
<div class="pw_setting_row pw_surprise_depth_range_row">
<span class="pw_setting_label"><i class="fa-solid fa-clock-rotate-left"></i> Min messages</span>
<div class="pw_setting_control">
<select id="pw_sm_surprise_depth_min" class="pw_select text_pole">
${[2,3,4,5,6,7,8,9,10,11,12].map(n => `<option value="${n}" ${settings.surprise_depth_min == n ? 'selected' : ''}>${n}</option>`).join('')}
</select>
</div>
</div>
<div class="pw_setting_row pw_surprise_depth_range_row">
<span class="pw_setting_label"><i class="fa-solid fa-clock-rotate-left"></i> Max messages</span>
<div class="pw_setting_control">
<select id="pw_sm_surprise_depth_max" class="pw_select text_pole">
${[2,3,4,5,6,7,8,9,10,11,12].map(n => `<option value="${n}" ${settings.surprise_depth_max == n ? 'selected' : ''}>${n}</option>`).join('')}
</select>
</div>
</div>
</div>
<div class="pw_setting_row pw_surprise_depth_range_row">
<span class="pw_setting_label"><i class="fa-solid fa-clock-rotate-left"></i> Max messages</span>
<div class="pw_setting_control">
<select id="pw_sm_surprise_depth_max" class="pw_select text_pole">
${[2,3,4,5,6,7,8,9,10,11,12].map(n => `<option value="${n}" ${settings.surprise_depth_max == n ? 'selected' : ''}>${n}</option>`).join('')}
</select>
</div>
<div id="pw_sm_surprise_fixed_hint" style="${settings.surprise_randomize ? 'display:none;' : ''}">
<p class="pw_setting_hint" style="margin: 2px 0 0; font-size: 0.78rem; opacity: 0.8;">
Uses a fixed depth of <strong>${settings.surprise_depth_min}</strong> messages.
</p>
</div>
</div>
@ -2584,6 +2591,18 @@ GUIDELINES:
jQuery('.pw_toggle[data-setting="insert_type_ooc"]').removeClass('active');
}
// Surprise Me: show/hide range rows based on randomize toggle
if (setting === 'surprise_randomize') {
if (settings.surprise_randomize) {
jQuery('#pw_sm_surprise_range_rows').show();
jQuery('#pw_sm_surprise_fixed_hint').hide();
} else {
jQuery('#pw_sm_surprise_range_rows').hide();
jQuery('#pw_sm_surprise_fixed_hint').show();
jQuery('#pw_sm_surprise_fixed_hint p strong').text(settings.surprise_depth_min);
}
}
saveSettings();
syncSettingsToPanel(); // Sync to extension panel (NOW after logic)
});
@ -3637,6 +3656,14 @@ GUIDELINES:
jQuery('#pw_surprise_randomize').prop('checked', settings.surprise_randomize);
jQuery('#pw_surprise_depth_min').val(settings.surprise_depth_min);
jQuery('#pw_surprise_depth_max').val(settings.surprise_depth_max);
if (settings.surprise_randomize) {
jQuery('#pw_surprise_range_rows').show();
jQuery('#pw_surprise_fixed_hint').hide();
} else {
jQuery('#pw_surprise_range_rows').hide();
jQuery('#pw_surprise_fixed_hint').show();
jQuery('#pw_surprise_fixed_depth_label').text(settings.surprise_depth_min);
}
updateProviderVisibility(settings.source);
}
@ -3674,6 +3701,14 @@ GUIDELINES:
jQuery('.pw_toggle[data-setting="surprise_randomize"]').toggleClass('active', settings.surprise_randomize);
jQuery('#pw_sm_surprise_depth_min').val(settings.surprise_depth_min);
jQuery('#pw_sm_surprise_depth_max').val(settings.surprise_depth_max);
if (settings.surprise_randomize) {
jQuery('#pw_sm_surprise_range_rows').show();
jQuery('#pw_sm_surprise_fixed_hint').hide();
} else {
jQuery('#pw_sm_surprise_range_rows').hide();
jQuery('#pw_sm_surprise_fixed_hint').show();
jQuery('#pw_sm_surprise_fixed_hint p strong').text(settings.surprise_depth_min);
}
// Context sources toggles
jQuery('.pw_toggle[data-setting="include_scenario"]').toggleClass('active', settings.include_scenario);
@ -3907,6 +3942,14 @@ GUIDELINES:
// Surprise Me: randomize toggle
jQuery('#pw_surprise_randomize').on('change', function () {
settings.surprise_randomize = this.checked;
if (settings.surprise_randomize) {
jQuery('#pw_surprise_range_rows').show();
jQuery('#pw_surprise_fixed_hint').hide();
} else {
jQuery('#pw_surprise_range_rows').hide();
jQuery('#pw_surprise_fixed_hint').show();
jQuery('#pw_surprise_fixed_depth_label').text(settings.surprise_depth_min);
}
saveSettings();
syncSettingsToModal();
});

View file

@ -232,48 +232,55 @@
<input id="pw_surprise_randomize" type="checkbox" class="checkbox">
<span><i class="fa-solid fa-shuffle"></i> Randomize depth</span>
</label>
<p class="pw_setting_hint" style="margin: 2px 0 8px 0; font-size: 0.78rem; opacity: 0.8;">
When enabled, picks a random depth within the range below. When disabled, uses the minimum as a fixed depth.
</p>
<div class="pw_row_2col" style="margin-top: 4px;">
<div>
<label for="pw_surprise_depth_min" class="pw_input_label">
<i class="fa-solid fa-clock-rotate-left"></i> Min messages
</label>
<select id="pw_surprise_depth_min" class="text_pole pw_select">
<option value="2">2</option>
<option value="3">3</option>
<option value="4" selected>4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
<div>
<label for="pw_surprise_depth_max" class="pw_input_label">
<i class="fa-solid fa-clock-rotate-left"></i> Max messages
</label>
<select id="pw_surprise_depth_max" class="text_pole pw_select">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6" selected>6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<div id="pw_surprise_range_rows" style="margin-top: 4px;">
<p class="pw_setting_hint" style="margin: 2px 0 8px 0; font-size: 0.78rem; opacity: 0.8;">
Picks a random depth within this range each time.
</p>
<div class="pw_row_2col">
<div>
<label for="pw_surprise_depth_min" class="pw_input_label">
<i class="fa-solid fa-clock-rotate-left"></i> Min messages
</label>
<select id="pw_surprise_depth_min" class="text_pole pw_select">
<option value="2">2</option>
<option value="3">3</option>
<option value="4" selected>4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
<div>
<label for="pw_surprise_depth_max" class="pw_input_label">
<i class="fa-solid fa-clock-rotate-left"></i> Max messages
</label>
<select id="pw_surprise_depth_max" class="text_pole pw_select">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6" selected>6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
</div>
</div>
<div id="pw_surprise_fixed_hint" style="display:none; margin-top: 4px;">
<p class="pw_setting_hint" style="margin: 0; font-size: 0.78rem; opacity: 0.8;">
Uses a fixed depth of <strong id="pw_surprise_fixed_depth_label">2</strong> messages.
</p>
</div>
</div>
<hr class="pw_divider">