12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Instascan</title>
- <script type="text/javascript" src="https://rawgit.com/schmich/instascan-builds/master/instascan.min.js"></script>
- </head>
- <body>
- <h1>Scanner QrCODE</h1>
- <video id="preview"></video>
- <script type="text/javascript">
- //Recupération du cookie espace
- function getCookieVal(offset) {
- let endstr = document.cookie.indexOf (";", offset);
- if (endstr==-1)
- endstr = document.cookie.length;
- return unescape(document.cookie.substring(offset, endstr));
- }
-
- function getCookie (name) {
- let arg = name + "=";
- let alen = arg.length;
- let clen = document.cookie.length;
- let i = 0;
- while (i < clen) {
- let j = i+alen;
- if (document.cookie.substring(i, j) == arg)
- return getCookieVal(j);
- i = document.cookie.indexOf(" ",i)+1;
- if (i == 0)
- break;
- }
- return null;
- }
-
- let espace = getCookie("microfolies.lens.espace");
- console.log(espace);
-
- //Scanner QRcode
- let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
- scanner.addListener('scan', function (content) {
- espace ? console.log(content + "/" + espace) : console.log(content);
- });
- Instascan.Camera.getCameras().then(function (cameras) {
- if (cameras.length > 0) {
- scanner.start(cameras[0]);
- }
- else {
- console.error('No cameras found.');
- }
- }).catch(function (e) {
- console.error(e);
- });
- </script>
- </body>
- </html>
|