Spaces:
Running
Running
Add 3 files
Browse files- README.md +7 -5
- index.html +1221 -19
- prompts.txt +0 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: red-falcon-2
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: red
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,1221 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>ZA License Scanner</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<!-- Tesseract.js for OCR -->
|
| 10 |
+
<script src='https://cdn.jsdelivr.net/npm/tesseract.js@4/dist/tesseract.min.js'></script>
|
| 11 |
+
<style>
|
| 12 |
+
.scanner-overlay {
|
| 13 |
+
position: relative;
|
| 14 |
+
width: 100%;
|
| 15 |
+
height: 60vh;
|
| 16 |
+
overflow: hidden;
|
| 17 |
+
border-radius: 20px;
|
| 18 |
+
}
|
| 19 |
+
.scanner-overlay::before {
|
| 20 |
+
content: '';
|
| 21 |
+
position: absolute;
|
| 22 |
+
top: 0;
|
| 23 |
+
left: 0;
|
| 24 |
+
right: 0;
|
| 25 |
+
bottom: 0;
|
| 26 |
+
border: 2px dashed rgba(255, 255, 255, 0.5);
|
| 27 |
+
border-radius: 20px;
|
| 28 |
+
z-index: 1;
|
| 29 |
+
}
|
| 30 |
+
.scanning-animation {
|
| 31 |
+
position: absolute;
|
| 32 |
+
top: 0;
|
| 33 |
+
left: 0;
|
| 34 |
+
width: 100%;
|
| 35 |
+
height: 10px;
|
| 36 |
+
background: linear-gradient(to right, rgba(59, 130, 246, 0), rgba(59, 130, 246, 0.8), rgba(59, 130, 246, 0));
|
| 37 |
+
animation: scan 2s linear infinite;
|
| 38 |
+
z-index: 2;
|
| 39 |
+
}
|
| 40 |
+
@keyframes scan {
|
| 41 |
+
0% { top: 0; }
|
| 42 |
+
100% { top: 100%; }
|
| 43 |
+
}
|
| 44 |
+
.result-card {
|
| 45 |
+
transition: all 0.3s ease;
|
| 46 |
+
transform: translateY(20px);
|
| 47 |
+
opacity: 0;
|
| 48 |
+
}
|
| 49 |
+
.result-card.show {
|
| 50 |
+
transform: translateY(0);
|
| 51 |
+
opacity: 1;
|
| 52 |
+
}
|
| 53 |
+
.tab-indicator {
|
| 54 |
+
transition: all 0.3s ease;
|
| 55 |
+
}
|
| 56 |
+
.page {
|
| 57 |
+
display: none;
|
| 58 |
+
}
|
| 59 |
+
.page.active {
|
| 60 |
+
display: block;
|
| 61 |
+
}
|
| 62 |
+
#videoElement {
|
| 63 |
+
width: 100%;
|
| 64 |
+
height: 100%;
|
| 65 |
+
object-fit: cover;
|
| 66 |
+
position: absolute;
|
| 67 |
+
top: 0;
|
| 68 |
+
left: 0;
|
| 69 |
+
}
|
| 70 |
+
#canvas {
|
| 71 |
+
display: none;
|
| 72 |
+
}
|
| 73 |
+
.camera-controls {
|
| 74 |
+
position: absolute;
|
| 75 |
+
bottom: 20px;
|
| 76 |
+
left: 0;
|
| 77 |
+
right: 0;
|
| 78 |
+
display: flex;
|
| 79 |
+
justify-content: center;
|
| 80 |
+
z-index: 3;
|
| 81 |
+
}
|
| 82 |
+
.switch-camera {
|
| 83 |
+
position: absolute;
|
| 84 |
+
top: 20px;
|
| 85 |
+
right: 20px;
|
| 86 |
+
z-index: 3;
|
| 87 |
+
background: rgba(0,0,0,0.5);
|
| 88 |
+
color: white;
|
| 89 |
+
border-radius: 50%;
|
| 90 |
+
width: 40px;
|
| 91 |
+
height: 40px;
|
| 92 |
+
display: flex;
|
| 93 |
+
align-items: center;
|
| 94 |
+
justify-content: center;
|
| 95 |
+
}
|
| 96 |
+
.ocr-processing {
|
| 97 |
+
position: absolute;
|
| 98 |
+
top: 0;
|
| 99 |
+
left: 0;
|
| 100 |
+
right: 0;
|
| 101 |
+
bottom: 0;
|
| 102 |
+
background: rgba(0,0,0,0.7);
|
| 103 |
+
display: flex;
|
| 104 |
+
flex-direction: column;
|
| 105 |
+
align-items: center;
|
| 106 |
+
justify-content: center;
|
| 107 |
+
color: white;
|
| 108 |
+
z-index: 10;
|
| 109 |
+
}
|
| 110 |
+
.spinner {
|
| 111 |
+
border: 4px solid rgba(255,255,255,0.3);
|
| 112 |
+
border-radius: 50%;
|
| 113 |
+
border-top: 4px solid white;
|
| 114 |
+
width: 40px;
|
| 115 |
+
height: 40px;
|
| 116 |
+
animation: spin 1s linear infinite;
|
| 117 |
+
margin-bottom: 15px;
|
| 118 |
+
}
|
| 119 |
+
@keyframes spin {
|
| 120 |
+
0% { transform: rotate(0deg); }
|
| 121 |
+
100% { transform: rotate(360deg); }
|
| 122 |
+
}
|
| 123 |
+
</style>
|
| 124 |
+
</head>
|
| 125 |
+
<body class="bg-gray-100 font-sans">
|
| 126 |
+
<div class="max-w-md mx-auto bg-white min-h-screen shadow-lg overflow-hidden">
|
| 127 |
+
<!-- Header -->
|
| 128 |
+
<div class="bg-blue-600 text-white p-4 flex justify-between items-center">
|
| 129 |
+
<div>
|
| 130 |
+
<h1 class="text-xl font-bold">ZA License Scanner</h1>
|
| 131 |
+
<p class="text-xs opacity-80">Official South African License Verification</p>
|
| 132 |
+
</div>
|
| 133 |
+
<div class="flex space-x-2">
|
| 134 |
+
<button id="history-btn" class="p-2 rounded-full bg-blue-500">
|
| 135 |
+
<i class="fas fa-history"></i>
|
| 136 |
+
</button>
|
| 137 |
+
<button id="settings-btn" class="p-2 rounded-full bg-blue-500">
|
| 138 |
+
<i class="fas fa-cog"></i>
|
| 139 |
+
</button>
|
| 140 |
+
</div>
|
| 141 |
+
</div>
|
| 142 |
+
|
| 143 |
+
<!-- Tabs -->
|
| 144 |
+
<div class="flex border-b border-gray-200 relative">
|
| 145 |
+
<button id="vehicle-tab" class="flex-1 py-3 font-medium text-blue-600 tab-button active">
|
| 146 |
+
Vehicle Disk
|
| 147 |
+
</button>
|
| 148 |
+
<button id="driver-tab" class="flex-1 py-3 font-medium text-gray-500 tab-button">
|
| 149 |
+
Driver License
|
| 150 |
+
</button>
|
| 151 |
+
<div class="tab-indicator absolute bottom-0 left-0 h-1 bg-blue-600 w-1/2"></div>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
<!-- Main Pages -->
|
| 155 |
+
<div id="scanner-page" class="page active p-4">
|
| 156 |
+
<!-- Scanner View -->
|
| 157 |
+
<div id="scanner-view" class="mb-6">
|
| 158 |
+
<div class="scanner-overlay bg-gray-800 mb-4 relative">
|
| 159 |
+
<video id="videoElement" playsinline></video>
|
| 160 |
+
<canvas id="canvas"></canvas>
|
| 161 |
+
<div class="scanning-animation hidden" id="scan-line"></div>
|
| 162 |
+
<div id="scanner-placeholder" class="absolute inset-0 flex items-center justify-center">
|
| 163 |
+
<div class="text-center text-white">
|
| 164 |
+
<i class="fas fa-camera text-4xl mb-2"></i>
|
| 165 |
+
<p id="scan-instruction">Align vehicle license disk within frame</p>
|
| 166 |
+
</div>
|
| 167 |
+
</div>
|
| 168 |
+
<button id="switch-camera" class="switch-camera hidden">
|
| 169 |
+
<i class="fas fa-camera-rotate"></i>
|
| 170 |
+
</button>
|
| 171 |
+
<div id="camera-controls" class="camera-controls hidden">
|
| 172 |
+
<button id="capture-btn" class="bg-white text-blue-600 p-3 rounded-full mx-2">
|
| 173 |
+
<i class="fas fa-camera"></i>
|
| 174 |
+
</button>
|
| 175 |
+
<button id="cancel-capture" class="bg-red-500 text-white p-3 rounded-full mx-2">
|
| 176 |
+
<i class="fas fa-times"></i>
|
| 177 |
+
</button>
|
| 178 |
+
</div>
|
| 179 |
+
<div id="ocr-processing" class="ocr-processing hidden">
|
| 180 |
+
<div class="spinner"></div>
|
| 181 |
+
<p>Processing license...</p>
|
| 182 |
+
<p class="text-sm opacity-75 mt-2" id="ocr-progress">Initializing OCR engine</p>
|
| 183 |
+
</div>
|
| 184 |
+
</div>
|
| 185 |
+
|
| 186 |
+
<button id="scan-button" class="w-full bg-blue-600 text-white py-3 rounded-full font-bold flex items-center justify-center">
|
| 187 |
+
<i class="fas fa-camera mr-2"></i> SCAN NOW
|
| 188 |
+
</button>
|
| 189 |
+
|
| 190 |
+
<div class="mt-4 text-center text-sm text-gray-500">
|
| 191 |
+
<p>Ensure good lighting and hold steady for accurate scanning</p>
|
| 192 |
+
</div>
|
| 193 |
+
</div>
|
| 194 |
+
|
| 195 |
+
<!-- Manual Entry Option -->
|
| 196 |
+
<div class="mt-6 border-t border-gray-200 pt-4">
|
| 197 |
+
<button id="manual-entry-btn" class="text-blue-600 font-medium flex items-center justify-center w-full">
|
| 198 |
+
<i class="fas fa-keyboard mr-2"></i> Enter Details Manually
|
| 199 |
+
</button>
|
| 200 |
+
</div>
|
| 201 |
+
|
| 202 |
+
<!-- Results Section (Initially Hidden) -->
|
| 203 |
+
<div id="results-section" class="hidden mt-6">
|
| 204 |
+
<div class="bg-white rounded-lg shadow-md p-4 mb-4 result-card">
|
| 205 |
+
<div class="flex justify-between items-center mb-3">
|
| 206 |
+
<h3 class="font-bold text-lg" id="result-title">Vehicle Details</h3>
|
| 207 |
+
<span class="bg-green-100 text-green-800 text-xs px-2 py-1 rounded-full">Verified</span>
|
| 208 |
+
</div>
|
| 209 |
+
|
| 210 |
+
<div id="vehicle-result" class="space-y-3">
|
| 211 |
+
<div class="flex justify-between border-b border-gray-100 pb-2">
|
| 212 |
+
<span class="text-gray-500">Registration:</span>
|
| 213 |
+
<span class="font-medium" id="reg-number">CA 123-456</span>
|
| 214 |
+
</div>
|
| 215 |
+
<div class="flex justify-between border-b border-gray-100 pb-2">
|
| 216 |
+
<span class="text-gray-500">Make/Model:</span>
|
| 217 |
+
<span class="font-medium" id="vehicle-make">Toyota Hilux</span>
|
| 218 |
+
</div>
|
| 219 |
+
<div class="flex justify-between border-b border-gray-100 pb-2">
|
| 220 |
+
<span class="text-gray-500">Year:</span>
|
| 221 |
+
<span class="font-medium" id="vehicle-year">2020</span>
|
| 222 |
+
</div>
|
| 223 |
+
<div class="flex justify-between border-b border-gray-100 pb-2">
|
| 224 |
+
<span class="text-gray-500">License Expiry:</span>
|
| 225 |
+
<span class="font-medium text-red-600" id="license-expiry">31 Dec 2023</span>
|
| 226 |
+
</div>
|
| 227 |
+
<div class="flex justify-between border-b border-gray-100 pb-2">
|
| 228 |
+
<span class="text-gray-500">Owner:</span>
|
| 229 |
+
<span class="font-medium" id="vehicle-owner">John Doe</span>
|
| 230 |
+
</div>
|
| 231 |
+
</div>
|
| 232 |
+
|
| 233 |
+
<div id="driver-result" class="space-y-3 hidden">
|
| 234 |
+
<div class="flex justify-between border-b border-gray-100 pb-2">
|
| 235 |
+
<span class="text-gray-500">Full Name:</span>
|
| 236 |
+
<span class="font-medium" id="driver-name">Sarah Johnson</span>
|
| 237 |
+
</div>
|
| 238 |
+
<div class="flex justify-between border-b border-gray-100 pb-2">
|
| 239 |
+
<span class="text-gray-500">ID Number:</span>
|
| 240 |
+
<span class="font-medium" id="driver-id">9001011234088</span>
|
| 241 |
+
</div>
|
| 242 |
+
<div class="flex justify-between border-b border-gray-100 pb-2">
|
| 243 |
+
<span class="text-gray-500">License Code:</span>
|
| 244 |
+
<span class="font-medium" id="license-code">B</span>
|
| 245 |
+
</div>
|
| 246 |
+
<div class="flex justify-between border-b border-gray-100 pb-2">
|
| 247 |
+
<span class="text-gray-500">Expiry Date:</span>
|
| 248 |
+
<span class="font-medium text-green-600" id="driver-license-expiry">31 Dec 2028</span>
|
| 249 |
+
</div>
|
| 250 |
+
<div class="flex justify-between border-b border-gray-100 pb-2">
|
| 251 |
+
<span class="text-gray-500">Issued:</span>
|
| 252 |
+
<span class="font-medium" id="license-issued">Gauteng</span>
|
| 253 |
+
</div>
|
| 254 |
+
</div>
|
| 255 |
+
|
| 256 |
+
<div class="mt-4 flex space-x-2">
|
| 257 |
+
<button class="flex-1 bg-blue-100 text-blue-600 py-2 rounded-full font-medium" id="share-btn">
|
| 258 |
+
<i class="fas fa-share-alt mr-1"></i> Share
|
| 259 |
+
</button>
|
| 260 |
+
<button class="flex-1 bg-blue-100 text-blue-600 py-2 rounded-full font-medium" id="print-btn">
|
| 261 |
+
<i class="fas fa-print mr-1"></i> Print
|
| 262 |
+
</button>
|
| 263 |
+
<button class="flex-1 bg-blue-100 text-blue-600 py-2 rounded-full font-medium" id="save-btn">
|
| 264 |
+
<i class="fas fa-save mr-1"></i> Save
|
| 265 |
+
</button>
|
| 266 |
+
</div>
|
| 267 |
+
</div>
|
| 268 |
+
|
| 269 |
+
<div class="bg-white rounded-lg shadow-md p-4 result-card">
|
| 270 |
+
<h3 class="font-bold text-lg mb-3">Additional Information</h3>
|
| 271 |
+
<div class="text-sm text-gray-600">
|
| 272 |
+
<p id="additional-info">This vehicle is registered in Gauteng province. No outstanding fines detected.</p>
|
| 273 |
+
<p id="driver-additional" class="hidden">This driver license is valid. Professional driving permit (PDP) not required.</p>
|
| 274 |
+
</div>
|
| 275 |
+
<button class="mt-3 w-full bg-gray-100 text-gray-800 py-2 rounded-full font-medium">
|
| 276 |
+
<i class="fas fa-search mr-1"></i> Check for Fines
|
| 277 |
+
</button>
|
| 278 |
+
</div>
|
| 279 |
+
|
| 280 |
+
<!-- Raw OCR Results (for debugging) -->
|
| 281 |
+
<div id="raw-ocr-results" class="hidden bg-gray-100 p-3 rounded-lg mt-4">
|
| 282 |
+
<h4 class="font-bold mb-2">OCR Results:</h4>
|
| 283 |
+
<pre id="ocr-text" class="text-xs whitespace-pre-wrap"></pre>
|
| 284 |
+
</div>
|
| 285 |
+
</div>
|
| 286 |
+
</div>
|
| 287 |
+
|
| 288 |
+
<!-- History Page -->
|
| 289 |
+
<div id="history-page" class="page p-4">
|
| 290 |
+
<div class="flex justify-between items-center mb-4">
|
| 291 |
+
<h2 class="text-xl font-bold">Scan History</h2>
|
| 292 |
+
<button class="text-blue-600" id="clear-history">Clear All</button>
|
| 293 |
+
</div>
|
| 294 |
+
|
| 295 |
+
<div id="history-list" class="space-y-3">
|
| 296 |
+
<!-- History items will be added here dynamically -->
|
| 297 |
+
</div>
|
| 298 |
+
|
| 299 |
+
<div id="empty-history" class="text-center py-10">
|
| 300 |
+
<i class="fas fa-history text-4xl text-gray-300 mb-3"></i>
|
| 301 |
+
<p class="text-gray-500">No scan history yet</p>
|
| 302 |
+
</div>
|
| 303 |
+
</div>
|
| 304 |
+
|
| 305 |
+
<!-- Saved Page -->
|
| 306 |
+
<div id="saved-page" class="page p-4">
|
| 307 |
+
<div class="flex justify-between items-center mb-4">
|
| 308 |
+
<h2 class="text-xl font-bold">Saved Scans</h2>
|
| 309 |
+
<button class="text-blue-600" id="clear-saved">Clear All</button>
|
| 310 |
+
</div>
|
| 311 |
+
|
| 312 |
+
<div id="saved-list" class="space-y-3">
|
| 313 |
+
<!-- Saved items will be added here dynamically -->
|
| 314 |
+
</div>
|
| 315 |
+
|
| 316 |
+
<div id="empty-saved" class="text-center py-10">
|
| 317 |
+
<i class="fas fa-bookmark text-4xl text-gray-300 mb-3"></i>
|
| 318 |
+
<p class="text-gray-500">No saved scans yet</p>
|
| 319 |
+
</div>
|
| 320 |
+
</div>
|
| 321 |
+
|
| 322 |
+
<!-- Account Page -->
|
| 323 |
+
<div id="account-page" class="page p-4">
|
| 324 |
+
<div class="flex flex-col items-center mb-6">
|
| 325 |
+
<div class="w-20 h-20 rounded-full bg-blue-100 flex items-center justify-center mb-3">
|
| 326 |
+
<i class="fas fa-user text-3xl text-blue-600"></i>
|
| 327 |
+
</div>
|
| 328 |
+
<h2 class="text-xl font-bold" id="account-name">Guest User</h2>
|
| 329 |
+
<p class="text-gray-500 text-sm" id="account-email">guest@example.com</p>
|
| 330 |
+
</div>
|
| 331 |
+
|
| 332 |
+
<div class="bg-white rounded-lg shadow-md p-4 mb-4">
|
| 333 |
+
<h3 class="font-bold mb-3">Account Settings</h3>
|
| 334 |
+
<div class="space-y-4">
|
| 335 |
+
<div>
|
| 336 |
+
<label class="block text-sm text-gray-500 mb-1">Name</label>
|
| 337 |
+
<input type="text" id="name-input" class="w-full p-2 border border-gray-300 rounded" value="Guest User">
|
| 338 |
+
</div>
|
| 339 |
+
<div>
|
| 340 |
+
<label class="block text-sm text-gray-500 mb-1">Email</label>
|
| 341 |
+
<input type="email" id="email-input" class="w-full p-2 border border-gray-300 rounded" value="guest@example.com">
|
| 342 |
+
</div>
|
| 343 |
+
<div>
|
| 344 |
+
<label class="block text-sm text-gray-500 mb-1">Password</label>
|
| 345 |
+
<input type="password" id="password-input" class="w-full p-2 border border-gray-300 rounded" placeholder="••••••••">
|
| 346 |
+
</div>
|
| 347 |
+
</div>
|
| 348 |
+
<button id="save-account" class="w-full bg-blue-600 text-white py-2 rounded-full font-medium mt-4">
|
| 349 |
+
Save Changes
|
| 350 |
+
</button>
|
| 351 |
+
</div>
|
| 352 |
+
|
| 353 |
+
<div class="bg-white rounded-lg shadow-md p-4">
|
| 354 |
+
<h3 class="font-bold mb-3">App Settings</h3>
|
| 355 |
+
<div class="flex justify-between items-center py-2 border-b border-gray-100">
|
| 356 |
+
<span>Dark Mode</span>
|
| 357 |
+
<label class="relative inline-flex items-center cursor-pointer">
|
| 358 |
+
<input type="checkbox" id="dark-mode-toggle" class="sr-only peer">
|
| 359 |
+
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
|
| 360 |
+
</label>
|
| 361 |
+
</div>
|
| 362 |
+
<div class="flex justify-between items-center py-2 border-b border-gray-100">
|
| 363 |
+
<span>Scan Sound</span>
|
| 364 |
+
<label class="relative inline-flex items-center cursor-pointer">
|
| 365 |
+
<input type="checkbox" id="sound-toggle" class="sr-only peer" checked>
|
| 366 |
+
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
|
| 367 |
+
</label>
|
| 368 |
+
</div>
|
| 369 |
+
<div class="flex justify-between items-center py-2">
|
| 370 |
+
<span>Auto-save scans</span>
|
| 371 |
+
<label class="relative inline-flex items-center cursor-pointer">
|
| 372 |
+
<input type="checkbox" id="autosave-toggle" class="sr-only peer" checked>
|
| 373 |
+
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
|
| 374 |
+
</label>
|
| 375 |
+
</div>
|
| 376 |
+
</div>
|
| 377 |
+
|
| 378 |
+
<button id="logout-btn" class="w-full bg-red-100 text-red-600 py-2 rounded-full font-medium mt-6">
|
| 379 |
+
<i class="fas fa-sign-out-alt mr-1"></i> Logout
|
| 380 |
+
</button>
|
| 381 |
+
</div>
|
| 382 |
+
|
| 383 |
+
<!-- Bottom Navigation -->
|
| 384 |
+
<div class="fixed bottom-0 left-0 right-0 max-w-md mx-auto bg-white border-t border-gray-200 flex justify-around py-2">
|
| 385 |
+
<button class="p-3 text-blue-600 nav-btn" data-page="scanner-page">
|
| 386 |
+
<i class="fas fa-home text-xl"></i>
|
| 387 |
+
</button>
|
| 388 |
+
<button class="p-3 text-gray-500 nav-btn" data-page="history-page">
|
| 389 |
+
<i class="fas fa-history text-xl"></i>
|
| 390 |
+
</button>
|
| 391 |
+
<button class="p-3 text-gray-500 nav-btn" data-page="saved-page">
|
| 392 |
+
<i class="fas fa-bookmark text-xl"></i>
|
| 393 |
+
</button>
|
| 394 |
+
<button class="p-3 text-gray-500 nav-btn" data-page="account-page">
|
| 395 |
+
<i class="fas fa-user text-xl"></i>
|
| 396 |
+
</button>
|
| 397 |
+
</div>
|
| 398 |
+
</div>
|
| 399 |
+
|
| 400 |
+
<script>
|
| 401 |
+
// Data storage
|
| 402 |
+
let scanHistory = JSON.parse(localStorage.getItem('scanHistory')) || [];
|
| 403 |
+
let savedScans = JSON.parse(localStorage.getItem('savedScans')) || [];
|
| 404 |
+
let accountData = JSON.parse(localStorage.getItem('accountData')) || {
|
| 405 |
+
name: "Guest User",
|
| 406 |
+
email: "guest@example.com",
|
| 407 |
+
password: ""
|
| 408 |
+
};
|
| 409 |
+
let settings = JSON.parse(localStorage.getItem('settings')) || {
|
| 410 |
+
darkMode: false,
|
| 411 |
+
scanSound: true,
|
| 412 |
+
autoSave: true,
|
| 413 |
+
showOcrResults: false
|
| 414 |
+
};
|
| 415 |
+
|
| 416 |
+
// DOM Elements
|
| 417 |
+
const vehicleTab = document.getElementById('vehicle-tab');
|
| 418 |
+
const driverTab = document.getElementById('driver-tab');
|
| 419 |
+
const tabIndicator = document.querySelector('.tab-indicator');
|
| 420 |
+
const scanInstruction = document.getElementById('scan-instruction');
|
| 421 |
+
const resultTitle = document.getElementById('result-title');
|
| 422 |
+
const vehicleResult = document.getElementById('vehicle-result');
|
| 423 |
+
const driverResult = document.getElementById('driver-result');
|
| 424 |
+
const additionalInfo = document.getElementById('additional-info');
|
| 425 |
+
const driverAdditional = document.getElementById('driver-additional');
|
| 426 |
+
const scanButton = document.getElementById('scan-button');
|
| 427 |
+
const scanLine = document.getElementById('scan-line');
|
| 428 |
+
const scannerView = document.getElementById('scanner-view');
|
| 429 |
+
const resultsSection = document.getElementById('results-section');
|
| 430 |
+
const historyBtn = document.getElementById('history-btn');
|
| 431 |
+
const settingsBtn = document.getElementById('settings-btn');
|
| 432 |
+
const shareBtn = document.getElementById('share-btn');
|
| 433 |
+
const printBtn = document.getElementById('print-btn');
|
| 434 |
+
const saveBtn = document.getElementById('save-btn');
|
| 435 |
+
const historyPage = document.getElementById('history-page');
|
| 436 |
+
const savedPage = document.getElementById('saved-page');
|
| 437 |
+
const accountPage = document.getElementById('account-page');
|
| 438 |
+
const scannerPage = document.getElementById('scanner-page');
|
| 439 |
+
const historyList = document.getElementById('history-list');
|
| 440 |
+
const savedList = document.getElementById('saved-list');
|
| 441 |
+
const emptyHistory = document.getElementById('empty-history');
|
| 442 |
+
const emptySaved = document.getElementById('empty-saved');
|
| 443 |
+
const clearHistory = document.getElementById('clear-history');
|
| 444 |
+
const clearSaved = document.getElementById('clear-saved');
|
| 445 |
+
const accountName = document.getElementById('account-name');
|
| 446 |
+
const accountEmail = document.getElementById('account-email');
|
| 447 |
+
const nameInput = document.getElementById('name-input');
|
| 448 |
+
const emailInput = document.getElementById('email-input');
|
| 449 |
+
const passwordInput = document.getElementById('password-input');
|
| 450 |
+
const saveAccount = document.getElementById('save-account');
|
| 451 |
+
const darkModeToggle = document.getElementById('dark-mode-toggle');
|
| 452 |
+
const soundToggle = document.getElementById('sound-toggle');
|
| 453 |
+
const autosaveToggle = document.getElementById('autosave-toggle');
|
| 454 |
+
const logoutBtn = document.getElementById('logout-btn');
|
| 455 |
+
const navBtns = document.querySelectorAll('.nav-btn');
|
| 456 |
+
const pages = document.querySelectorAll('.page');
|
| 457 |
+
const videoElement = document.getElementById('videoElement');
|
| 458 |
+
const canvas = document.getElementById('canvas');
|
| 459 |
+
const scannerPlaceholder = document.getElementById('scanner-placeholder');
|
| 460 |
+
const captureBtn = document.getElementById('capture-btn');
|
| 461 |
+
const cancelCapture = document.getElementById('cancel-capture');
|
| 462 |
+
const switchCamera = document.getElementById('switch-camera');
|
| 463 |
+
const cameraControls = document.getElementById('camera-controls');
|
| 464 |
+
const manualEntryBtn = document.getElementById('manual-entry-btn');
|
| 465 |
+
const ocrProcessing = document.getElementById('ocr-processing');
|
| 466 |
+
const ocrProgress = document.getElementById('ocr-progress');
|
| 467 |
+
const ocrText = document.getElementById('ocr-text');
|
| 468 |
+
const rawOcrResults = document.getElementById('raw-ocr-results');
|
| 469 |
+
|
| 470 |
+
// Camera variables
|
| 471 |
+
let stream = null;
|
| 472 |
+
let facingMode = 'environment'; // Default to rear camera
|
| 473 |
+
let isScanning = false;
|
| 474 |
+
|
| 475 |
+
// Initialize the app
|
| 476 |
+
function initApp() {
|
| 477 |
+
// Apply settings
|
| 478 |
+
darkModeToggle.checked = settings.darkMode;
|
| 479 |
+
soundToggle.checked = settings.scanSound;
|
| 480 |
+
autosaveToggle.checked = settings.autoSave;
|
| 481 |
+
|
| 482 |
+
if (settings.darkMode) {
|
| 483 |
+
document.body.classList.add('bg-gray-900');
|
| 484 |
+
document.body.classList.remove('bg-gray-100');
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
+
// Load account data
|
| 488 |
+
accountName.textContent = accountData.name;
|
| 489 |
+
accountEmail.textContent = accountData.email;
|
| 490 |
+
nameInput.value = accountData.name;
|
| 491 |
+
emailInput.value = accountData.email;
|
| 492 |
+
|
| 493 |
+
// Load history and saved scans
|
| 494 |
+
renderHistory();
|
| 495 |
+
renderSavedScans();
|
| 496 |
+
|
| 497 |
+
// Show OCR debug if enabled
|
| 498 |
+
if (settings.showOcrResults) {
|
| 499 |
+
rawOcrResults.classList.remove('hidden');
|
| 500 |
+
}
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
// Tab switching functionality
|
| 504 |
+
vehicleTab.addEventListener('click', () => {
|
| 505 |
+
vehicleTab.classList.remove('text-gray-500');
|
| 506 |
+
vehicleTab.classList.add('text-blue-600');
|
| 507 |
+
driverTab.classList.remove('text-blue-600');
|
| 508 |
+
driverTab.classList.add('text-gray-500');
|
| 509 |
+
tabIndicator.style.transform = 'translateX(0)';
|
| 510 |
+
scanInstruction.textContent = 'Align vehicle license disk within frame';
|
| 511 |
+
});
|
| 512 |
+
|
| 513 |
+
driverTab.addEventListener('click', () => {
|
| 514 |
+
driverTab.classList.remove('text-gray-500');
|
| 515 |
+
driverTab.classList.add('text-blue-600');
|
| 516 |
+
vehicleTab.classList.remove('text-blue-600');
|
| 517 |
+
vehicleTab.classList.add('text-gray-500');
|
| 518 |
+
tabIndicator.style.transform = 'translateX(100%)';
|
| 519 |
+
scanInstruction.textContent = 'Align driver license within frame';
|
| 520 |
+
});
|
| 521 |
+
|
| 522 |
+
// Start camera function
|
| 523 |
+
async function startCamera() {
|
| 524 |
+
try {
|
| 525 |
+
// Check if camera is already running
|
| 526 |
+
if (stream) {
|
| 527 |
+
stopCamera();
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
// Request camera access
|
| 531 |
+
stream = await navigator.mediaDevices.getUserMedia({
|
| 532 |
+
video: {
|
| 533 |
+
facingMode: facingMode,
|
| 534 |
+
width: { ideal: 1280 },
|
| 535 |
+
height: { ideal: 720 }
|
| 536 |
+
},
|
| 537 |
+
audio: false
|
| 538 |
+
});
|
| 539 |
+
|
| 540 |
+
// Show video element
|
| 541 |
+
videoElement.srcObject = stream;
|
| 542 |
+
videoElement.play();
|
| 543 |
+
scannerPlaceholder.classList.add('hidden');
|
| 544 |
+
cameraControls.classList.remove('hidden');
|
| 545 |
+
switchCamera.classList.remove('hidden');
|
| 546 |
+
|
| 547 |
+
// Change scan button to cancel
|
| 548 |
+
scanButton.innerHTML = '<i class="fas fa-times mr-2"></i> CANCEL';
|
| 549 |
+
scanButton.classList.remove('bg-blue-600');
|
| 550 |
+
scanButton.classList.add('bg-red-600');
|
| 551 |
+
|
| 552 |
+
// Enable capture button
|
| 553 |
+
captureBtn.disabled = false;
|
| 554 |
+
|
| 555 |
+
return true;
|
| 556 |
+
} catch (err) {
|
| 557 |
+
console.error('Error accessing camera:', err);
|
| 558 |
+
alert('Could not access the camera. Please ensure you have granted camera permissions.');
|
| 559 |
+
resetScanner();
|
| 560 |
+
return false;
|
| 561 |
+
}
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
// Stop camera function
|
| 565 |
+
function stopCamera() {
|
| 566 |
+
if (stream) {
|
| 567 |
+
stream.getTracks().forEach(track => track.stop());
|
| 568 |
+
stream = null;
|
| 569 |
+
}
|
| 570 |
+
videoElement.srcObject = null;
|
| 571 |
+
scannerPlaceholder.classList.remove('hidden');
|
| 572 |
+
cameraControls.classList.add('hidden');
|
| 573 |
+
switchCamera.classList.add('hidden');
|
| 574 |
+
|
| 575 |
+
// Reset scan button
|
| 576 |
+
scanButton.innerHTML = '<i class="fas fa-camera mr-2"></i> SCAN NOW';
|
| 577 |
+
scanButton.classList.remove('bg-red-600');
|
| 578 |
+
scanButton.classList.add('bg-blue-600');
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
// Switch between front and back camera
|
| 582 |
+
switchCamera.addEventListener('click', async () => {
|
| 583 |
+
facingMode = facingMode === 'user' ? 'environment' : 'user';
|
| 584 |
+
await startCamera();
|
| 585 |
+
});
|
| 586 |
+
|
| 587 |
+
// Process image with OCR
|
| 588 |
+
async function processImageWithOCR(imageData) {
|
| 589 |
+
ocrProcessing.classList.remove('hidden');
|
| 590 |
+
|
| 591 |
+
try {
|
| 592 |
+
const result = await Tesseract.recognize(
|
| 593 |
+
imageData,
|
| 594 |
+
'eng', // English language
|
| 595 |
+
{
|
| 596 |
+
logger: m => {
|
| 597 |
+
if (m.status === 'recognizing text') {
|
| 598 |
+
ocrProgress.textContent = `OCR Progress: ${Math.round(m.progress * 100)}%`;
|
| 599 |
+
} else {
|
| 600 |
+
ocrProgress.textContent = `Status: ${m.status}`;
|
| 601 |
+
}
|
| 602 |
+
}
|
| 603 |
+
}
|
| 604 |
+
);
|
| 605 |
+
|
| 606 |
+
// Show raw OCR results for debugging
|
| 607 |
+
if (settings.showOcrResults) {
|
| 608 |
+
ocrText.textContent = result.data.text;
|
| 609 |
+
rawOcrResults.classList.remove('hidden');
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
// Parse the OCR results to extract license information
|
| 613 |
+
return parseLicenseData(result.data.text);
|
| 614 |
+
|
| 615 |
+
} catch (error) {
|
| 616 |
+
console.error('OCR Error:', error);
|
| 617 |
+
return null;
|
| 618 |
+
} finally {
|
| 619 |
+
ocrProcessing.classList.add('hidden');
|
| 620 |
+
}
|
| 621 |
+
}
|
| 622 |
+
|
| 623 |
+
// Parse OCR text to extract license information
|
| 624 |
+
function parseLicenseData(ocrText) {
|
| 625 |
+
const isVehicle = vehicleTab.classList.contains('text-blue-600');
|
| 626 |
+
|
| 627 |
+
// Convert to uppercase for easier matching
|
| 628 |
+
const text = ocrText.toUpperCase();
|
| 629 |
+
|
| 630 |
+
if (isVehicle) {
|
| 631 |
+
// Parse vehicle license disk
|
| 632 |
+
const regNumberMatch = text.match(/([A-Z]{1,2}\s?\d{1,3}\s?[-]?\s?\d{1,6})/);
|
| 633 |
+
const makeModelMatch = text.match(/(TOYOTA|FORD|BMW|VOLKSWAGEN|MERCEDES|AUDI|NISSAN|HYUNDAI|KIA|MAZDA|HONDA|SUZUKI|VOLVO|CHEVROLET|JEEP|MITSUBISHI|SUBARU|LEXUS|LAND ROVER|RANGE ROVER|ISUZU|PEUGEOT|CITROEN|RENAULT|OPEL|PORSCHE|MINI|JAGUAR|FIAT|ALFA ROMEO|CHRYSLER|DODGE|BUICK|CADILLAC|GMC|LINCOLN|TESLA|FERRARI|LAMBORGHINI|MASERATI|BENTLEY|ROLLS ROYCE|ASTON MARTIN|LOTUS|MCLAREN|BUGATTI|PAGANI|KOENIGSEGG)\s?([A-Z0-9\s]+)?/i);
|
| 634 |
+
const yearMatch = text.match(/(19|20)\d{2}/);
|
| 635 |
+
const expiryMatch = text.match(/(\d{1,2}\s?(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\s?(20)\d{2})/i);
|
| 636 |
+
|
| 637 |
+
return {
|
| 638 |
+
type: 'vehicle',
|
| 639 |
+
regNumber: regNumberMatch ? regNumberMatch[0].replace(/\s/g, ' ') : 'Not found',
|
| 640 |
+
make: makeModelMatch ? makeModelMatch[0] : 'Not found',
|
| 641 |
+
year: yearMatch ? yearMatch[0] : 'Not found',
|
| 642 |
+
expiry: expiryMatch ? expiryMatch[0] : 'Not found',
|
| 643 |
+
owner: 'Not found', // Hard to extract from OCR
|
| 644 |
+
info: 'Information extracted from license scan',
|
| 645 |
+
timestamp: new Date().toISOString(),
|
| 646 |
+
imageData: imageData
|
| 647 |
+
};
|
| 648 |
+
} else {
|
| 649 |
+
// Parse driver's license
|
| 650 |
+
const nameMatch = text.match(/[A-Z]{2,}\s[A-Z]{2,}/);
|
| 651 |
+
const idMatch = text.match(/\d{13}/);
|
| 652 |
+
const codeMatch = text.match(/[A-Z]\b/);
|
| 653 |
+
const expiryMatch = text.match(/(\d{1,2}\s?(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)\s?(20)\d{2})/i);
|
| 654 |
+
const issuedMatch = text.match(/(GAUTENG|WESTERN CAPE|EASTERN CAPE|NORTHERN CAPE|FREE STATE|KWAZULU-NATAL|NORTH WEST|MPUMALANGA|LIMPOPO)/i);
|
| 655 |
+
|
| 656 |
+
return {
|
| 657 |
+
type: 'driver',
|
| 658 |
+
name: nameMatch ? nameMatch[0] : 'Not found',
|
| 659 |
+
id: idMatch ? idMatch[0] : 'Not found',
|
| 660 |
+
code: codeMatch ? codeMatch[0] : 'Not found',
|
| 661 |
+
expiry: expiryMatch ? expiryMatch[0] : 'Not found',
|
| 662 |
+
issued: issuedMatch ? issuedMatch[0] : 'Not found',
|
| 663 |
+
info: 'Information extracted from license scan',
|
| 664 |
+
timestamp: new Date().toISOString(),
|
| 665 |
+
imageData: imageData
|
| 666 |
+
};
|
| 667 |
+
}
|
| 668 |
+
}
|
| 669 |
+
|
| 670 |
+
// Capture image from camera
|
| 671 |
+
captureBtn.addEventListener('click', async () => {
|
| 672 |
+
if (!stream) return;
|
| 673 |
+
|
| 674 |
+
// Play capture sound if enabled
|
| 675 |
+
if (settings.scanSound) {
|
| 676 |
+
const audio = new Audio('https://assets.mixkit.co/sfx/preview/mixkit-camera-shutter-click-1131.mp3');
|
| 677 |
+
audio.volume = 0.3;
|
| 678 |
+
audio.play();
|
| 679 |
+
}
|
| 680 |
+
|
| 681 |
+
// Show scanning animation
|
| 682 |
+
scanLine.classList.remove('hidden');
|
| 683 |
+
|
| 684 |
+
// Set canvas dimensions to match video
|
| 685 |
+
canvas.width = videoElement.videoWidth;
|
| 686 |
+
canvas.height = videoElement.videoHeight;
|
| 687 |
+
|
| 688 |
+
// Draw current video frame to canvas
|
| 689 |
+
const context = canvas.getContext('2d');
|
| 690 |
+
context.drawImage(videoElement, 0, 0, canvas.width, canvas.height);
|
| 691 |
+
|
| 692 |
+
// Get image data URL
|
| 693 |
+
const imageData = canvas.toDataURL('image/jpeg');
|
| 694 |
+
|
| 695 |
+
// Process with OCR
|
| 696 |
+
const scanData = await processImageWithOCR(imageData);
|
| 697 |
+
|
| 698 |
+
// Stop camera after processing
|
| 699 |
+
stopCamera();
|
| 700 |
+
scanLine.classList.add('hidden');
|
| 701 |
+
|
| 702 |
+
// Show results
|
| 703 |
+
scannerView.classList.add('hidden');
|
| 704 |
+
resultsSection.classList.remove('hidden');
|
| 705 |
+
|
| 706 |
+
// Add to history
|
| 707 |
+
if (scanData) {
|
| 708 |
+
scanHistory.unshift(scanData);
|
| 709 |
+
if (scanHistory.length > 50) scanHistory.pop(); // Limit history
|
| 710 |
+
localStorage.setItem('scanHistory', JSON.stringify(scanHistory));
|
| 711 |
+
renderHistory();
|
| 712 |
+
|
| 713 |
+
// Auto-save if enabled
|
| 714 |
+
if (settings.autoSave) {
|
| 715 |
+
savedScans.unshift(scanData);
|
| 716 |
+
if (savedScans.length > 100) savedScans.pop(); // Limit saved
|
| 717 |
+
localStorage.setItem('savedScans', JSON.stringify(savedScans));
|
| 718 |
+
renderSavedScans();
|
| 719 |
+
}
|
| 720 |
+
|
| 721 |
+
// Populate with appropriate data
|
| 722 |
+
if (scanData.type === 'vehicle') {
|
| 723 |
+
// Vehicle results
|
| 724 |
+
resultTitle.textContent = 'Vehicle Details';
|
| 725 |
+
document.getElementById('reg-number').textContent = scanData.regNumber;
|
| 726 |
+
document.getElementById('vehicle-make').textContent = scanData.make;
|
| 727 |
+
document.getElementById('vehicle-year').textContent = scanData.year;
|
| 728 |
+
document.getElementById('license-expiry').textContent = scanData.expiry;
|
| 729 |
+
document.getElementById('vehicle-owner').textContent = scanData.owner;
|
| 730 |
+
additionalInfo.textContent = scanData.info;
|
| 731 |
+
vehicleResult.classList.remove('hidden');
|
| 732 |
+
driverResult.classList.add('hidden');
|
| 733 |
+
additionalInfo.classList.remove('hidden');
|
| 734 |
+
driverAdditional.classList.add('hidden');
|
| 735 |
+
} else {
|
| 736 |
+
// Driver results
|
| 737 |
+
resultTitle.textContent = 'Driver License Details';
|
| 738 |
+
document.getElementById('driver-name').textContent = scanData.name;
|
| 739 |
+
document.getElementById('driver-id').textContent = scanData.id;
|
| 740 |
+
document.getElementById('license-code').textContent = scanData.code;
|
| 741 |
+
document.getElementById('driver-license-expiry').textContent = scanData.expiry;
|
| 742 |
+
document.getElementById('license-issued').textContent = scanData.issued;
|
| 743 |
+
driverAdditional.textContent = scanData.info;
|
| 744 |
+
vehicleResult.classList.add('hidden');
|
| 745 |
+
driverResult.classList.remove('hidden');
|
| 746 |
+
additionalInfo.classList.add('hidden');
|
| 747 |
+
driverAdditional.classList.remove('hidden');
|
| 748 |
+
}
|
| 749 |
+
} else {
|
| 750 |
+
// OCR failed
|
| 751 |
+
alert('Could not read license information. Please try again with better lighting and focus.');
|
| 752 |
+
resetScanner();
|
| 753 |
+
return;
|
| 754 |
+
}
|
| 755 |
+
|
| 756 |
+
// Animate results in
|
| 757 |
+
const resultCards = document.querySelectorAll('.result-card');
|
| 758 |
+
resultCards.forEach((card, index) => {
|
| 759 |
+
setTimeout(() => {
|
| 760 |
+
card.classList.add('show');
|
| 761 |
+
}, index * 100);
|
| 762 |
+
});
|
| 763 |
+
});
|
| 764 |
+
|
| 765 |
+
// Cancel capture
|
| 766 |
+
cancelCapture.addEventListener('click', () => {
|
| 767 |
+
stopCamera();
|
| 768 |
+
});
|
| 769 |
+
|
| 770 |
+
// Scan button functionality
|
| 771 |
+
scanButton.addEventListener('click', async () => {
|
| 772 |
+
if (stream) {
|
| 773 |
+
// If camera is running, this is a cancel action
|
| 774 |
+
stopCamera();
|
| 775 |
+
return;
|
| 776 |
+
}
|
| 777 |
+
|
| 778 |
+
// Start camera for scanning
|
| 779 |
+
const cameraStarted = await startCamera();
|
| 780 |
+
if (!cameraStarted) {
|
| 781 |
+
resetScanner();
|
| 782 |
+
}
|
| 783 |
+
});
|
| 784 |
+
|
| 785 |
+
// Manual entry button
|
| 786 |
+
manualEntryBtn.addEventListener('click', () => {
|
| 787 |
+
// For demo purposes, we'll just show sample data
|
| 788 |
+
scannerView.classList.add('hidden');
|
| 789 |
+
resultsSection.classList.remove('hidden');
|
| 790 |
+
|
| 791 |
+
// Determine which data to use based on selected tab
|
| 792 |
+
const isVehicle = vehicleTab.classList.contains('text-blue-600');
|
| 793 |
+
const scanData = isVehicle ? {
|
| 794 |
+
type: 'vehicle',
|
| 795 |
+
regNumber: 'CA 123-456',
|
| 796 |
+
make: 'Toyota Hilux',
|
| 797 |
+
year: '2020',
|
| 798 |
+
expiry: '31 Dec 2023',
|
| 799 |
+
owner: 'John Doe',
|
| 800 |
+
info: 'Manually entered vehicle information',
|
| 801 |
+
timestamp: new Date().toISOString(),
|
| 802 |
+
imageData: null
|
| 803 |
+
} : {
|
| 804 |
+
type: 'driver',
|
| 805 |
+
name: 'Sarah Johnson',
|
| 806 |
+
id: '9001011234088',
|
| 807 |
+
code: 'B',
|
| 808 |
+
expiry: '31 Dec 2028',
|
| 809 |
+
issued: 'Gauteng',
|
| 810 |
+
info: 'Manually entered driver license information',
|
| 811 |
+
timestamp: new Date().toISOString(),
|
| 812 |
+
imageData: null
|
| 813 |
+
};
|
| 814 |
+
|
| 815 |
+
// Add to history
|
| 816 |
+
scanHistory.unshift(scanData);
|
| 817 |
+
if (scanHistory.length > 50) scanHistory.pop(); // Limit history
|
| 818 |
+
localStorage.setItem('scanHistory', JSON.stringify(scanHistory));
|
| 819 |
+
renderHistory();
|
| 820 |
+
|
| 821 |
+
// Auto-save if enabled
|
| 822 |
+
if (settings.autoSave) {
|
| 823 |
+
savedScans.unshift(scanData);
|
| 824 |
+
if (savedScans.length > 100) savedScans.pop(); // Limit saved
|
| 825 |
+
localStorage.setItem('savedScans', JSON.stringify(savedScans));
|
| 826 |
+
renderSavedScans();
|
| 827 |
+
}
|
| 828 |
+
|
| 829 |
+
// Populate with appropriate data
|
| 830 |
+
if (isVehicle) {
|
| 831 |
+
// Vehicle results
|
| 832 |
+
resultTitle.textContent = 'Vehicle Details';
|
| 833 |
+
document.getElementById('reg-number').textContent = scanData.regNumber;
|
| 834 |
+
document.getElementById('vehicle-make').textContent = scanData.make;
|
| 835 |
+
document.getElementById('vehicle-year').textContent = scanData.year;
|
| 836 |
+
document.getElementById('license-expiry').textContent = scanData.expiry;
|
| 837 |
+
document.getElementById('vehicle-owner').textContent = scanData.owner;
|
| 838 |
+
additionalInfo.textContent = scanData.info;
|
| 839 |
+
vehicleResult.classList.remove('hidden');
|
| 840 |
+
driverResult.classList.add('hidden');
|
| 841 |
+
additionalInfo.classList.remove('hidden');
|
| 842 |
+
driverAdditional.classList.add('hidden');
|
| 843 |
+
} else {
|
| 844 |
+
// Driver results
|
| 845 |
+
resultTitle.textContent = 'Driver License Details';
|
| 846 |
+
document.getElementById('driver-name').textContent = scanData.name;
|
| 847 |
+
document.getElementById('driver-id').textContent = scanData.id;
|
| 848 |
+
document.getElementById('license-code').textContent = scanData.code;
|
| 849 |
+
document.getElementById('driver-license-expiry').textContent = scanData.expiry;
|
| 850 |
+
document.getElementById('license-issued').textContent = scanData.issued;
|
| 851 |
+
driverAdditional.textContent = scanData.info;
|
| 852 |
+
vehicleResult.classList.add('hidden');
|
| 853 |
+
driverResult.classList.remove('hidden');
|
| 854 |
+
additionalInfo.classList.add('hidden');
|
| 855 |
+
driverAdditional.classList.remove('hidden');
|
| 856 |
+
}
|
| 857 |
+
|
| 858 |
+
// Animate results in
|
| 859 |
+
const resultCards = document.querySelectorAll('.result-card');
|
| 860 |
+
resultCards.forEach((card, index) => {
|
| 861 |
+
setTimeout(() => {
|
| 862 |
+
card.classList.add('show');
|
| 863 |
+
}, index * 100);
|
| 864 |
+
});
|
| 865 |
+
});
|
| 866 |
+
|
| 867 |
+
// Save button functionality
|
| 868 |
+
saveBtn.addEventListener('click', () => {
|
| 869 |
+
const isVehicle = vehicleTab.classList.contains('text-blue-600');
|
| 870 |
+
const currentData = isVehicle ? {
|
| 871 |
+
type: 'vehicle',
|
| 872 |
+
regNumber: document.getElementById('reg-number').textContent,
|
| 873 |
+
make: document.getElementById('vehicle-make').textContent,
|
| 874 |
+
year: document.getElementById('vehicle-year').textContent,
|
| 875 |
+
expiry: document.getElementById('license-expiry').textContent,
|
| 876 |
+
owner: document.getElementById('vehicle-owner').textContent,
|
| 877 |
+
info: additionalInfo.textContent,
|
| 878 |
+
timestamp: new Date().toISOString()
|
| 879 |
+
} : {
|
| 880 |
+
type: 'driver',
|
| 881 |
+
name: document.getElementById('driver-name').textContent,
|
| 882 |
+
id: document.getElementById('driver-id').textContent,
|
| 883 |
+
code: document.getElementById('license-code').textContent,
|
| 884 |
+
expiry: document.getElementById('driver-license-expiry').textContent,
|
| 885 |
+
issued: document.getElementById('license-issued').textContent,
|
| 886 |
+
info: driverAdditional.textContent,
|
| 887 |
+
timestamp: new Date().toISOString()
|
| 888 |
+
};
|
| 889 |
+
|
| 890 |
+
// Check if already saved
|
| 891 |
+
const isAlreadySaved = savedScans.some(item =>
|
| 892 |
+
item.type === currentData.type &&
|
| 893 |
+
(item.regNumber === currentData.regNumber || item.id === currentData.id)
|
| 894 |
+
);
|
| 895 |
+
|
| 896 |
+
if (isAlreadySaved) {
|
| 897 |
+
alert('This scan is already saved.');
|
| 898 |
+
return;
|
| 899 |
+
}
|
| 900 |
+
|
| 901 |
+
savedScans.unshift(currentData);
|
| 902 |
+
localStorage.setItem('savedScans', JSON.stringify(savedScans));
|
| 903 |
+
renderSavedScans();
|
| 904 |
+
|
| 905 |
+
// Show confirmation
|
| 906 |
+
const originalText = saveBtn.innerHTML;
|
| 907 |
+
saveBtn.innerHTML = '<i class="fas fa-check mr-1"></i> Saved';
|
| 908 |
+
setTimeout(() => {
|
| 909 |
+
saveBtn.innerHTML = originalText;
|
| 910 |
+
}, 2000);
|
| 911 |
+
});
|
| 912 |
+
|
| 913 |
+
// Share button functionality
|
| 914 |
+
shareBtn.addEventListener('click', () => {
|
| 915 |
+
const isVehicle = vehicleTab.classList.contains('text-blue-600');
|
| 916 |
+
const data = isVehicle ?
|
| 917 |
+
`Vehicle Details:\nRegistration: ${document.getElementById('reg-number').textContent}\nMake/Model: ${document.getElementById('vehicle-make').textContent}\nYear: ${document.getElementById('vehicle-year').textContent}\nExpiry: ${document.getElementById('license-expiry').textContent}\nOwner: ${document.getElementById('vehicle-owner').textContent}` :
|
| 918 |
+
`Driver License Details:\nName: ${document.getElementById('driver-name').textContent}\nID: ${document.getElementById('driver-id').textContent}\nLicense Code: ${document.getElementById('license-code').textContent}\nExpiry: ${document.getElementById('driver-license-expiry').textContent}\nIssued: ${document.getElementById('license-issued').textContent}`;
|
| 919 |
+
|
| 920 |
+
if (navigator.share) {
|
| 921 |
+
navigator.share({
|
| 922 |
+
title: 'ZA License Scan Results',
|
| 923 |
+
text: data,
|
| 924 |
+
}).catch(err => {
|
| 925 |
+
console.log('Error sharing:', err);
|
| 926 |
+
copyToClipboard(data);
|
| 927 |
+
});
|
| 928 |
+
} else {
|
| 929 |
+
copyToClipboard(data);
|
| 930 |
+
}
|
| 931 |
+
});
|
| 932 |
+
|
| 933 |
+
// Print button functionality
|
| 934 |
+
printBtn.addEventListener('click', () => {
|
| 935 |
+
window.print();
|
| 936 |
+
});
|
| 937 |
+
|
| 938 |
+
// Copy to clipboard helper
|
| 939 |
+
function copyToClipboard(text) {
|
| 940 |
+
const textarea = document.createElement('textarea');
|
| 941 |
+
textarea.value = text;
|
| 942 |
+
document.body.appendChild(textarea);
|
| 943 |
+
textarea.select();
|
| 944 |
+
document.execCommand('copy');
|
| 945 |
+
document.body.removeChild(textarea);
|
| 946 |
+
alert('Scan results copied to clipboard!');
|
| 947 |
+
}
|
| 948 |
+
|
| 949 |
+
// Render history list
|
| 950 |
+
function renderHistory() {
|
| 951 |
+
historyList.innerHTML = '';
|
| 952 |
+
|
| 953 |
+
if (scanHistory.length === 0) {
|
| 954 |
+
emptyHistory.classList.remove('hidden');
|
| 955 |
+
return;
|
| 956 |
+
}
|
| 957 |
+
|
| 958 |
+
emptyHistory.classList.add('hidden');
|
| 959 |
+
|
| 960 |
+
scanHistory.forEach((item, index) => {
|
| 961 |
+
const historyItem = document.createElement('div');
|
| 962 |
+
historyItem.className = 'bg-white rounded-lg shadow p-3 flex justify-between items-center';
|
| 963 |
+
|
| 964 |
+
if (item.type === 'vehicle') {
|
| 965 |
+
historyItem.innerHTML = `
|
| 966 |
+
<div>
|
| 967 |
+
<div class="font-medium">${item.regNumber}</div>
|
| 968 |
+
<div class="text-sm text-gray-500">${item.make} • ${new Date(item.timestamp).toLocaleString()}</div>
|
| 969 |
+
</div>
|
| 970 |
+
<button class="text-blue-600 save-history-item" data-index="${index}">
|
| 971 |
+
<i class="fas fa-bookmark"></i>
|
| 972 |
+
</button>
|
| 973 |
+
`;
|
| 974 |
+
} else {
|
| 975 |
+
historyItem.innerHTML = `
|
| 976 |
+
<div>
|
| 977 |
+
<div class="font-medium">${item.name}</div>
|
| 978 |
+
<div class="text-sm text-gray-500">${item.id} • ${new Date(item.timestamp).toLocaleString()}</div>
|
| 979 |
+
</div>
|
| 980 |
+
<button class="text-blue-600 save-history-item" data-index="${index}">
|
| 981 |
+
<i class="fas fa-bookmark"></i>
|
| 982 |
+
</button>
|
| 983 |
+
`;
|
| 984 |
+
}
|
| 985 |
+
|
| 986 |
+
historyList.appendChild(historyItem);
|
| 987 |
+
});
|
| 988 |
+
|
| 989 |
+
// Add event listeners to save buttons
|
| 990 |
+
document.querySelectorAll('.save-history-item').forEach(btn => {
|
| 991 |
+
btn.addEventListener('click', (e) => {
|
| 992 |
+
const index = e.currentTarget.getAttribute('data-index');
|
| 993 |
+
const item = scanHistory[index];
|
| 994 |
+
|
| 995 |
+
// Check if already saved
|
| 996 |
+
const isAlreadySaved = savedScans.some(savedItem =>
|
| 997 |
+
savedItem.type === item.type &&
|
| 998 |
+
(savedItem.regNumber === item.regNumber || savedItem.id === item.id)
|
| 999 |
+
);
|
| 1000 |
+
|
| 1001 |
+
if (isAlreadySaved) {
|
| 1002 |
+
alert('This scan is already saved.');
|
| 1003 |
+
return;
|
| 1004 |
+
}
|
| 1005 |
+
|
| 1006 |
+
savedScans.unshift(item);
|
| 1007 |
+
localStorage.setItem('savedScans', JSON.stringify(savedScans));
|
| 1008 |
+
renderSavedScans();
|
| 1009 |
+
|
| 1010 |
+
// Show confirmation
|
| 1011 |
+
e.currentTarget.innerHTML = '<i class="fas fa-check"></i>';
|
| 1012 |
+
setTimeout(() => {
|
| 1013 |
+
e.currentTarget.innerHTML = '<i class="fas fa-bookmark"></i>';
|
| 1014 |
+
}, 1000);
|
| 1015 |
+
});
|
| 1016 |
+
});
|
| 1017 |
+
}
|
| 1018 |
+
|
| 1019 |
+
// Render saved scans list
|
| 1020 |
+
function renderSavedScans() {
|
| 1021 |
+
savedList.innerHTML = '';
|
| 1022 |
+
|
| 1023 |
+
if (savedScans.length === 0) {
|
| 1024 |
+
emptySaved.classList.remove('hidden');
|
| 1025 |
+
return;
|
| 1026 |
+
}
|
| 1027 |
+
|
| 1028 |
+
emptySaved.classList.add('hidden');
|
| 1029 |
+
|
| 1030 |
+
savedScans.forEach((item, index) => {
|
| 1031 |
+
const savedItem = document.createElement('div');
|
| 1032 |
+
savedItem.className = 'bg-white rounded-lg shadow p-3 flex justify-between items-center';
|
| 1033 |
+
|
| 1034 |
+
if (item.type === 'vehicle') {
|
| 1035 |
+
savedItem.innerHTML = `
|
| 1036 |
+
<div>
|
| 1037 |
+
<div class="font-medium">${item.regNumber}</div>
|
| 1038 |
+
<div class="text-sm text-gray-500">${item.make} • ${new Date(item.timestamp).toLocaleString()}</div>
|
| 1039 |
+
</div>
|
| 1040 |
+
<button class="text-red-600 remove-saved-item" data-index="${index}">
|
| 1041 |
+
<i class="fas fa-trash"></i>
|
| 1042 |
+
</button>
|
| 1043 |
+
`;
|
| 1044 |
+
} else {
|
| 1045 |
+
savedItem.innerHTML = `
|
| 1046 |
+
<div>
|
| 1047 |
+
<div class="font-medium">${item.name}</div>
|
| 1048 |
+
<div class="text-sm text-gray-500">${item.id} • ${new Date(item.timestamp).toLocaleString()}</div>
|
| 1049 |
+
</div>
|
| 1050 |
+
<button class="text-red-600 remove-saved-item" data-index="${index}">
|
| 1051 |
+
<i class="fas fa-trash"></i>
|
| 1052 |
+
</button>
|
| 1053 |
+
`;
|
| 1054 |
+
}
|
| 1055 |
+
|
| 1056 |
+
savedList.appendChild(savedItem);
|
| 1057 |
+
});
|
| 1058 |
+
|
| 1059 |
+
// Add event listeners to remove buttons
|
| 1060 |
+
document.querySelectorAll('.remove-saved-item').forEach(btn => {
|
| 1061 |
+
btn.addEventListener('click', (e) => {
|
| 1062 |
+
const index = e.currentTarget.getAttribute('data-index');
|
| 1063 |
+
savedScans.splice(index, 1);
|
| 1064 |
+
localStorage.setItem('savedScans', JSON.stringify(savedScans));
|
| 1065 |
+
renderSavedScans();
|
| 1066 |
+
});
|
| 1067 |
+
});
|
| 1068 |
+
}
|
| 1069 |
+
|
| 1070 |
+
// Clear history
|
| 1071 |
+
clearHistory.addEventListener('click', () => {
|
| 1072 |
+
if (confirm('Are you sure you want to clear all scan history?')) {
|
| 1073 |
+
scanHistory = [];
|
| 1074 |
+
localStorage.setItem('scanHistory', JSON.stringify(scanHistory));
|
| 1075 |
+
renderHistory();
|
| 1076 |
+
}
|
| 1077 |
+
});
|
| 1078 |
+
|
| 1079 |
+
// Clear saved scans
|
| 1080 |
+
clearSaved.addEventListener('click', () => {
|
| 1081 |
+
if (confirm('Are you sure you want to clear all saved scans?')) {
|
| 1082 |
+
savedScans = [];
|
| 1083 |
+
localStorage.setItem('savedScans', JSON.stringify(savedScans));
|
| 1084 |
+
renderSavedScans();
|
| 1085 |
+
}
|
| 1086 |
+
});
|
| 1087 |
+
|
| 1088 |
+
// Save account settings
|
| 1089 |
+
saveAccount.addEventListener('click', () => {
|
| 1090 |
+
accountData.name = nameInput.value;
|
| 1091 |
+
accountData.email = emailInput.value;
|
| 1092 |
+
if (passwordInput.value) {
|
| 1093 |
+
accountData.password = passwordInput.value;
|
| 1094 |
+
passwordInput.value = '';
|
| 1095 |
+
}
|
| 1096 |
+
|
| 1097 |
+
localStorage.setItem('accountData', JSON.stringify(accountData));
|
| 1098 |
+
|
| 1099 |
+
accountName.textContent = accountData.name;
|
| 1100 |
+
accountEmail.textContent = accountData.email;
|
| 1101 |
+
|
| 1102 |
+
// Show confirmation
|
| 1103 |
+
const originalText = saveAccount.innerHTML;
|
| 1104 |
+
saveAccount.innerHTML = '<i class="fas fa-check mr-1"></i> Saved';
|
| 1105 |
+
setTimeout(() => {
|
| 1106 |
+
saveAccount.innerHTML = originalText;
|
| 1107 |
+
}, 2000);
|
| 1108 |
+
});
|
| 1109 |
+
|
| 1110 |
+
// Logout
|
| 1111 |
+
logoutBtn.addEventListener('click', () => {
|
| 1112 |
+
if (confirm('Are you sure you want to logout?')) {
|
| 1113 |
+
// Reset account to guest
|
| 1114 |
+
accountData = {
|
| 1115 |
+
name: "Guest User",
|
| 1116 |
+
email: "guest@example.com",
|
| 1117 |
+
password: ""
|
| 1118 |
+
};
|
| 1119 |
+
localStorage.setItem('accountData', JSON.stringify(accountData));
|
| 1120 |
+
|
| 1121 |
+
// Update UI
|
| 1122 |
+
accountName.textContent = accountData.name;
|
| 1123 |
+
accountEmail.textContent = accountData.email;
|
| 1124 |
+
nameInput.value = accountData.name;
|
| 1125 |
+
emailInput.value = accountData.email;
|
| 1126 |
+
passwordInput.value = '';
|
| 1127 |
+
|
| 1128 |
+
// Go to scanner page
|
| 1129 |
+
showPage('scanner-page');
|
| 1130 |
+
updateNavButtons('scanner-page');
|
| 1131 |
+
}
|
| 1132 |
+
});
|
| 1133 |
+
|
| 1134 |
+
// Settings toggles
|
| 1135 |
+
darkModeToggle.addEventListener('change', () => {
|
| 1136 |
+
settings.darkMode = darkModeToggle.checked;
|
| 1137 |
+
localStorage.setItem('settings', JSON.stringify(settings));
|
| 1138 |
+
|
| 1139 |
+
if (settings.darkMode) {
|
| 1140 |
+
document.body.classList.add('bg-gray-900');
|
| 1141 |
+
document.body.classList.remove('bg-gray-100');
|
| 1142 |
+
} else {
|
| 1143 |
+
document.body.classList.remove('bg-gray-900');
|
| 1144 |
+
document.body.classList.add('bg-gray-100');
|
| 1145 |
+
}
|
| 1146 |
+
});
|
| 1147 |
+
|
| 1148 |
+
soundToggle.addEventListener('change', () => {
|
| 1149 |
+
settings.scanSound = soundToggle.checked;
|
| 1150 |
+
localStorage.setItem('settings', JSON.stringify(settings));
|
| 1151 |
+
});
|
| 1152 |
+
|
| 1153 |
+
autosaveToggle.addEventListener('change', () => {
|
| 1154 |
+
settings.autoSave = autosaveToggle.checked;
|
| 1155 |
+
localStorage.setItem('settings', JSON.stringify(settings));
|
| 1156 |
+
});
|
| 1157 |
+
|
| 1158 |
+
// Navigation buttons
|
| 1159 |
+
historyBtn.addEventListener('click', () => {
|
| 1160 |
+
showPage('history-page');
|
| 1161 |
+
updateNavButtons('history-page');
|
| 1162 |
+
});
|
| 1163 |
+
|
| 1164 |
+
settingsBtn.addEventListener('click', () => {
|
| 1165 |
+
showPage('account-page');
|
| 1166 |
+
updateNavButtons('account-page');
|
| 1167 |
+
});
|
| 1168 |
+
|
| 1169 |
+
navBtns.forEach(btn => {
|
| 1170 |
+
btn.addEventListener('click', () => {
|
| 1171 |
+
const page = btn.getAttribute('data-page');
|
| 1172 |
+
showPage(page);
|
| 1173 |
+
updateNavButtons(page);
|
| 1174 |
+
});
|
| 1175 |
+
});
|
| 1176 |
+
|
| 1177 |
+
// Show page function
|
| 1178 |
+
function showPage(pageId) {
|
| 1179 |
+
pages.forEach(page => {
|
| 1180 |
+
if (page.id === pageId) {
|
| 1181 |
+
page.classList.add('active');
|
| 1182 |
+
} else {
|
| 1183 |
+
page.classList.remove('active');
|
| 1184 |
+
}
|
| 1185 |
+
});
|
| 1186 |
+
|
| 1187 |
+
// Stop camera when navigating away from scanner page
|
| 1188 |
+
if (pageId !== 'scanner-page' && stream) {
|
| 1189 |
+
stopCamera();
|
| 1190 |
+
}
|
| 1191 |
+
}
|
| 1192 |
+
|
| 1193 |
+
// Update nav buttons
|
| 1194 |
+
function updateNavButtons(activePage) {
|
| 1195 |
+
navBtns.forEach(btn => {
|
| 1196 |
+
if (btn.getAttribute('data-page') === activePage) {
|
| 1197 |
+
btn.classList.remove('text-gray-500');
|
| 1198 |
+
btn.classList.add('text-blue-600');
|
| 1199 |
+
} else {
|
| 1200 |
+
btn.classList.remove('text-blue-600');
|
| 1201 |
+
btn.classList.add('text-gray-500');
|
| 1202 |
+
}
|
| 1203 |
+
});
|
| 1204 |
+
}
|
| 1205 |
+
|
| 1206 |
+
// Reset scanner
|
| 1207 |
+
function resetScanner() {
|
| 1208 |
+
stopCamera();
|
| 1209 |
+
scannerView.classList.remove('hidden');
|
| 1210 |
+
resultsSection.classList.add('hidden');
|
| 1211 |
+
const resultCards = document.querySelectorAll('.result-card');
|
| 1212 |
+
resultCards.forEach(card => {
|
| 1213 |
+
card.classList.remove('show');
|
| 1214 |
+
});
|
| 1215 |
+
}
|
| 1216 |
+
|
| 1217 |
+
// Initialize the app
|
| 1218 |
+
initApp();
|
| 1219 |
+
</script>
|
| 1220 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=serverghost/red-falcon-2" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 1221 |
+
</html>
|
prompts.txt
ADDED
|
File without changes
|