index.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <link type="text/css" rel="stylesheet" href="../css/material-icons.css" />
  7. <link type="text/css" rel="stylesheet" href="../css/materialize.min.css" media="screen,projection" />
  8. <link type="text/css" rel="stylesheet" href="../css/style.min.css" media="screen,projection" />
  9. <link rel="icon" href="../img/favicon.ico" />
  10. <title>Scan - Microfolie Lens</title>
  11. </head>
  12. <body class="grey lighten-3">
  13. <!-- Header -->
  14. <header class="navbar-fixed">
  15. <nav class="red">
  16. <div class="nav-wrapper">
  17. <span class="brand-logo center mtop-half hide-on-med-and-down"><img src="../img/logo.png"
  18. title="Logo Microfolie" class="responsive-img" style="max-width: 128px;" /></span>
  19. <span class="brand-logo center hide-on-large-only">Microfolie Lens</span>
  20. <div class="left mleft-2 hide-on-med-and-down">
  21. <span>
  22. <h5>Microfolie Lens</h5>
  23. </span>
  24. </div>
  25. </div>
  26. </nav>
  27. </header>
  28. <div class="mtop-5 hide-on-med-and-down"></div>
  29. <!-- Main -->
  30. <main class="container">
  31. <div class="row">
  32. <div class="col s12 center-align">
  33. <h3 id="title">QR Code Scanner</h3>
  34. </div>
  35. </div>
  36. <div class="row">
  37. <div class="col s12 center-align">
  38. <video id="qr-preview"></video>
  39. </div>
  40. </div>
  41. <div class="row">
  42. <div class="col s12 center-align">
  43. <p id="result"></p>
  44. </div>
  45. </div>
  46. </main>
  47. <!-- Modals -->
  48. <div id="ok-modal" class="modal">
  49. <div class="modal-content" style="overflow: hidden;">
  50. <div class="row">
  51. <div class="col offset-m1 m3 s12">
  52. <i class="material-icons green-text" style="font-size: 8em;">check_circle</i>
  53. </div>
  54. <div class="col m7 s12 mtop-3">
  55. <h4>Votre code a bien &eacute;t&eacute; scann&eacute;</h4>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <!-- Modals -->
  61. <div id="err-modal" class="modal">
  62. <div class="modal-content" style="overflow: hidden;">
  63. <div class="row">
  64. <div class="col offset-m1 m3 s12">
  65. <i class="material-icons red-text" style="font-size: 8em;">error</i>
  66. </div>
  67. <div class="col m7 s12 mtop-3">
  68. <h4 id="error-text">Error message</h4>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <!-- Script -->
  74. <script type="text/javascript" src="../js/jquery.min.js"></script>
  75. <script type="text/javascript" src="../js/materialize.min.js"></script>
  76. <script type="text/javascript" src="../js/script.js"></script>
  77. <!-- Script pour cette page-->
  78. <script type="text/javascript" src="../js/instascan.min.js"></script>
  79. <script type="text/javascript">
  80. // Lecteur cookie espace
  81. const espace = getCookie("microfolies.lens.espace");
  82. // Changement nom titre
  83. if (espace !== undefined) {
  84. $('#title').html(espace.capitalize());
  85. }
  86. //Scanner QRcode
  87. const scanner = new Instascan.Scanner({ video: document.getElementById('qr-preview') });
  88. scanner.addListener('scan', function (content) {
  89. const result = espace ? content + "/" + espace : content;
  90. $('#result').html(result);
  91. M.Modal.getInstance($('#ok-modal')).open();
  92. });
  93. Instascan.Camera.getCameras().then(function (cameras) {
  94. if (cameras.length > 0) {
  95. scanner.start(cameras[0]);
  96. }
  97. else {
  98. console.error('No cameras found.');
  99. }
  100. }).catch(err => {
  101. console.error(err);
  102. });
  103. </script>
  104. </body>
  105. </html>