Generic Commit; Most likely a fix or small feature
This commit is contained in:
@@ -879,6 +879,16 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
function waitForElement(id: string, callback: Function) {
|
||||
const interval = setInterval(() => {
|
||||
const element = document.getElementById(id);
|
||||
if (element) {
|
||||
clearInterval(interval);
|
||||
callback(element);
|
||||
}
|
||||
}, 100); // Check every 100ms
|
||||
}
|
||||
|
||||
async function startScanner() {
|
||||
try {
|
||||
if (!window.ZXing) {
|
||||
@@ -894,6 +904,7 @@ body {
|
||||
codeReader = new window.ZXing.BrowserMultiFormatReader();
|
||||
|
||||
document.getElementById('start-scanner-btn').addEventListener('click', () => {
|
||||
waitForElement('scanner-video', () => {
|
||||
codeReader.decodeFromVideoDevice(undefined, 'scanner-video', (result: unknown, err: unknown) => {
|
||||
if (result) {
|
||||
const code = result.getText();
|
||||
@@ -903,6 +914,7 @@ body {
|
||||
searchProduct(code);
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
} catch (err) {
|
||||
console.error("Scanner error:", err);
|
||||
|
||||
Reference in New Issue
Block a user