QR Code Generator
+Paste a url or enter text to create QR Code
+From 63f3e773ea08f17587cedf526564f32f6f3e0712 Mon Sep 17 00:00:00 2001 From: Sam <74021826+x39OME@users.noreply.github.com> Date: Mon, 17 Apr 2023 01:33:23 +0300 Subject: [PATCH] Add files via upload --- 100_projects/55-qr-code-generator/app.js | 24 +++++ 100_projects/55-qr-code-generator/index.html | 26 +++++ 100_projects/55-qr-code-generator/style.css | 108 +++++++++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 100_projects/55-qr-code-generator/app.js create mode 100644 100_projects/55-qr-code-generator/index.html create mode 100644 100_projects/55-qr-code-generator/style.css diff --git a/100_projects/55-qr-code-generator/app.js b/100_projects/55-qr-code-generator/app.js new file mode 100644 index 0000000..ff0c4d8 --- /dev/null +++ b/100_projects/55-qr-code-generator/app.js @@ -0,0 +1,24 @@ +const main = document.querySelector(".main"), +qrInput = main.querySelector(".form input"), +generateBtn = main.querySelector(".form button"), +qrImg = main.querySelector(".qr-code img"); +let preValue; + +generateBtn.addEventListener("click", () => { + let qrValue = qrInput.value.trim(); + if(!qrValue || preValue === qrValue) return; + preValue = qrValue; + generateBtn.innerText = "Generating QR Code..."; + qrImg.src = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${qrValue}`; + qrImg.addEventListener("load", () => { + main.classList.add("active"); + generateBtn.innerText = "Generate QR Code"; + }); +}); +qrInput.addEventListener("keyup", () => { + if(!qrInput.value.trim()) { + main.classList.remove("active"); + preValue = ""; + } +}); +// https://goqr.me/api/ \ No newline at end of file diff --git a/100_projects/55-qr-code-generator/index.html b/100_projects/55-qr-code-generator/index.html new file mode 100644 index 0000000..21d8cfb --- /dev/null +++ b/100_projects/55-qr-code-generator/index.html @@ -0,0 +1,26 @@ + + +
+ + + +Paste a url or enter text to create QR Code
+