-
Notifications
You must be signed in to change notification settings - Fork 0
/
style.js
30 lines (25 loc) · 954 Bytes
/
style.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const wrapper = document.querySelector(".wrapper"),
qrInput = wrapper.querySelector(".form input"),
genBtn = wrapper.querySelector(".form button"),
qrImg = wrapper.querySelector(".qr-code img");
qrMass = wrapper.querySelector("h5");
let tempValue;
genBtn.addEventListener("click", () => {
let qrValue = qrInput.value.trim();
if (!qrValue || tempValue === qrValue) return;
tempValue = qrValue;
genBtn.innerText = "Generating QR Code...";
qrImg.src = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${qrValue}`;
qrImg.addEventListener("load", () => {
wrapper.classList.add("active");
genBtn.innerText = "Generate QR Code";
qrMass.innerText = "Scan the QR to check the massage"
});
});
qrInput.addEventListener("keyup", () => {
if (!qrInput.value.trim()) {
wrapper.classList.remove("active");
tempValue = "";
qrMass.innerText = "";
}
});