Spaces:
Running
Running
Update index.html
Browse files- index.html +12 -3
index.html
CHANGED
|
@@ -172,17 +172,26 @@ a.cta{display:flex;align-items:center;justify-content:center;text-decoration:non
|
|
| 172 |
im.onerror=function(){ cb(null); };
|
| 173 |
im.src=URL.createObjectURL(file);
|
| 174 |
}
|
| 175 |
-
//
|
| 176 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
function handleFile(f){
|
| 178 |
if(!f) return;
|
| 179 |
show(f);
|
| 180 |
btn.classList.add("busy");
|
| 181 |
btn.textContent="Preparing photo…";
|
| 182 |
compress(f,function(d){
|
| 183 |
-
|
|
|
|
| 184 |
btn.classList.remove("busy");
|
| 185 |
btn.textContent="Search this face →";
|
|
|
|
| 186 |
});
|
| 187 |
}
|
| 188 |
file.addEventListener("change",function(){ handleFile(file.files&&file.files[0]); });
|
|
|
|
| 172 |
im.onerror=function(){ cb(null); };
|
| 173 |
im.src=URL.createObjectURL(file);
|
| 174 |
}
|
| 175 |
+
// Navigate to UnFake. On the direct subdomain (not in HF's iframe) this is a
|
| 176 |
+
// same-tab redirect and works automatically; inside the iframe it opens a new
|
| 177 |
+
// tab (which mobile browsers may only allow right after a user tap).
|
| 178 |
+
function navigate(url){
|
| 179 |
+
if (!inFrame) { window.location.href = url; }
|
| 180 |
+
else { window.open(url, "_blank"); }
|
| 181 |
+
}
|
| 182 |
+
// Compress as soon as a photo is picked, then auto-move to UnFake. The button
|
| 183 |
+
// href is also preset so the button still works as a manual fallback.
|
| 184 |
function handleFile(f){
|
| 185 |
if(!f) return;
|
| 186 |
show(f);
|
| 187 |
btn.classList.add("busy");
|
| 188 |
btn.textContent="Preparing photo…";
|
| 189 |
compress(f,function(d){
|
| 190 |
+
var url = d ? "https://unfake.pro/#photo="+encodeURIComponent(d) : "https://unfake.pro";
|
| 191 |
+
btn.href = url;
|
| 192 |
btn.classList.remove("busy");
|
| 193 |
btn.textContent="Search this face →";
|
| 194 |
+
navigate(url);
|
| 195 |
});
|
| 196 |
}
|
| 197 |
file.addEventListener("change",function(){ handleFile(file.files&&file.files[0]); });
|