From 3dc6fed5bde543677abae0412e9978c6f5dd6a8b Mon Sep 17 00:00:00 2001 From: Ryan Wark Date: Tue, 10 Aug 2021 22:20:19 -0300 Subject: [PATCH] Moving QR app to qr.js --- dist/index.html | 31 +------------------------------ dist/qr.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 30 deletions(-) create mode 100644 dist/qr.js diff --git a/dist/index.html b/dist/index.html index df9e084..b92f52e 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,36 +5,7 @@ - + diff --git a/dist/qr.js b/dist/qr.js new file mode 100644 index 0000000..3438e5e --- /dev/null +++ b/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); +}