Update script.js
Browse files
script.js
CHANGED
|
@@ -22,6 +22,21 @@
|
|
| 22 |
let selectedFile = null;
|
| 23 |
let isSubmitting = false;
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
const isSupportedImage = (file) => {
|
| 26 |
if (!file) return false;
|
| 27 |
const acceptedTypes = ["image/jpeg", "image/jpg", "image/png"];
|
|
@@ -168,6 +183,9 @@
|
|
| 168 |
startSearch.addEventListener("click", async () => {
|
| 169 |
if (startSearch.disabled || isSubmitting || !selectedFile) return;
|
| 170 |
|
|
|
|
|
|
|
|
|
|
| 171 |
isSubmitting = true;
|
| 172 |
startSearch.disabled = true;
|
| 173 |
startSearch.textContent = "OPTIMIZING PHOTO…";
|
|
@@ -193,8 +211,11 @@
|
|
| 193 |
}
|
| 194 |
|
| 195 |
startSearch.textContent = "OPENING SEARCH…";
|
| 196 |
-
|
|
|
|
|
|
|
| 197 |
} catch (_) {
|
|
|
|
| 198 |
isSubmitting = false;
|
| 199 |
startSearch.disabled = false;
|
| 200 |
startSearch.textContent = "START SEARCH";
|
|
@@ -226,4 +247,4 @@
|
|
| 226 |
window.addEventListener("beforeunload", () => {
|
| 227 |
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
| 228 |
});
|
| 229 |
-
})();
|
|
|
|
| 22 |
let selectedFile = null;
|
| 23 |
let isSubmitting = false;
|
| 24 |
|
| 25 |
+
const openTopLevelWindow = (url = "about:blank") => {
|
| 26 |
+
const topLevelWindow = window.open(url, "_blank");
|
| 27 |
+
if (topLevelWindow) topLevelWindow.opener = null;
|
| 28 |
+
return topLevelWindow;
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
document
|
| 32 |
+
.querySelectorAll(".how-it-works .section-button, .final-cta .primary-button")
|
| 33 |
+
.forEach((link) => {
|
| 34 |
+
link.addEventListener("click", (event) => {
|
| 35 |
+
event.preventDefault();
|
| 36 |
+
openTopLevelWindow(destination);
|
| 37 |
+
});
|
| 38 |
+
});
|
| 39 |
+
|
| 40 |
const isSupportedImage = (file) => {
|
| 41 |
if (!file) return false;
|
| 42 |
const acceptedTypes = ["image/jpeg", "image/jpg", "image/png"];
|
|
|
|
| 183 |
startSearch.addEventListener("click", async () => {
|
| 184 |
if (startSearch.disabled || isSubmitting || !selectedFile) return;
|
| 185 |
|
| 186 |
+
const topLevelWindow = openTopLevelWindow();
|
| 187 |
+
if (!topLevelWindow) return;
|
| 188 |
+
|
| 189 |
isSubmitting = true;
|
| 190 |
startSearch.disabled = true;
|
| 191 |
startSearch.textContent = "OPTIMIZING PHOTO…";
|
|
|
|
| 211 |
}
|
| 212 |
|
| 213 |
startSearch.textContent = "OPENING SEARCH…";
|
| 214 |
+
topLevelWindow.location.replace(
|
| 215 |
+
`${destination}?handoff=${encodeURIComponent(data.handoffToken)}`
|
| 216 |
+
);
|
| 217 |
} catch (_) {
|
| 218 |
+
topLevelWindow.close();
|
| 219 |
isSubmitting = false;
|
| 220 |
startSearch.disabled = false;
|
| 221 |
startSearch.textContent = "START SEARCH";
|
|
|
|
| 247 |
window.addEventListener("beforeunload", () => {
|
| 248 |
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
| 249 |
});
|
| 250 |
+
})();
|