Update gate.html
Browse files
gate.html
CHANGED
|
@@ -43,44 +43,54 @@
|
|
| 43 |
</form>
|
| 44 |
</div>
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
|
| 49 |
-
const VERIFY_URL = "https://hudaakram-emmys-api.hf.space/verify";
|
| 50 |
-
const EMMYS_URL = "./index.html";
|
| 51 |
-
document.getElementById('gate').addEventListener('submit', async (e)=>{
|
| 52 |
-
e.preventDefault();
|
| 53 |
-
const btn = document.getElementById('go');
|
| 54 |
-
const msg = document.getElementById('msg');
|
| 55 |
-
msg.textContent = ""; btn.disabled = true; btn.style.opacity = .6;
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
msg.textContent = `Error: ${err}`;
|
| 79 |
msg.style.color = "#fca5a5";
|
| 80 |
-
}finally{
|
| 81 |
-
btn.disabled = false; btn.style.opacity = 1;
|
| 82 |
}
|
| 83 |
-
})
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
</body>
|
| 86 |
</html>
|
|
|
|
| 43 |
</form>
|
| 44 |
</div>
|
| 45 |
|
| 46 |
+
<script>
|
| 47 |
+
lucide.createIcons();
|
| 48 |
|
| 49 |
+
const VERIFY_URL = "https://hudaakram-emmys-api.hf.space/verify"; // أو اتركيه placeholder أثناء التجربة
|
| 50 |
+
const EMMYS_URL = "./index.html";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
+
document.getElementById('gate').addEventListener('submit', async (e)=>{
|
| 53 |
+
e.preventDefault();
|
| 54 |
+
const btn = document.getElementById('go');
|
| 55 |
+
const msg = document.getElementById('msg');
|
| 56 |
+
msg.textContent = ""; btn.disabled = true; btn.style.opacity = .6;
|
| 57 |
|
| 58 |
+
const name = document.getElementById('name').value.trim();
|
| 59 |
+
const file = document.getElementById('image').files[0];
|
| 60 |
+
if(!name || !file){
|
| 61 |
+
msg.textContent = "Please provide username and image.";
|
| 62 |
+
btn.disabled=false; btn.style.opacity=1; return;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
if (!VERIFY_URL || VERIFY_URL.includes("YOUR-BACKEND") || !VERIFY_URL.includes("hf.space")) {
|
| 66 |
+
const score = 0.951;
|
| 67 |
+
location.href = `${EMMYS_URL}?user=${encodeURIComponent(name)}&score=${score.toFixed(3)}`;
|
| 68 |
+
return;
|
| 69 |
+
}
|
| 70 |
|
| 71 |
+
const fd = new FormData();
|
| 72 |
+
fd.append('name', name);
|
| 73 |
+
fd.append('image', file, file.name);
|
| 74 |
+
|
| 75 |
+
try{
|
| 76 |
+
const r = await fetch(VERIFY_URL, { method:'POST', body: fd, mode:'cors' });
|
| 77 |
+
const out = await r.json();
|
| 78 |
+
if(out.decision === "Access Granted"){
|
| 79 |
+
const score = Number(out.score || 0).toFixed(3);
|
| 80 |
+
const token = out.token ? `&token=${encodeURIComponent(out.token)}` : "";
|
| 81 |
+
window.location.href = `${EMMYS_URL}?user=${encodeURIComponent(name)}&score=${score}${token}`;
|
| 82 |
+
}else{
|
| 83 |
+
msg.textContent = `⛔ ${out.decision || "Denied"} — score=${Number(out.score||0).toFixed(3)}`;
|
|
|
|
| 84 |
msg.style.color = "#fca5a5";
|
|
|
|
|
|
|
| 85 |
}
|
| 86 |
+
}catch(err){
|
| 87 |
+
msg.textContent = `Error: ${err}`;
|
| 88 |
+
msg.style.color = "#fca5a5";
|
| 89 |
+
}finally{
|
| 90 |
+
btn.disabled = false; btn.style.opacity = 1;
|
| 91 |
+
}
|
| 92 |
+
});
|
| 93 |
+
</script>
|
| 94 |
+
|
| 95 |
</body>
|
| 96 |
</html>
|