-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqr_two_way.html
More file actions
60 lines (55 loc) · 1.87 KB
/
Copy pathqr_two_way.html
File metadata and controls
60 lines (55 loc) · 1.87 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>QR Code: Two-Way (Tirupati ↔ Tirumala)</title>
<link rel="stylesheet" href="styles.css" />
<script src="https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js"></script>
<script src="common.js"></script>
</head>
<body>
<div class="container" role="main">
<h1 class="up">Your Ticket QR Code: Two-Way (Tirupati ↔ Tirumala)</h1>
<canvas id="qrcode"></canvas>
<p id="message" class="message" aria-live="polite"></p>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const urlParams = new URLSearchParams(window.location.search);
const ticketId = urlParams.get('id');
const messageEl = document.getElementById('message');
const canvas = document.getElementById('qrcode');
if (!ticketId) {
messageEl.textContent = "Invalid ticket ID.";
speak(messageEl.textContent);
return;
}
const data = getTicketById(ticketId);
if (!data) {
messageEl.textContent = "Ticket not found.";
speak(messageEl.textContent);
return;
}
const qrData = {
route: data.route,
type: data.type,
timestamp: data.timestamp,
scansUsed: data.scansUsed,
maxScans: data.maxScans,
id: ticketId
};
QRCode.toCanvas(canvas, JSON.stringify(qrData), { width: 300 }, function (error) {
if (error) {
messageEl.textContent = "Error generating QR code.";
speak(messageEl.textContent);
console.error(error);
} else {
messageEl.textContent = "Show this QR code to the bus conductor.";
speak(messageEl.textContent);
}
});
});
</script>
</body>
</html>