🧪

Test QR Scan

Enter the QR code manually to test the counter and verification system

⬅ Back to Dashboard
tById('resultBox'); const resultTitle = document.getElementById('resultTitle'); const resultDetails = document.getElementById('resultDetails'); if (!token) { alert('Please enter the code first'); return; } btn.disabled = true; btn.innerText = 'Verifying...'; resultBox.style.display = 'none'; try { const response = await fetch('/scan', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + (localStorage.getItem('token') || '') }, body: JSON.stringify({ token: token }) }); const data = await response.json(); resultBox.style.display = 'block'; if (data.success) { resultBox.className = 'result-box result-success'; resultTitle.innerHTML = '✅ Access Allowed'; resultDetails.innerHTML = 'Name: ' + data.studentName + '
' + 'Usage: ' + data.currentScan + ' of ' + data.maxAllowed + '
' + 'Remaining: ' + data.remaining + ' times'; } else { resultBox.className = 'result-box result-error'; resultTitle.innerHTML = '❌ Access Denied'; resultDetails.innerHTML = 'Reason: ' + (data.message || 'Invalid code') + '
' + (data.studentName ? 'Student: ' + data.studentName + '
' : '') + (data.maxAllowed ? 'Limit: ' + data.maxAllowed : ''); } } catch (error) { resultBox.style.display = 'block'; resultBox.className = 'result-box result-error'; resultTitle.innerHTML = '⚠️ Connection Error'; resultDetails.innerText = 'Make sure the API is running correctly.'; } finally { btn.disabled = false; btn.innerText = 'Verify Code 🔍'; } } // Allow pressing Enter to submit document.getElementById('qrToken').addEventListener('keypress', function (e) { if (e.key === 'Enter') testScan(); }); can(); }); } } // السماح بالضغط على Enter للإرسال document.getElementById('qrToken').addEventListener('keypress', function (e) { if (e.key === 'Enter') testScan(); });
Web hosting by Somee.com