Initial commit: caddy static file server workspace
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
51
caddy/www/qr_code_scanner_instascan.html
Normal file
51
caddy/www/qr_code_scanner_instascan.html
Normal file
@@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>QR Code Scanner Example</title>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
||||
<script src="https://cdn.rawgit.com/schmich/instascan-builds/master/instascan.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<video id="preview"></video>
|
||||
<button id="switchCameraButton">Switch Camera</button>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
|
||||
let cameras = [];
|
||||
|
||||
Instascan.Camera.getCameras().then(function(cameras) {
|
||||
if (cameras.length > 0) {
|
||||
startScanner(cameras[0]);
|
||||
setupCameraSwitching(cameras);
|
||||
} else {
|
||||
console.error('No cameras found.');
|
||||
}
|
||||
}).catch(function(e) {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
function startScanner(camera) {
|
||||
scanner.start(camera);
|
||||
scanner.addListener('scan', function(content) {
|
||||
alert('Scanned QR Code: ' + content);
|
||||
});
|
||||
}
|
||||
|
||||
function setupCameraSwitching(cameras) {
|
||||
$('#switchCameraButton').click(function() {
|
||||
if (cameras.length > 1) {
|
||||
let currentCamera = scanner.camera;
|
||||
let nextCameraIndex = (cameras.indexOf(currentCamera) + 1) % cameras.length;
|
||||
let nextCamera = cameras[nextCameraIndex];
|
||||
scanner.stop().then(function() {
|
||||
startScanner(nextCamera);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user