Spaces:
Running
Running
Download script.js from tazawy/securevault-lockscreen: direct link, hf CLI and curl.
- Browser
- Download file 2.7 kB
-
https://huggingface.co/spaces/tazawy/securevault-lockscreen/resolve/main/script.js
- Command line
-
hf download hf://spaces/tazawy/securevault-lockscreen/script.js
-
curl -L -o script.js https://huggingface.co/spaces/tazawy/securevault-lockscreen/resolve/main/script.js
2.7 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| const pinInput = document.getElementById('pin'); | |
| const unlockBtn = document.getElementById('unlockBtn'); | |
| const fingerprintBtn = document.getElementById('fingerprintBtn'); | |
| // Mock authentication functions | |
| async function checkPin() { | |
| const enteredPin = pinInput.value; | |
| if (!enteredPin || enteredPin.length < 4) { | |
| showToast('الرجاء إدخال رمز PIN مكون من 4 أرقام على الأقل', 'error'); | |
| return; | |
| } | |
| // In a real app, you would check against stored hash | |
| showToast('جارٍ التحقق...', 'info'); | |
| // Simulate API call | |
| setTimeout(() => { | |
| // Default PIN for demo: 1234 | |
| if (enteredPin === '1234') { | |
| showToast('تم فتح القفل بنجاح!', 'success'); | |
| // Redirect to home page | |
| setTimeout(() => { | |
| window.location.href = 'home.html'; | |
| }, 1000); | |
| } else { | |
| showToast('رمز PIN غير صحيح', 'error'); | |
| } | |
| }, 1500); | |
| } | |
| async function authenticateWithFingerprint() { | |
| showToast('جارٍ التحقق بالبصمة...', 'info'); | |
| // Check if browser supports WebAuthn | |
| if (!window.PublicKeyCredential) { | |
| showToast('المتصفح لا يدعم المصادقة البيومترية', 'error'); | |
| return; | |
| } | |
| // Simulate fingerprint auth | |
| setTimeout(() => { | |
| const isSuccess = Math.random() > 0.2; // 80% success rate for demo | |
| if (isSuccess) { | |
| showToast('تم المصادقة بنجاح!', 'success'); | |
| setTimeout(() => { | |
| window.location.href = 'home.html'; | |
| }, 1000); | |
| } else { | |
| showToast('فشل المصادقة، حاول مرة أخرى', 'error'); | |
| } | |
| }, 2000); | |
| } | |
| // Event listeners | |
| unlockBtn.addEventListener('click', checkPin); | |
| fingerprintBtn.addEventListener('click', authenticateWithFingerprint); | |
| // Allow submitting with Enter key | |
| pinInput.addEventListener('keypress', function(e) { | |
| if (e.key === 'Enter') { | |
| checkPin(); | |
| } | |
| }); | |
| }); | |
| function showToast(message, type) { | |
| const toast = document.createElement('custom-toast'); | |
| toast.setAttribute('message', message); | |
| toast.setAttribute('type', type); | |
| document.body.appendChild(toast); | |
| setTimeout(() => { | |
| toast.remove(); | |
| }, 3000); | |
| } |