index.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Instascan</title>
  6. <script type="text/javascript" src="https://rawgit.com/schmich/instascan-builds/master/instascan.min.js"></script>
  7. <link rel="stylesheet" type="text/css" href="../css/style.css">
  8. <link rel="stylesheet" href="../css/style1.css" type="text/css" />
  9. <link rel="stylesheet" href="../css/style.css" type="bootstrap/css/bootstrap.min.css" />
  10. </head>
  11. <body>
  12. <div id="principal">
  13. <div class="header">
  14. </div><!-- end of header -->
  15. <div class="main">
  16. <div class="content">
  17. <h1>Accueil</h1>
  18. <video id="preview"></video>
  19. <script type="text/javascript">
  20. //Recupération du cookie espace
  21. function getCookieVal(offset) {
  22. let endstr = document.cookie.indexOf (";", offset);
  23. if (endstr==-1)
  24. endstr = document.cookie.length;
  25. return unescape(document.cookie.substring(offset, endstr));
  26. }
  27. function getCookie (name) {
  28. let arg = name + "=";
  29. let alen = arg.length;
  30. let clen = document.cookie.length;
  31. let i = 0;
  32. while (i < clen) {
  33. let j = i+alen;
  34. if (document.cookie.substring(i, j) == arg)
  35. return getCookieVal(j);
  36. i = document.cookie.indexOf(" ",i)+1;
  37. if (i == 0)
  38. break;
  39. }
  40. return null;
  41. }
  42. let espace = getCookie("microfolies.lens.espace");
  43. console.log(espace);
  44. //Scanner QRcode
  45. let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
  46. scanner.addListener('scan', function (content) {
  47. espace ? document.getElementById("resultScan").value = content + "/" + espace : document.getElementById("resultScan").value = content;
  48. });
  49. Instascan.Camera.getCameras().then(function (cameras) {
  50. if (cameras.length > 0) {
  51. scanner.start(cameras[0]);
  52. }
  53. else {
  54. console.error('No cameras found.');
  55. }
  56. }).catch(function (e) {
  57. console.error(e);
  58. });
  59. </script>
  60. <textarea id="resultScan" read_only="true"></textarea>
  61. </div>
  62. </div>
  63. </div>
  64. </body>
  65. </html>