Update checking camera switcher

Fix camera selection using correct ID value.
Adjust column layout for mobile devices.
This commit is contained in:
Joel Addison 2023-03-14 12:01:02 +11:00
parent e83dafef90
commit aeacf7f8a8

View file

@ -18,7 +18,7 @@
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-lg-6">
<p><strong id="note"></strong></p> <p><strong id="note"></strong></p>
<video id="preview"" autoplay style=" height: 400px;"></video> <video id="preview"" autoplay style=" height: 400px;"></video>
@ -28,7 +28,7 @@
</ul> </ul>
</div> </div>
<div class="col-6"> <div class="col-lg-6">
<div id="code_div" class="form-group has-feedback has-error"> <div id="code_div" class="form-group has-feedback has-error">
<label class="control-label" for="bpcode">Boarding Pass Code</label> <label class="control-label" for="bpcode">Boarding Pass Code</label>
<input id="bptext" type="text" class="form-control" id="bpcode" placeholder="Code"> <input id="bptext" type="text" class="form-control" id="bpcode" placeholder="Code">
@ -78,7 +78,7 @@
let cameraItem = document.createElement('li'); let cameraItem = document.createElement('li');
cameraItem.textContent = formatCameraName(camera.name); cameraItem.textContent = formatCameraName(camera.name);
cameraItem.setAttribute('data-cameraId', camera.id); cameraItem.setAttribute('data-cameraid', camera.id);
let classNames = "list-group-item"; let classNames = "list-group-item";
if (i == 0) { if (i == 0) {
@ -111,8 +111,17 @@
} }
function selectCamera(cameraItem) { function selectCamera(cameraItem) {
let cameraId = cameraItem.dataset.cameraId; let cameraId = cameraItem.dataset.cameraid;
let camera = availableCameras[cameraId];
// Find the camera in the list.
let camera = null;
for (let i = 0; i < availableCameras.length; ++i) {
if (availableCameras[i].id === cameraId) {
camera = availableCameras[i];
break;
}
}
scanner.start(camera); scanner.start(camera);
} }