< >

qrcode_to_site.php


Quell Code


 
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#conti{
margin-left:calc(50% - 200px);
margin-top:10%;
width:400px;
ight:300px;
text-align:center;
font-size:30px;
font-weight:900;
}

#reture{
display:inline-block;
border:2px solid black;
background:lightblue;
}
</style>
 <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js"></script>
   <script src="https://rawgit.com/sitepoint-editors/jsqrcode/master/src/qr_packed.js"></script>
 </head>
<body>

<form>
 
<div id="conti">
<input type=button class=qrcode-text value="Leer....">
<label class=qrcode-text-btn>
  <input type=file
         accept="image/*"
         capture=environment
         onchange="openQRCamera(this);"
         tabindex=-1>
</label>
</div>


<script>

$('.qrcode-text').click(function(){
 
open(this.value);
});




	function openQRCamera(node) {
  var reader = new FileReader();
  reader.onload = function() {
    node.value = "";
    qrcode.callback = function(res) {
      if(res instanceof Error) {
        alert("No QR code found. Please make sure the QR code is within the camera's frame and try again.");
      } else {
       node.parentNode.previousElementSibling.value = res;
      }
    };
    qrcode.decode(reader.result);
  };
  reader.readAsDataURL(node.files[0]);
}
    
</script>

</body>
</html>