feat: silent success scan, error beep on fail and duplicate
This commit is contained in:
@@ -247,6 +247,7 @@ function processSmartScan(barcode, confirm = false) {
|
|||||||
|
|
||||||
// --- 1. HANDLE DUPLICATE CONFIRMATION ---
|
// --- 1. HANDLE DUPLICATE CONFIRMATION ---
|
||||||
if (data.needs_confirmation) {
|
if (data.needs_confirmation) {
|
||||||
|
playErrorBeep();
|
||||||
isSmartScan = true;
|
isSmartScan = true;
|
||||||
currentDupKeyValue = barcode;
|
currentDupKeyValue = barcode;
|
||||||
if (data.duplicate_status === 'dup_same_session') {
|
if (data.duplicate_status === 'dup_same_session') {
|
||||||
@@ -296,27 +297,23 @@ function processSmartScan(barcode, confirm = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- 3. STANDARD SUCCESS/FAIL ---
|
// --- 3. STANDARD SUCCESS/FAIL ---
|
||||||
if(smartInput) {
|
|
||||||
smartInput.value = '';
|
|
||||||
smartInput.focus();
|
|
||||||
}
|
|
||||||
feedbackArea.style.display = 'block';
|
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
feedbackArea.style.background = 'rgba(40, 167, 69, 0.2)';
|
|
||||||
feedbackArea.style.border = '1px solid #28a745';
|
|
||||||
feedbackText.style.color = '#28a745';
|
|
||||||
feedbackText.textContent = data.message;
|
|
||||||
if (data.detail_id && data.data) {
|
if (data.detail_id && data.data) {
|
||||||
addScanToList(data.detail_id, data.data, data.data.duplicate_status);
|
addScanToList(data.detail_id, data.data, data.data.duplicate_status);
|
||||||
}
|
}
|
||||||
setTimeout(() => feedbackArea.style.display = 'none', 1000);
|
feedbackArea.style.display = 'none';
|
||||||
}
|
if(smartInput) {
|
||||||
else {
|
smartInput.value = '';
|
||||||
|
smartInput.focus();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
playErrorBeep();
|
||||||
|
feedbackArea.style.display = 'block';
|
||||||
feedbackArea.style.background = 'rgba(220, 53, 69, 0.2)';
|
feedbackArea.style.background = 'rgba(220, 53, 69, 0.2)';
|
||||||
feedbackArea.style.border = '1px solid #dc3545';
|
feedbackArea.style.border = '1px solid #dc3545';
|
||||||
feedbackText.style.color = '#dc3545';
|
feedbackText.style.color = '#dc3545';
|
||||||
feedbackText.textContent = data.message;
|
feedbackText.textContent = data.message;
|
||||||
|
if(smartInput) smartInput.focus();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
@@ -324,7 +321,7 @@ function processSmartScan(barcode, confirm = false) {
|
|||||||
console.error(err); // Log it, don't popup alert to annoy user
|
console.error(err); // Log it, don't popup alert to annoy user
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Function to handle the "Save" click from the Details Modal
|
|
||||||
// Function to handle the "Save" click from the Details Modal
|
// Function to handle the "Save" click from the Details Modal
|
||||||
function saveSmartScanData() {
|
function saveSmartScanData() {
|
||||||
// 1. Validate we have the original barcode
|
// 1. Validate we have the original barcode
|
||||||
@@ -380,6 +377,25 @@ function resetSmartScan() {
|
|||||||
document.getElementById('smartScanner').focus();
|
document.getElementById('smartScanner').focus();
|
||||||
document.getElementById('routerFeedback').style.display = 'none';
|
document.getElementById('routerFeedback').style.display = 'none';
|
||||||
}
|
}
|
||||||
|
// --- ERROR BEEP ---
|
||||||
|
function playErrorBeep() {
|
||||||
|
try {
|
||||||
|
const ctx = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
|
const oscillator = ctx.createOscillator();
|
||||||
|
const gainNode = ctx.createGain();
|
||||||
|
oscillator.connect(gainNode);
|
||||||
|
gainNode.connect(ctx.destination);
|
||||||
|
oscillator.type = 'square';
|
||||||
|
oscillator.frequency.setValueAtTime(520, ctx.currentTime);
|
||||||
|
gainNode.gain.setValueAtTime(0.3, ctx.currentTime);
|
||||||
|
gainNode.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + 0.4);
|
||||||
|
oscillator.start(ctx.currentTime);
|
||||||
|
oscillator.stop(ctx.currentTime + 0.4);
|
||||||
|
} catch(e) {
|
||||||
|
console.warn('Audio not available:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Standard variables
|
// Standard variables
|
||||||
let currentDupKeyValue = '';
|
let currentDupKeyValue = '';
|
||||||
let currentDuplicateStatus = '';
|
let currentDuplicateStatus = '';
|
||||||
|
|||||||
Reference in New Issue
Block a user