index.html 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 class="navbar">
  15. <ul>
  16. <li><a href="../index.html">Accueil</a></li>
  17. <li><a href="../abonnes.html">nos Abonnés</a></li>
  18. </ul>
  19. </div><!-- end navbar -->
  20. </div><!-- end of header -->
  21. <div class="main">
  22. <div class="menu">
  23. <ul>
  24. <li><a href="../index.html">Accueil</a></li>
  25. <li><a href="../abonnes.html">Nos abonnées</a></li>
  26. <li><a href="../inscription.jsp">Inscription</a></li>
  27. </ul>
  28. </div><!--end menu -->
  29. <div class="content">
  30. <h1>Scanner QrCODE</h1>
  31. <video id="preview"></video>
  32. <script type="text/javascript">
  33. //Recupération du cookie espace
  34. function getCookieVal(offset) {
  35. let endstr = document.cookie.indexOf (";", offset);
  36. if (endstr==-1)
  37. endstr = document.cookie.length;
  38. return unescape(document.cookie.substring(offset, endstr));
  39. }
  40. function getCookie (name) {
  41. let arg = name + "=";
  42. let alen = arg.length;
  43. let clen = document.cookie.length;
  44. let i = 0;
  45. while (i < clen) {
  46. let j = i+alen;
  47. if (document.cookie.substring(i, j) == arg)
  48. return getCookieVal(j);
  49. i = document.cookie.indexOf(" ",i)+1;
  50. if (i == 0)
  51. break;
  52. }
  53. return null;
  54. }
  55. let espace = getCookie("microfolies.lens.espace");
  56. console.log(espace);
  57. //Scanner QRcode
  58. let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
  59. scanner.addListener('scan', function (content) {
  60. espace ? document.getElementById("resultScan").value = content + "/" + espace : document.getElementById("resultScan").value = content;
  61. });
  62. Instascan.Camera.getCameras().then(function (cameras) {
  63. if (cameras.length > 0) {
  64. scanner.start(cameras[0]);
  65. }
  66. else {
  67. console.error('No cameras found.');
  68. }
  69. }).catch(function (e) {
  70. console.error(e);
  71. });
  72. </script>
  73. <textarea id="resultScan" read_only="true"></textarea>
  74. </div>
  75. </div>
  76. </div>
  77. </body>
  78. </html>