-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
60 lines (57 loc) · 1.75 KB
/
index.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>qr code generator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.min.js"></script>
<div class="form">
<h1>QR Code generator</h1>
<form>
<input type="url" id="website" name="website" placeholder="https://liupurnomo.com" required />
<button class="center" type="button" onclick="generateQRCode()">
Generate QR Code
</button>
</form>
<div id="qrcode-container">
<canvas id="qrcode" class="qrcode"></canvas>
<h4 class="center">With some styles</h4>
<canvas id="qrcode-2" class="qrcode"></canvas>
</div>
<script type="text/javascript">
function generateQRCode() {
let website = document.getElementById("website").value;
if (website) {
let qrcodeContainer = document.getElementById("qrcode");
qrcodeContainer.innerHTML = "";
new QRious({
element: qrcodeContainer,
value: website
});
/*With some styles*/
let qrcodeContainer2 = document.getElementById("qrcode-2");
qrcodeContainer2.innerHTML = "";
new QRious({
element: qrcodeContainer2,
background: '#ffffff',
backgroundAlpha: 1,
foreground: '#5868bf',
foregroundAlpha: 1,
level: 'H',
padding: 0,
size: 128,
value: website
});
document.getElementById("qrcode-container").style.display = "block";
} else {
alert("Please enter a valid URL");
}
}
</script>
</div>
</body>
</html>