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

added url field

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