feat(ui): add a Custom… option for manual lossy bitrate entry

Keeps the reference presets (96/128/192/256/320) but adds "Custom…", which
reveals a number input so you can type any minimum bitrate. addRankedTarget
reads the manual value when the dropdown is on Custom.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
dev 2026-06-24 23:30:27 +02:00
parent 4d287c9699
commit df4ef99389
2 changed files with 17 additions and 2 deletions

View file

@ -5087,14 +5087,19 @@
</select>
</span>
<span class="rt-lossy-fields" style="display:none;">
<select id="rt-add-bitrate" title="Minimum bitrate">
<select id="rt-add-bitrate" title="Minimum bitrate" onchange="onRtBitrateChange()">
<option value="">Any bitrate</option>
<option value="96">≥ 96 kbps</option>
<option value="128">≥ 128 kbps</option>
<option value="192">≥ 192 kbps</option>
<option value="256">≥ 256 kbps</option>
<option value="320" selected>≥ 320 kbps</option>
<option value="custom">Custom…</option>
</select>
<label class="rt-inline-label" id="rt-add-bitrate-custom-wrap" style="display:none;">
<input type="number" id="rt-add-bitrate-custom" min="0" max="5000" step="1" value="320" style="width:72px;"
autocomplete="off" data-bwignore="" data-1p-ignore="" data-lpignore="true"> kbps
</label>
</span>
<button type="button" class="rt-add-btn" onclick="addRankedTarget()">+ Add target</button>
</div>

View file

@ -2085,6 +2085,15 @@ function onRtAddFormatChange() {
const lyFields = document.querySelector('.rt-lossy-fields');
if (llFields) llFields.style.display = lossless ? '' : 'none';
if (lyFields) lyFields.style.display = lossless ? 'none' : '';
onRtBitrateChange(); // keep the custom-bitrate field in sync
}
// Reveal the manual bitrate input only when the dropdown is on "Custom…".
function onRtBitrateChange() {
const wrap = document.getElementById('rt-add-bitrate-custom-wrap');
if (!wrap) return;
const isCustom = document.getElementById('rt-add-bitrate')?.value === 'custom';
wrap.style.display = isCustom ? '' : 'none';
}
function addRankedTarget() {
@ -2098,7 +2107,8 @@ function addRankedTarget() {
if (bd) constraints.bit_depth = parseInt(bd, 10);
if (sr) constraints.min_sample_rate = parseInt(sr, 10);
} else {
const br = document.getElementById('rt-add-bitrate')?.value;
let br = document.getElementById('rt-add-bitrate')?.value;
if (br === 'custom') br = document.getElementById('rt-add-bitrate-custom')?.value;
if (br) constraints.min_bitrate = parseInt(br, 10);
}