Add end-page control for inclusive print ranges
Operators can print a middle slice of labels, not only resume from a start page through the end. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -57,7 +57,7 @@
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.preview-controls .start-from {
|
||||
.preview-controls .page-range {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
@@ -67,7 +67,7 @@
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.preview-controls .start-from input {
|
||||
.preview-controls .page-range input {
|
||||
width: 4.5em;
|
||||
padding: 8px 6px;
|
||||
font-size: 16px;
|
||||
@@ -179,9 +179,11 @@
|
||||
{{ order.canister_count }} Canisters ({{ order.canister_pages }} Pages) |
|
||||
{{ order.box_count }} Boxes ({{ order.box_pages }} Pages)
|
||||
</p>
|
||||
<label class="start-from" for="start-from">
|
||||
Start from page
|
||||
<label class="page-range">
|
||||
Pages
|
||||
<input id="start-from" type="number" min="1" max="{{ pages|length }}" value="1" {% if not pages %}disabled{% endif %}>
|
||||
–
|
||||
<input id="end-at" type="number" min="1" max="{{ pages|length }}" value="{{ pages|length }}" {% if not pages %}disabled{% endif %}>
|
||||
/ {{ pages|length }}
|
||||
</label>
|
||||
<button id="btn-print" type="button" disabled>🖨️ Print Now</button>
|
||||
@@ -212,6 +214,7 @@
|
||||
const varsEl = document.getElementById('calibration-vars');
|
||||
const btn = document.getElementById('btn-print');
|
||||
const startInput = document.getElementById('start-from');
|
||||
const endInput = document.getElementById('end-at');
|
||||
const pages = document.querySelectorAll('.a4-page');
|
||||
const total = pages.length;
|
||||
|
||||
@@ -234,7 +237,7 @@
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
function clampStart(n) {
|
||||
function clampPage(n) {
|
||||
if (!total) return 1;
|
||||
n = parseInt(n, 10);
|
||||
if (isNaN(n) || n < 1) return 1;
|
||||
@@ -243,20 +246,23 @@
|
||||
}
|
||||
|
||||
function applySkip() {
|
||||
const start = clampStart(startInput.value);
|
||||
let start = clampPage(startInput.value);
|
||||
let end = clampPage(endInput.value);
|
||||
if (start > end) end = start;
|
||||
startInput.value = start;
|
||||
endInput.value = end;
|
||||
pages.forEach(function (el) {
|
||||
const pageNum = parseInt(el.getAttribute('data-page'), 10);
|
||||
el.classList.toggle('skip-print', pageNum < start);
|
||||
el.classList.toggle('skip-print', pageNum < start || pageNum > end);
|
||||
});
|
||||
}
|
||||
|
||||
function seedFromQuery() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const from = params.get('from');
|
||||
if (from != null) {
|
||||
startInput.value = clampStart(from);
|
||||
}
|
||||
const to = params.get('to');
|
||||
if (from != null) startInput.value = clampPage(from);
|
||||
if (to != null) endInput.value = clampPage(to);
|
||||
applySkip();
|
||||
}
|
||||
|
||||
@@ -270,6 +276,8 @@
|
||||
|
||||
startInput.addEventListener('change', applySkip);
|
||||
startInput.addEventListener('input', applySkip);
|
||||
endInput.addEventListener('change', applySkip);
|
||||
endInput.addEventListener('input', applySkip);
|
||||
seedFromQuery();
|
||||
|
||||
fetch('/api/calibration', { cache: 'no-store' })
|
||||
|
||||
Reference in New Issue
Block a user