You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
955 B
51 lines
955 B
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<style>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
body {
|
|
margin:1em;
|
|
}
|
|
#qrtext {
|
|
width:80%;
|
|
}
|
|
#qrcode {
|
|
width:160px;
|
|
height:160px;
|
|
margin-top:15px;
|
|
}
|
|
</style>
|
|
<script src="qr.js"></script>
|
|
<script type="text/javascript">
|
|
var qrcode = null;
|
|
var qrtext = null;
|
|
function init() {
|
|
qrtext = document.getElementById("qrtext");
|
|
qrcode = new QRCode(document.getElementById("qrcode"));
|
|
qrtext.focus();
|
|
parseLocation();
|
|
}
|
|
function parseLocation() {
|
|
var term = window.location.search || window.location.hash;
|
|
if(term.length > 1) {
|
|
qrtext.value = term.substring(1);
|
|
makeCode(qrtext);
|
|
}
|
|
}
|
|
function makeCode (input) {
|
|
if (!input.value) {
|
|
qrcode.clear();
|
|
input.focus();
|
|
return;
|
|
}
|
|
|
|
qrcode.makeCode(input.value);
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="init()">
|
|
<input id="qrtext" type="text" placeholder="Enter text" oninput="makeCode(this)"/>
|
|
<br />
|
|
<div id="qrcode"></div>
|
|
</body>
|
|
</html>
|