-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (26 loc) · 831 Bytes
/
script.js
File metadata and controls
32 lines (26 loc) · 831 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
30
31
32
let qrcode;
function generateQR() {
const qrText = document.getElementById("qrText").value;
const qrContainer = document.getElementById("qrcode");
const downloadLink = document.getElementById("downloadLink");
if (!qrText) return alert("Bitte gib einen Text oder eine URL ein!");
qrContainer.innerHTML = ""; // Reset
qrcode = new QRCode(qrContainer, {
text: qrText,
width: 256,
height: 256,
colorDark: "#000000",
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.H
});
setTimeout(() => {
const img = qrContainer.querySelector("img") || qrContainer.querySelector("canvas");
if (img) {
const dataURL = img.src || img.toDataURL("image/png");
downloadLink.href = dataURL;
}
}, 500);
}
function toggleDarkMode() {
document.body.classList.toggle("dark");
}