From 4cb2bc7d29616e1cb6ea9a23a2a3b49a3b8bcaae Mon Sep 17 00:00:00 2001 From: Steven Tracey Date: Thu, 17 Jul 2025 12:18:02 -0400 Subject: [PATCH] v1.1 --- genqr.php | 4 ++-- static/register.js | 2 +- static/verify.js | 19 +++++++++++++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/genqr.php b/genqr.php index 16648cf..4dabf3b 100644 --- a/genqr.php +++ b/genqr.php @@ -25,7 +25,7 @@ const path = window.location.pathname; const parts = path.split("/"); const user = parts.pop(); - let url = location.protocol + "//" + location.host + "/u/" + user; + let url = location.protocol + "//" + location.host + "/u/" + user.toLowerCase(); const qrcode = new QRCode(document.getElementById('qr'), { text: url, @@ -39,7 +39,7 @@ let qrLink = document.getElementById("qr-link"); let qrImg = document.querySelector("#qr img"); console.log(qrImg.src); - qrLink.setAttribute("download", "qrcode-" + user + ".png"); + qrLink.setAttribute("download", "qrcode-" + user.toLowerCase() + ".png"); const delay = ms => new Promise(res => setTimeout(res, ms)); const setHref = async () => { diff --git a/static/register.js b/static/register.js index bc726b8..347ab3a 100644 --- a/static/register.js +++ b/static/register.js @@ -1,4 +1,4 @@ -const form = document.getElementById("reg-form"); // Replace #my-form with your form's ID +const form = document.getElementById("reg-form"); form.addEventListener("submit", async (event) => { event.preventDefault(); diff --git a/static/verify.js b/static/verify.js index 40924ad..a7a9cac 100644 --- a/static/verify.js +++ b/static/verify.js @@ -1,10 +1,10 @@ -document.getElementById("submitBtn").addEventListener('click', function(e) { - let code = document.getElementById("code").value; - console.log("Clicked: " + code); +let submitBtn = document.getElementById("submitBtn"); +submitBtn.addEventListener('click', function(e) { + let code = document.getElementById("code").value.replaceAll(" ", ""); const path = window.location.pathname; const parts = path.split("/"); - const user = parts.pop(); + const user = parts.pop().toLowerCase(); fetch("/api/verify/" + user, { method: 'GET', @@ -15,8 +15,9 @@ document.getElementById("submitBtn").addEventListener('click', function(e) { }).then(response => response.json()) .then(data => { let statusText = document.getElementById("status"); - console.log(data); statusText.classList.remove("hidden"); + console.log("Status Code: " + data.status); + console.log("Code Type: " + typeof data.status) if (data.status === 404) { // Not found statusText.innerText = "User with that code not found"; @@ -29,4 +30,10 @@ document.getElementById("submitBtn").addEventListener('click', function(e) { statusText.innerText = "Error, please send this to Steven to be fixed. Error: " + data.error; } }) -}) \ No newline at end of file +}); + +document.getElementById("code").addEventListener('keyup', function(e) { + if (e.key === "Enter") { + submitBtn.click(); + } +}); \ No newline at end of file