Applied VSCode JS formatting settings

This commit is contained in:
Bernd Bestel
2020-08-30 12:18:16 +02:00
parent e0e3212f13
commit 9cea0c77cd
68 changed files with 408 additions and 371 deletions

View File

@@ -1,18 +1,20 @@
Grocy.Components.BarcodeScanner = { };
Grocy.Components.BarcodeScanner = {};
Grocy.Components.BarcodeScanner.LiveVideoSizeAdjusted = false;
Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
{
var track = Quagga.CameraAccess.getActiveTrack();
var capabilities = {};
if (typeof track.getCapabilities === 'function') {
if (typeof track.getCapabilities === 'function')
{
capabilities = track.getCapabilities();
}
// If there is more than 1 camera, show the camera selection
var cameras = await Quagga.CameraAccess.enumerateVideoDevices();
var cameraSelect = document.querySelector('.cameraSelect-wrapper');
if (cameraSelect) {
if (cameraSelect)
{
cameraSelect.style.display = cameras.length > 1 ? 'inline-block' : 'none';
}
@@ -20,11 +22,13 @@ Grocy.Components.BarcodeScanner.CheckCapabilities = async function()
var canTorch = typeof capabilities.torch === 'boolean' && capabilities.torch
// Remove the torch button, if either the device can not torch or AutoTorchOn is set.
var node = document.querySelector('.torch');
if (node) {
if (node)
{
node.style.display = canTorch && !Grocy.FeatureFlags.GROCY_FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA ? 'inline-block' : 'none';
}
// If AutoTorchOn is set, turn on the torch.
if (canTorch && Grocy.FeatureFlags.GROCY_FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA) {
if (canTorch && Grocy.FeatureFlags.GROCY_FEATURE_FLAG_AUTO_TORCH_ON_WITH_CAMERA)
{
Grocy.Components.BarcodeScanner.TorchOn(track);
}
@@ -65,7 +69,7 @@ Grocy.Components.BarcodeScanner.StartScanning = function()
target: document.querySelector("#barcodescanner-livestream"),
constraints: {
facingMode: "environment",
...(window.localStorage.getItem('cameraId') && {deviceId : window.localStorage.getItem('cameraId')}) // If preferred cameraId is set, request to use that specific camera
...(window.localStorage.getItem('cameraId') && { deviceId: window.localStorage.getItem('cameraId') }) // If preferred cameraId is set, request to use that specific camera
}
},
locator: {
@@ -142,7 +146,8 @@ Grocy.Components.BarcodeScanner.StopScanning = function()
Grocy.Components.BarcodeScanner.TorchOn = function(track)
{
if (track) {
if (track)
{
track.applyConstraints({
advanced: [
{
@@ -233,7 +238,7 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
{
Grocy.Components.BarcodeScanner.TorchOn(Quagga.CameraAccess.getActiveTrack());
return false;
}
}
},
cancel: {
label: __t('Cancel'),
@@ -251,7 +256,8 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
var cameraSelect = document.querySelector('.cameraSelect');
var cameras = await Quagga.CameraAccess.enumerateVideoDevices();
cameras.forEach(camera => {
cameras.forEach(camera =>
{
var option = document.createElement("option");
option.text = camera.label ? camera.label : camera.deviceId; // Use camera label if it exists, else show device id
option.value = camera.deviceId;
@@ -261,7 +267,8 @@ $(document).on("click", "#barcodescanner-start-button", async function(e)
// Set initial value to preferred camera if one exists - and if not, start out empty
cameraSelect.value = window.localStorage.getItem('cameraId');
cameraSelect.onchange = function(){
cameraSelect.onchange = function()
{
window.localStorage.setItem('cameraId', cameraSelect.value);
Quagga.stop();
Grocy.Components.BarcodeScanner.StartScanning();