-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
37 lines (29 loc) · 1.03 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
37
const qrcodeContainer = document.getElementById('imgBox');
const downloadButton = document.getElementById('downloadButton');
function generateQRCode() {
const qrText = document.getElementById('qrText').value;
if (qrText.trim() === '') {
alert('Please enter a Name or URL');
return;
}
qrcodeContainer.innerHTML = '';
const qrcode = new QRCode(qrcodeContainer, {
text: qrText,
width: 150,
height: 150,
colorDark: '#0000FF',
colorLight: '#fff',
correctLevel: QRCode.CorrectLevel.H,
});
downloadButton.style.display = 'block';
}
function downloadQR() {
const qrText = document.getElementById('qrText').value;
if (qrcodeContainer.innerHTML) {
const qrCodeDataURL = qrcodeContainer.querySelector('img').src;
const downloadLink = document.createElement('a');
downloadLink.href = qrCodeDataURL;
downloadLink.download = "qrcode"+qrText+".png";
downloadLink.click();
}
}