-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQRcode.html
More file actions
249 lines (223 loc) · 6.05 KB
/
Copy pathQRcode.html
File metadata and controls
249 lines (223 loc) · 6.05 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>QR Code Scanner | KaCyber</title>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap" rel="stylesheet">
<style>
body {
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
margin: 0;
padding: 0;
background: #f5f6fa;
}
footer {
text-align: center;
padding: 15px;
background-color: #A8C13F;
color: white;
border-radius: 5px;
}
h1 {
color: #007bff;
margin-bottom: 20px;
margin-left: 90px;
}
#reader {
width: 250px;
height: 250px;
margin-left: 50px;
padding: 20px 30px;
}
.navbar-logo {
display: flex;
align-items: center;
gap: 10px;
font-size: 1.5em;
font-weight: bold;
}
.container{
background: white;
width: 500px;
height: 600px;
margin: 30px auto;
padding: 20px 30px;
border-radius: 10px;
border: solid;
}
#result {
margin-top: 20px;
padding: 12px;
background: #fff;
border-radius: 8px;
border: 1px solid #ddd;
width: 250px;
word-break: break-word;
text-align: center;
border: solid;
margin-left: 100px;
}
.btn {
margin-top: 30px;
padding: 10px;
background: #007bff;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
font-size: larger;
font-weight: 600;
margin-left: 160px;
}
.btn.stop {
background: #dc3545;
margin-left: 160px;
}
.footer {
margin-top: auto;
padding: 20px;
color: #555;
font-size: 13px;
}
.navbar {
background-color: #A8C13F;
color: white;
padding: 12px 0;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.navbar-container {
display: flex;
justify-content: space-between;
align-items: center;
width: 90%;
margin: auto;
}
.navbar-logo {
font-size: 1.5em;
font-weight: bold;
margin-left: 0px;
}
.navbar-links {
list-style: none;
display: flex;
gap: 20px;
font-size: larger;
}
.navbar-links a {
color: white;
text-decoration: none;
font-weight: 500;
transition: 0.3s;
}
.navbar-links a:hover {
text-decoration: underline;
color: #ffcc00;
}
h1{
color:black;
}
</style>
</head>
<body>
<nav class="navbar">
<div class="navbar-container">
<div id="google_translate_element"></div>
<div class="navbar-logo">
<span>Transafe</span>
</div>
<ul class="navbar-links">
<li><a href="index.html">Home</a></li>
<li><a href="rides.html">Rides</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
</nav>
<div class="container">
<h1>Scan the Number Plate</h1>
<!-- QR Code Reader -->
<div id="reader"></div>
<!-- Result Display -->
<div id="result">No Number Plate detected Yet.</div>
<!-- Control Buttons -->
<button id="startBtn" class="btn">Start Scanner</button>
<br> <button id="stopBtn" class="btn stop">Stop Scanner</button>
</div>
<div class="footer">
</div>
<!-- html5-qrcode Library -->
<script src="https://unpkg.com/html5-qrcode"></script>
<script>
const readerDiv = document.getElementById("reader");
const resultDiv = document.getElementById("result");
const startBtn = document.getElementById("startBtn");
const stopBtn = document.getElementById("stopBtn");
const html5QrCode = new Html5Qrcode("reader");
let isScanning = false;
async function startScanner() {
if (isScanning) return;
try {
const cameras = await Html5Qrcode.getCameras();
if (cameras && cameras.length) {
const cameraId = cameras[0].id; // Use first available camera
html5QrCode.start(
cameraId,
{ fps: 10, qrbox: { width: 250, height: 250 } },
(decodedText) => {
resultDiv.innerHTML = `<b>Scanned Code:</b> ${decodedText}`;
// Example: verify number plate or ticket
if (decodedText.startsWith("KC-")) {
resultDiv.style.background = "#d4edda";
resultDiv.style.borderColor = "#28a745";
} else {
resultDiv.style.background = "#f8d7da";
resultDiv.style.borderColor = "#dc3545";
}
},
(errorMessage) => {
// Ignore scanning errors
}
);
isScanning = true;
} else {
alert("No camera found on this device.");
}
} catch (err) {
console.error(err);
alert("Error accessing camera: " + err.message);
}
}
async function stopScanner() {
if (!isScanning) return;
await html5QrCode.stop();
isScanning = false;
resultDiv.innerText = "Scanner stopped.";
}
startBtn.addEventListener("click", startScanner);
stopBtn.addEventListener("click", stopScanner);
function googleTranslateElementInit() {
new google.translate.TranslateElement(
{
pageLanguage: 'en', // Default language of your website
includedLanguages: 'en,xog,lg,cgg,ach', // You can add more if supported
layout: google.translate.TranslateElement.InlineLayout.SIMPLE,
},
'google_translate_element' // The ID of the div where the widget appears
);
}
// ===== GOOGLE TRANSLATE INIT =====
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<footer>
<div class="footer-content">
<p>© 2025 Transafe Uganda. All rights reserved.</p>
<div class="social-icons">
<a href="https://www.facebook.com/TransafeUganda" target="_blank"><img src="fb.JPG" alt="Facebook"></a>
<a href="https://twitter.com/TransafeUG" target="_blank"><img src="x.JPG" alt="Twitter"></a>
<a href="https://www.instagram.com/transafeug" target="_blank"><img src="insta.JPG" alt="Instagram"></a>
<a href="https://www.linkedin.com/company/transafe-uganda" target="_blank"><img src="linked.JPG" alt="LinkedIn"></a>
</div>
</div>
</footer>
</body>
</html>