Skip to content
Snippets Groups Projects
Verified Commit 954d46f3 authored by nd's avatar nd
Browse files

added url field

parent 88144c1f
No related branches found
No related tags found
No related merge requests found
Pipeline #6259 passed
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
} }
</style> </style>
<body> <body>
<input id="text" name="text" placeholder="QR code content">
<div id="qrcode"></div> <div id="qrcode"></div>
</body> </body>
<script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.min.js"></script>
...@@ -21,16 +22,29 @@ ...@@ -21,16 +22,29 @@
<script type="text/javascript"> <script type="text/javascript">
var qrcode; var qrcode;
var elText;
function generateQR() { function generateQR() {
qrcode = new QRCode(document.getElementById("qrcode"), location.hash.substring(1)); url = elText.value;
if (!qrcode) {
qrcode = new QRCode(document.getElementById("qrcode"), url);
} else {
qrcode.clear();
qrcode.makeCode(url);
}
} }
$( document ).ready(function() { $( document ).ready(function() {
window.addEventListener('hashchange', function() {
elText.value = location.hash.substring(1)
generateQR(); generateQR();
}); });
elText = document.getElementById("text");
elText.oninput = function () {
window.location.hash = elText.value;
};
elText.value = location.hash.substring(1);
window.addEventListener('hashchange', function() { generateQR();
qrcode.clear();
qrcode.makeCode(location.hash.substring(1));
}); });
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment