|
|
|
@ -1,29 +1,6 @@ |
|
|
|
{% extends 'base.html' %} |
|
|
|
{% extends 'base.html' %} |
|
|
|
{% block content %} |
|
|
|
{% block content %} |
|
|
|
{% load static %} |
|
|
|
{% 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="container-fluid mt-4"> |
|
|
|
<div class="row"> |
|
|
|
<div class="row"> |
|
|
|
<div class="col-12"> |
|
|
|
<div class="col-12"> |
|
|
|
@ -172,16 +149,14 @@ document.addEventListener('DOMContentLoaded', function() { |
|
|
|
const reader = document.getElementById('reader'); |
|
|
|
const reader = document.getElementById('reader'); |
|
|
|
if (!reader) return; |
|
|
|
if (!reader) return; |
|
|
|
|
|
|
|
|
|
|
|
html5Qrcode = new Html5Qrcode('reader', { |
|
|
|
html5Qrcode = new Html5Qrcode('reader'); |
|
|
|
formatsToSupport: [Html5QrcodeSupportedFormats.QR_CODE] |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
Html5Qrcode.getCameras().then(cameras => { |
|
|
|
Html5Qrcode.getCameras().then(cameras => { |
|
|
|
camerasAvailable = cameras || []; |
|
|
|
camerasAvailable = cameras || []; |
|
|
|
if (camerasAvailable.length) { |
|
|
|
if (camerasAvailable.length) { |
|
|
|
currentCameraId = camerasAvailable[0].id; |
|
|
|
currentCameraId = camerasAvailable[0].id; |
|
|
|
html5Qrcode.start( |
|
|
|
html5Qrcode.start( |
|
|
|
currentCameraId, |
|
|
|
currentCameraId, |
|
|
|
{ fps: 15, qrbox: 250 }, |
|
|
|
{ fps: 10, qrbox: 250 }, |
|
|
|
onScanSuccess |
|
|
|
onScanSuccess |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -202,7 +177,7 @@ document.addEventListener('DOMContentLoaded', function() { |
|
|
|
currentCameraId = cam.id; |
|
|
|
currentCameraId = cam.id; |
|
|
|
html5Qrcode.start( |
|
|
|
html5Qrcode.start( |
|
|
|
currentCameraId, |
|
|
|
currentCameraId, |
|
|
|
{ fps: 15, qrbox: 250 }, |
|
|
|
{ fps: 10, qrbox: 250 }, |
|
|
|
onScanSuccess |
|
|
|
onScanSuccess |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -220,11 +195,6 @@ function getCourseIdFromUrl() { |
|
|
|
} |
|
|
|
} |
|
|
|
function onScanSuccess(decodedText, decodedResult) { |
|
|
|
function onScanSuccess(decodedText, decodedResult) { |
|
|
|
console.log('Scan détecté :', decodedText, 'Course:', getCourseIdFromUrl()); |
|
|
|
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; |
|
|
|
if (decodedText === lastScanned || window.scanDebounce) return; |
|
|
|
window.scanDebounce = true; |
|
|
|
window.scanDebounce = true; |
|
|
|
lastScanned = decodedText; |
|
|
|
lastScanned = decodedText; |
|
|
|
|