-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
29 lines (23 loc) · 782 Bytes
/
scripts.js
File metadata and controls
29 lines (23 loc) · 782 Bytes
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
const image = document.querySelector("img");
const input = document.querySelector("input");
const button = document.querySelector("button");
const p = document.querySelector("p");
const api = `https://api.qrserver.com/v1/create-qr-code/?data=`;
const api2 = `&size=150x150`;
function gerandoQrCode() {
p.innerHTML = "Gerando Qr Code";
setTimeout(QrCodeGerado, 1000);
image.src = `${api}${input.value}${api2}`;
}
function QrCodeGerado() {
p.innerHTML = "O Qr Code está pronto para ser lido!";
}
button.addEventListener("click", gerandoQrCode);
button.disabled = true;
input.addEventListener("input", function (event) {
if (input.value !== null && input.value !== '') {
button.disabled = false;
} else {
button.disabled = true;
}
});