-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathqr-codes.html
More file actions
127 lines (102 loc) · 3.01 KB
/
qr-codes.html
File metadata and controls
127 lines (102 loc) · 3.01 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>QR codes</title>
<style type="text/css">
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
img, video, canvas, svg { max-width: 100%; height: auto; }
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap");
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap');
h2 {
font-family: "Oswald", serif;
font-size: 1.5em;
line-height: 1.1em;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-top: 0;
padding: 0.3125rem 0.625rem;
margin-bottom: 0.9375rem;
position: relative;
}
/* Input Section */
#input-container {
margin-bottom: 1.25rem;
}
label {
font-weight: bold;
display: block;
margin-bottom: 0.5rem;
font-size: 0.875rem;
color: #555;
}
#qr-text {
width: 100%;
padding: 0.625rem;
font-size: 1rem;
border: 1px solid #ddd;
border-radius: 0.3125rem; /* Round the corners */
background-color: #f2f2f2;
}
input:focus {outline: none; /* Remove the default focus outline */
border-color: blue; /* Change the border color on focus */
box-shadow: 0 0 0.3125rem rgba(0, 0, 255, 0.5);}
button {
font-family: "Oswald", serif;
margin-top: 0.625rem;
width: 100%;
background: #007bff; /* Blue button */
color: #fff;
font-size: 1rem;
padding: 0.625rem;
border: none;
border-radius: 0.25rem;
cursor: pointer;
font-weight: bold;
transition: background 0.3s ease;
float:left;
}
button:hover {
background: #0056b3; /* Darker blue on hover */
}
</style>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.min.js"></script>
</head>
<body>
<input type="text" id="qr-text" placeholder="Enter text or URL" /><br><br>
<button id="generate-btn">Generate</button><br><br><br>
<button id="download-btn" disabled>Download</button>
<br><br>
<canvas id="qr-code"></canvas>
<script type="text/javascript">
document.getElementById('generate-btn').addEventListener('click', () => {
const qrText = document.getElementById('qr-text').value;
if (qrText.trim() === '') {
alert('Please enter text or a URL!');
return;
}
const qr = new QRious({
element: document.getElementById('qr-code'),
value: qrText,
size: 200, // QR code size in pixels
});
// Enable the download button
const downloadBtn = document.getElementById('download-btn');
downloadBtn.disabled = false;
// Add click event for downloading the QR code
downloadBtn.addEventListener('click', () => {
const canvas = document.getElementById('qr-code');
const dataURL = canvas.toDataURL('image/png');
const link = document.createElement('a');
link.href = dataURL;
link.download = 'qr-code.png';
link.click();
});
});
</script>
</body>
</html>