Browse Source

Moving QR app to qr.js

master
Ryan Wark 4 years ago
parent
commit
3dc6fed5bd
  1. 31
      dist/index.html
  2. 28
      dist/qr.js

31
dist/index.html

@ -5,36 +5,7 @@
<link rel="stylesheet" href="qr.css">
<script src="qr-maker.js"></script>
<script type="text/javascript">
var qrcode = null;
var qrtext = null;
function init() {
qrtext = document.getElementById("qrtext");
qrcode = new QRCode(document.getElementById("qrcode"), {
correctLevel : QRCode.CorrectLevel.L,
colorDark: '#333',
colorLight: '#f0f0f0'
});
qrtext.focus();
parseLocation();
}
function parseLocation() {
var term = window.location.search || window.location.hash;
if(term.length > 1) {
qrtext.value = decodeURIComponent(term.substring(1));
makeCode(qrtext);
}
}
function makeCode (input) {
if (!input.value) {
qrcode.clear();
input.focus();
return;
}
qrcode.makeCode(input.value);
}
</script>
<script src="qr.js"></script>
</head>
<body onload="init()">
<input id="qrtext" type="text" placeholder="Enter text" oninput="makeCode(this)"/>

28
dist/qr.js

@ -0,0 +1,28 @@
var qrcode = null;
var qrtext = null;
function init() {
qrtext = document.getElementById("qrtext");
qrcode = new QRCode(document.getElementById("qrcode"), {
correctLevel : QRCode.CorrectLevel.L,
colorDark: '#333',
colorLight: '#f0f0f0'
});
qrtext.focus();
parseLocation();
}
function parseLocation() {
var term = window.location.search || window.location.hash;
if(term.length > 1) {
qrtext.value = decodeURIComponent(term.substring(1));
makeCode(qrtext);
}
}
function makeCode (input) {
if (!input.value) {
qrcode.clear();
input.focus();
return;
}
qrcode.makeCode(input.value);
}
Loading…
Cancel
Save