-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (24 loc) · 868 Bytes
/
app.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
var url = 'https://github.com/EverSilverio';
var apiChart = 'https://chart.googleapis.com/chart?chs=350x350&cht=qr&choe=UTF-8&chl=';
var qrcodeUrl = apiChart + url;
function loadQrCode() {
let qrcode = document.querySelector('#qrcode');
let inputUrl = document.querySelector('#url');
qrcode.setAttribute('src', './img/loading.gif');
url = inputUrl.value;
// replace & por %26 - API nao entende "&"
url = url.replace('&', '%26');
qrcodeUrl = apiChart + url;
setTimeout(() => {
qrcode.setAttribute('src', qrcodeUrl);
}, 10);
}
window.onload = function() {
let qrcode = document.querySelector('#qrcode');
let inputUrl = document.querySelector('#url');
inputUrl.value = url;
qrcode.setAttribute('src', qrcodeUrl)
inputUrl.onchange = function(e) {
url = e.target.value;
}
}