From 79130dece718368575b920f6ca852777e306db9c Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Fri, 21 Mar 2025 17:39:43 +0100 Subject: [PATCH] Review --- .../viewjs/components/camerabarcodescanner.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/public/viewjs/components/camerabarcodescanner.js b/public/viewjs/components/camerabarcodescanner.js index 56c21d14..d3da448d 100644 --- a/public/viewjs/components/camerabarcodescanner.js +++ b/public/viewjs/components/camerabarcodescanner.js @@ -47,7 +47,7 @@ Grocy.Components.CameraBarcodeScanner.CheckCapabilities = async function() document.querySelector('.camerabarcodescanner-modal .modal-footer').setAttribute('style', 'flex;'); } - // Reduce the height of the video, if it's higher than then the viewport + // Reduce the height of the video if it's higher than the viewport if (!Grocy.Components.CameraBarcodeScanner.LiveVideoSizeAdjusted) { var bc = document.getElementById('camerabarcodescanner-container'); @@ -72,9 +72,6 @@ Grocy.Components.CameraBarcodeScanner.CheckCapabilities = async function() Grocy.Components.CameraBarcodeScanner.StartScanning = function() { - Grocy.Components.CameraBarcodeScanner.DecodedCodesCount = 0; - Grocy.Components.CameraBarcodeScanner.DecodedCodesErrorCount = 0; - Grocy.Components.CameraBarcodeScanner.Scanner.decodeFromVideoDevice( window.localStorage.getItem('cameraId'), document.querySelector("#camerabarcodescanner-livestream"), @@ -85,7 +82,6 @@ Grocy.Components.CameraBarcodeScanner.StartScanning = function() return; } - Grocy.Components.CameraBarcodeScanner.DecodedCodesCount++; Grocy.Components.CameraBarcodeScanner.StopScanning(); $(document).trigger("Grocy.BarcodeScanned", [result.getText(), Grocy.Components.CameraBarcodeScanner.CurrentTarget]); @@ -121,8 +117,6 @@ Grocy.Components.CameraBarcodeScanner.StopScanning = function() { Grocy.Components.CameraBarcodeScanner.Scanner.reset(); - Grocy.Components.CameraBarcodeScanner.DecodedCodesCount = 0; - Grocy.Components.CameraBarcodeScanner.DecodedCodesErrorCount = 0; Grocy.Components.CameraBarcodeScanner.LiveVideoSizeAdjusted = false; Grocy.Components.CameraBarcodeScanner.CameraSelectLoaded = false; Grocy.Components.CameraBarcodeScanner.TorchIsOn = false; @@ -146,6 +140,7 @@ Grocy.Components.CameraBarcodeScanner.TorchToggle = function(track) $(document).on("click", "#camerabarcodescanner-start-button", async function(e) { e.preventDefault(); + var inputElement = $(e.currentTarget).prev(); if (inputElement.hasAttr("disabled")) { @@ -184,7 +179,7 @@ $(document).on("click", "#camerabarcodescanner-start-button", async function(e) }); // Add camera select to existing dialog - dialog.find('.bootbox-body').append('
'); + dialog.find('.bootbox-body').append('
'); var cameraSelect = document.querySelector('.cameraSelect'); cameraSelect.onchange = function() { @@ -204,16 +199,14 @@ Grocy.Components.CameraBarcodeScanner.Init = function() return; } - var scannerHints = new Map(); - scannerHints.set(ZXing.DecodeHintType.POSSIBLE_FORMATS, [ + Grocy.Components.CameraBarcodeScanner.Scanner = new ZXing.BrowserMultiFormatReader(new Map().set(ZXing.DecodeHintType.POSSIBLE_FORMATS, [ ZXing.BarcodeFormat.EAN_8, ZXing.BarcodeFormat.EAN_13, ZXing.BarcodeFormat.CODE_39, ZXing.BarcodeFormat.CODE_128, ZXing.BarcodeFormat.DATA_MATRIX, ZXing.BarcodeFormat.QR_CODE, - ]) - Grocy.Components.CameraBarcodeScanner.Scanner = new ZXing.BrowserMultiFormatReader(scannerHints); + ])); $(".barcodescanner-input:visible").each(function() {