Browse Source

Annulation optimations scan

master
scayac 1 month ago
parent
commit
f19e026a74
  1. 36
      main/templates/scan.html

36
main/templates/scan.html

@ -1,29 +1,6 @@ @@ -1,29 +1,6 @@
{% extends 'base.html' %}
{% block content %}
{% load static %}
<style>
#reader {
position: relative;
}
#reader::after {
position: absolute;
top: 50%;
left: 50%;
width: min(250px, calc(100% - 20px));
aspect-ratio: 1;
border: 2px solid #fff;
box-sizing: border-box;
content: '';
pointer-events: none;
transform: translate(-50%, -50%);
z-index: 10;
}
#reader.qr-detected::after {
border-color: rgb(90, 193, 56);
}
</style>
<div class="container-fluid mt-4">
<div class="row">
<div class="col-12">
@ -172,16 +149,14 @@ document.addEventListener('DOMContentLoaded', function() { @@ -172,16 +149,14 @@ document.addEventListener('DOMContentLoaded', function() {
const reader = document.getElementById('reader');
if (!reader) return;
html5Qrcode = new Html5Qrcode('reader', {
formatsToSupport: [Html5QrcodeSupportedFormats.QR_CODE]
});
html5Qrcode = new Html5Qrcode('reader');
Html5Qrcode.getCameras().then(cameras => {
camerasAvailable = cameras || [];
if (camerasAvailable.length) {
currentCameraId = camerasAvailable[0].id;
html5Qrcode.start(
currentCameraId,
{ fps: 15, qrbox: 250 },
{ fps: 10, qrbox: 250 },
onScanSuccess
);
}
@ -202,7 +177,7 @@ document.addEventListener('DOMContentLoaded', function() { @@ -202,7 +177,7 @@ document.addEventListener('DOMContentLoaded', function() {
currentCameraId = cam.id;
html5Qrcode.start(
currentCameraId,
{ fps: 15, qrbox: 250 },
{ fps: 10, qrbox: 250 },
onScanSuccess
);
});
@ -220,11 +195,6 @@ function getCourseIdFromUrl() { @@ -220,11 +195,6 @@ function getCourseIdFromUrl() {
}
function onScanSuccess(decodedText, decodedResult) {
console.log('Scan détecté :', decodedText, 'Course:', getCourseIdFromUrl());
if (decodedResult) {
const reader = document.getElementById('reader');
reader.classList.add('qr-detected');
setTimeout(() => reader.classList.remove('qr-detected'), 350);
}
if (decodedText === lastScanned || window.scanDebounce) return;
window.scanDebounce = true;
lastScanned = decodedText;

Loading…
Cancel
Save