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