-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqr-code-generator.js
More file actions
31 lines (29 loc) · 1.07 KB
/
qr-code-generator.js
File metadata and controls
31 lines (29 loc) · 1.07 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
const toolSection = document.getElementById('toolSection');
toolSection.innerHTML = `
<div class="input-area">
<label for="inputText">Text or URL:</label>
<textarea id="inputText" rows="4" placeholder="Enter text or URL..."></textarea>
</div>
<div class="buttons-grid">
<button onclick="generate()" class="btn btn-primary">Generate QR Code</button>
</div>
<div class="output-area" style="text-align:center;">
<div id="qrcode" style="display:inline-block;margin:20px auto;"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"><\/script>
`;
let qrCodeInstance = null;
function generate() {
const text = document.getElementById('inputText').value.trim();
if (!text) return;
const container = document.getElementById('qrcode');
container.innerHTML = '';
qrCodeInstance = new QRCode(container, {
text: text,
width: 256,
height: 256,
colorDark: '#000000',
colorLight: '#ffffff',
correctLevel: QRCode.CorrectLevel.H
});
}