feat: redirect routes added
This commit is contained in:
parent
0d09ee74c3
commit
1835cb9f49
1 changed files with 20 additions and 2 deletions
22
js/script.js
22
js/script.js
|
|
@ -67,6 +67,19 @@ function getInviteCode() {
|
|||
return new URLSearchParams(window.location.search).get("inviteCode");
|
||||
}
|
||||
|
||||
// Picks where to send the user after a successful submission, based on platform.
|
||||
function getDownloadRedirectUrl() {
|
||||
const ua = navigator.userAgent || "";
|
||||
|
||||
if (/android/i.test(ua)) {
|
||||
return "https://myket.ir/app/com.adv.winsoo";
|
||||
}
|
||||
if (/iphone|ipad|ipod/i.test(ua)) {
|
||||
return "https://web.winsoo.ir";
|
||||
}
|
||||
return "https://winsoo.ir/#Download";
|
||||
}
|
||||
|
||||
const PERSIAN_DIGITS = "۰۱۲۳۴۵۶۷۸۹";
|
||||
const ARABIC_INDIC_DIGITS = "٠١٢٣٤٥٦٧٨٩";
|
||||
|
||||
|
|
@ -157,12 +170,17 @@ async function handleSubmit() {
|
|||
}
|
||||
|
||||
setMessage("ثبت شماره با موفقیت انجام شد.", "success");
|
||||
setButtonLoading(true, "در حال انتقال...");
|
||||
setTimeout(() => {
|
||||
window.location.href = getDownloadRedirectUrl();
|
||||
}, 1200);
|
||||
return;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
setMessage(err.message || "خطا در ارسال اطلاعات. لطفاً دوباره تلاش کنید.", "error");
|
||||
} finally {
|
||||
setButtonLoading(false);
|
||||
}
|
||||
|
||||
setButtonLoading(false);
|
||||
}
|
||||
|
||||
submitBtn.addEventListener("click", handleSubmit);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue