-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
36 lines (32 loc) · 1.01 KB
/
script.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
31
32
33
34
35
36
const $ = document
const inputElem = $.querySelector('input')
const btnElem = $.querySelector('.btn-gen')
const imgElem = $.querySelector('.qr-img')
const warnElem = $.querySelector('.warn')
const request = "https://api.qrserver.com/v1/create-qr-code/?size=200x200&data="
btnElem.addEventListener('click', ()=>{
if (inputElem.value === "") {
warnElem.innerHTML = "Fill input!"
warnElem.style.color = "red"
warnElem.style.textAlign = "center"
setTimeout(() => {
warnElem.innerHTML = ""
}, 2000);
} else{
let inputValue = inputElem.value.trim()
let qrUrl = request + inputValue
imgElem.src = qrUrl
}
})
const activateInput = () => {
console.log("test");
}
inputElem.addEventListener('input', (ev) => {
if (inputElem.value === "") {
inputElem.style.padding = "0 0 0 25%";
inputElem.style.letterSpacing = "5px"
} else {
inputElem.style.padding = "0 0 0 10%";
inputElem.style.letterSpacing = "0px"
}
})