-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.js
26 lines (20 loc) · 785 Bytes
/
main.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
const wrapper = document.querySelector('.wrapper');
const qrInput = document.querySelector('.form input')
const generateButton = document.querySelector('.form button')
const qrImg = document.querySelector('.qr-code img')
generateButton.addEventListener('click', () => {
let qrValue = qrInput.value;
if (!qrValue) return;
generateButton.innerHTML = "Generating QR code..."
qrImg.src = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${qrValue}`;
qrImg.addEventListener("load", () => {
wrapper.classList.add("active");
generateButton.innerText = "Generate QR Code";
})
wrapper.classList.add('active')
})
qrInput.addEventListener("keyup", () => {
if (qrInput.value) {
wrapper.classList.remove("active")
}
})