diff --git a/js/script.js b/js/script.js index 8dc3d31..a264d2d 100644 --- a/js/script.js +++ b/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);