Add infinity max option for reciprocal scale
This commit is contained in:
@@ -330,9 +330,11 @@
|
||||
<label>Min value</label>
|
||||
<input name="min" type="number" step="any" value="0" required>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="field" id="field-max">
|
||||
<label>Max value</label>
|
||||
<input name="max" type="number" step="any" value="100" required>
|
||||
<input name="max" id="input-max" type="number" step="any" value="100" required>
|
||||
<button type="button" id="btn-inf" style="display:none;font-family:var(--f-mono);font-size:0.65rem;color:var(--muted);background:none;border:none;padding:0;cursor:pointer;text-align:left">set max = ∞</button>
|
||||
<input type="hidden" name="max_is_inf" id="max-is-inf" value="">
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="scale_type" id="scale-type" value="linear">
|
||||
@@ -397,6 +399,31 @@
|
||||
<script>
|
||||
let lastSvg = '';
|
||||
|
||||
function resetInf() {
|
||||
const inp = document.getElementById('input-max');
|
||||
const hidden = document.getElementById('max-is-inf');
|
||||
const btn = document.getElementById('btn-inf');
|
||||
inp.style.display = '';
|
||||
inp.required = true;
|
||||
hidden.value = '';
|
||||
btn.textContent = 'set max = ∞';
|
||||
}
|
||||
|
||||
document.getElementById('btn-inf').addEventListener('click', () => {
|
||||
const inp = document.getElementById('input-max');
|
||||
const hidden = document.getElementById('max-is-inf');
|
||||
const btn = document.getElementById('btn-inf');
|
||||
if (hidden.value === '1') {
|
||||
resetInf();
|
||||
} else {
|
||||
inp.style.display = 'none';
|
||||
inp.required = false;
|
||||
hidden.value = '1';
|
||||
btn.textContent = 'max = ∞ (click to reset)';
|
||||
}
|
||||
doGenerate();
|
||||
});
|
||||
|
||||
async function doGenerate() {
|
||||
const status = document.getElementById('status');
|
||||
status.textContent = 'Generating…';
|
||||
@@ -448,6 +475,14 @@
|
||||
if (!(parseFloat(minInput.value) > 0)) minInput.value = '1';
|
||||
if (!(parseFloat(maxInput.value) > parseFloat(minInput.value))) maxInput.value = String(parseFloat(minInput.value) * 10);
|
||||
}
|
||||
// Show/hide ∞ toggle
|
||||
const infBtn = document.getElementById('btn-inf');
|
||||
if (btn.dataset.scale === 'reciprocal') {
|
||||
infBtn.style.display = '';
|
||||
} else {
|
||||
infBtn.style.display = 'none';
|
||||
resetInf();
|
||||
}
|
||||
}
|
||||
doGenerate();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user