GameHome.cshtml 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. @model LotteryWebApp.Models.HomeIndex_ViewModel
  2. @{
  3. ViewData["Title"] = "Millions - Game Home";
  4. Layout = "~/Areas/Millions/Views/Shared/_Layout.cshtml";
  5. }
  6. @using LotteryWebApp.Languages;
  7. @using LotteryWebApp.Controllers;
  8. @using LotteryWebApp.Common;
  9. @{
  10. string SubText(string key) => Lang.ResourceManager.GetString(key, System.Globalization.CultureInfo.CurrentUICulture) ?? key;
  11. }
  12. @section Styles {
  13. <link rel="preconnect" href="https://fonts.googleapis.com">
  14. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  15. <link href="https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800&family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,500;12..96,600;12..96,700;12..96,800&display=swap" rel="stylesheet">
  16. <link rel="stylesheet" href="/Millions/css/all.min.css"/>
  17. <link rel="stylesheet" href="/Millions/css/game-home.css"/>
  18. }
  19. <div class="main-content h-dvh w-full max-w-[430px] mx-auto bg-[#f5f7fb] relative overflow-hidden font-bricolage" style="background-color:#f5f7fb;">
  20. <!-- Scrollable content area -->
  21. @{
  22. var hasResult = !string.IsNullOrEmpty(Model.lastResult);
  23. var resultBalls = hasResult ? Model.lastResult.Split(',') : null;
  24. if (hasResult && resultBalls.Length < 6) {
  25. var temp = new string[6];
  26. for (int i = 0; i < 6; i++) temp[i] = i < resultBalls.Length ? resultBalls[i] : "0";
  27. resultBalls = temp;
  28. }
  29. }
  30. <div class="absolute inset-x-0 top-0 bottom-[64px] overflow-y-auto flex flex-col" style="background-color:#f5f7fb; overscroll-behavior:contain;">
  31. <!-- Top section with header + cards -->
  32. <div class="relative">
  33. <!-- Header gradient background -->
  34. <div class="header-bg relative h-[160px] rounded-b-[40px] overflow-hidden">
  35. <!-- Top bar -->
  36. <div class="flex items-center justify-between px-3 pt-3 relative z-10">
  37. <button onclick='location.href=subDomain + "@Url.Action("Index", "Home", new { area = "LotteryV2" })";' class="w-6 h-6 flex items-center justify-center">
  38. <img src="/Millions/assets/icons/arrow-left.svg" alt="Back" class="w-6 h-6"/>
  39. </button>
  40. @{
  41. var currentLang = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
  42. var isEnglish = currentLang == "fr";
  43. }
  44. <div class="relative">
  45. <button type="button" id="langSwitchBtn" class="flex items-center gap-2 bg-white/15 rounded-full px-3 py-1 text-white text-sm">
  46. <img src="@(isEnglish ? "/img/en_flag.png" : "/img/Flag_of_Haiti.png")" alt="" class="lang-flag-icon"/>
  47. <span>@(isEnglish ? "English" : "Natcom")</span>
  48. <img src="/Millions/assets/icons/chevron-down.svg" alt="" class="w-2 h-2"/>
  49. </button>
  50. <div id="langSwitchMenu" class="hidden absolute right-0 mt-2 bg-white rounded-xl shadow-lg overflow-hidden z-50 min-w-[140px] py-1">
  51. <button type="button" onclick="setLanguage('fr')" class="w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-800 hover:bg-gray-100 @(isEnglish ? "font-bold" : "")">
  52. <img src="/img/en_flag.png" alt="" class="lang-flag-icon"/>
  53. <span>English</span>
  54. </button>
  55. <button type="button" onclick="setLanguage('en')" class="w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-800 hover:bg-gray-100 @(!isEnglish ? "font-bold" : "")">
  56. <img src="/img/Flag_of_Haiti.png" alt="" class="lang-flag-icon"/>
  57. <span>Natcom</span>
  58. </button>
  59. </div>
  60. </div>
  61. </div>
  62. <!-- User profile -->
  63. <div class="flex items-center gap-2 px-3 min-[380px]:gap-4 min-[380px]:px-4 -mt-2">
  64. <div class="w-16 h-16 min-[380px]:w-[84px] min-[380px]:h-[84px] rounded-full overflow-hidden bg-white/20 border-[3px] border-white shrink-0">
  65. <img src="/Millions/assets/images/avatar.png" alt="Avatar" class="w-full h-full object-cover"/>
  66. </div>
  67. <div class="flex-1 min-w-0">
  68. <p class="text-white text-base font-semibold leading-tight">@(Model?.profile?.users ?? "User")</p>
  69. <div class="mt-1.5 min-[380px]:mt-2 flex items-center justify-between gap-1.5 min-[380px]:gap-2 rounded-full border border-white/35 bg-white/10 px-2 py-1.5 min-[380px]:px-3 min-[380px]:py-2">
  70. <div class="flex items-center gap-0.5 min-[380px]:gap-1 min-w-0">
  71. <span class="text-xl min-[340px]:text-2xl min-[380px]:text-3xl font-condensed text-gold-gradient leading-none whitespace-nowrap">@Utils.FormatMoney(Model?.userStatus?.bet_coin)</span>
  72. <img src="/Millions/assets/icons/coin.png" alt="" class="w-5 h-5 shrink-0"/>
  73. <span class="text-white text-sm shrink-0">@Lang.millions_htg</span>
  74. </div>
  75. <button type="button" onclick="transferWinMoney()" class="redeem-pulse shrink-0 rounded-full px-3 py-2 min-h-[40px] w-[4.9rem] font-extrabold text-[#0a1f44] text-[9px] leading-[1.12] text-center active:scale-[0.98] transition-transform" style="background: linear-gradient(90deg, #ffcf0f 0%, #fff1b8 100%); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);">
  76. @Lang.millions_redeem_rewards
  77. </button>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. <!-- Floating info card -->
  83. <div class="absolute left-5 right-5 -bottom-[52px] bg-white rounded-2xl shadow-md flex items-center h-20 px-4">
  84. <div class="flex items-center gap-2 flex-1">
  85. <img src="/Millions/assets/icons/calendar.png" alt="" class="w-6 h-6"/>
  86. <div>
  87. <p class="text-xs text-[#797979]">@Lang.millions_next_round</p>
  88. <p class="text-xs font-bold text-black" id="draw-date">@Utils.FormatResultDate(Model.nextRoundDate)</p>
  89. </div>
  90. </div>
  91. <div class="w-px h-12 bg-gray-200"></div>
  92. <div class="flex items-center gap-2 flex-1 pl-4">
  93. <img src="/Millions/assets/icons/money-bag.png" alt="" class="w-6 h-[34px] object-contain"/>
  94. <div>
  95. <p class="text-xs text-[#797979]">@Lang.millions_jackpot_prize_to</p>
  96. <p class="leading-none ">
  97. <span class="text-base font-extrabold text-[#002bff]">30.000.000</span><span class="text-[10.32px] font-extrabold text-black align-top">@Lang.millions_htg</span>
  98. </p>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. <!-- Result section -->
  104. @if (hasResult)
  105. {
  106. <div class="px-4 mt-10">
  107. <div class="result-box rounded-[32px] py-3 flex flex-col gap-2">
  108. <div class="flex items-center justify-between px-4">
  109. <div class="flex items-center gap-2 text-xs">
  110. <span class="text-[#797979]">@Lang.results</span>
  111. <span class="font-bold text-black">@Utils.FormatResultDate(Model.lastResultDate)</span>
  112. </div>
  113. <a href="/Millions/Home/Results" class="flex items-center gap-1 text-[10px] font-bold text-black border border-[#c2c2c2] rounded-lg px-2 py-1">
  114. @Lang.millions_view_all_results
  115. <img src="/Millions/assets/icons/chevron-right.svg" alt="" class="w-[5px] h-2" />
  116. </a>
  117. </div>
  118. <!-- Result balls -->
  119. <div class="flex items-center justify-between gap-1 px-4">
  120. @for (int i = 0; i < 5; i++)
  121. {
  122. <div class="ball ball-blue">@resultBalls[i]</div>
  123. }
  124. <div class="relative">
  125. <img src="/Millions/assets/icons/crown.png" alt="" class="absolute -top-4 -right-1 w-7 h-auto pointer-events-none rotate-[15deg] z-0" />
  126. <div class="ball ball-mb relative z-10">
  127. <span>@resultBalls[5]</span>
  128. <span class="absolute -bottom-1 -right-2 bg-[#ee0033] text-white text-[8px] font-bold px-1.5 py-0.5 rounded z-20">MB</span>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. }
  135. else
  136. {
  137. <div class="mt-14"></div>
  138. }
  139. <!-- Mega Jackpot banner -->
  140. <div class="px-2 mt-6">
  141. <a href="@Url.Action("JackpotResults", "Home", new { area = "Millions", termType = Model.termType })" class="mega-banner relative rounded-[20px] overflow-hidden px-4 py-3 flex flex-col">
  142. <span class="mega-glow" style="left:-79px; top:-101px;"></span>
  143. <span class="mega-glow" style="right:-78px; top:9px;"></span>
  144. <span class="mega-glow" style="right:-107px; top:20px;"></span>
  145. <p class="mega-title relative inline-block text-white text-[22px] font-futura leading-none">
  146. <img src="/Millions/assets/icons/crown.png" alt="" class="absolute -top-[5px] left-[26px] w-[12px] h-auto rotate-[10deg] pointer-events-none"/>
  147. @Lang.millions_mega_jackpot
  148. </p>
  149. <p class="text-white text-xs mt-2">@Lang.millions_estimate_jackpot_prize</p>
  150. <p class="leading-none mt-1" style="margin-bottom:18px;">
  151. <span class="mega-jackpot-spiral inline-flex items-start">
  152. <span class="mega-amount text-[40px] font-condensed text-gold-gradient tracking-tight leading-none">@Utils.FormatMoney(Model.bolet ?? "30000000")</span>
  153. <span class="text-gold-gradient text-sm font-bold uppercase ml-2 mt-0.5">@Lang.v2_htg</span>
  154. </span>
  155. </p>
  156. <p class="text-white text-[10px] mt-1 ">@Lang.millions_be_the_next_millionaire</p>
  157. <div class="relative z-10 mt-1 flex items-end justify-between gap-2">
  158. <p class="text-white text-[10px] leading-snug flex-1 pr-1 max-w-[68%]">@Lang.millions_jackpot_disclaimer</p>
  159. <span class="shrink-0 inline-flex items-center gap-1 bg-white/20 hover:bg-white/30 rounded-full px-2 py-0.5 text-white text-[10px] font-semibold">
  160. @Lang.millions_view
  161. <img src="/Millions/assets/icons/chevron-right.svg" alt="" class="w-[5px] h-2 invert"/>
  162. </span>
  163. </div>
  164. <!-- Decorative elements -->
  165. <img src="/Millions/assets/images/crown-balls.png" alt="" class="absolute right-2 top-1/2 -translate-y-1/2 w-44 h-auto pointer-events-none"/>
  166. </a>
  167. </div>
  168. <!-- Play now button + decorative balls -->
  169. <div id="playNowSection" class="relative shrink-0 mt-4 z-10">
  170. <img src="/Millions/assets/images/play-decor.png" alt="" class="block w-full h-auto pointer-events-none"/>
  171. <a onclick="onPlayNow('@Constants.Millions_CODE')" class="play-now-outer rounded-full animate-pulse-play" style="position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); width:155px; height:155px; padding:11px; cursor:pointer;">
  172. <div class="play-now-ring rounded-full" style="width:100%;height:100%;padding:4px;">
  173. <div class="play-now-btn rounded-full flex flex-col items-center justify-center text-white text-[32px] font-black border-[1.8px] border-white animate-pulse-play" style="width:100%;height:100%;line-height:24px;">
  174. <span class="uppercase">@Lang.millions_play</span>
  175. <span class="uppercase">@Lang.millions_now</span>
  176. </div>
  177. </div>
  178. </a>
  179. </div>
  180. </div>
  181. @{
  182. ViewData["ActiveTab"] = "Home";
  183. }
  184. <div id="notificationModal" class="fixed inset-0 z-[100] flex items-center justify-center hidden px-6 font-bricolage" style="background: linear-gradient(135deg, rgba(26, 26, 46, 0.9) 0%, rgba(22, 33, 62, 0.9) 100%);">
  185. <div class="w-full max-w-[343px] min-h-[480px] bg-white rounded-[24px] overflow-hidden flex flex-col items-center p-8 animate__animated animate__zoomIn animate__faster shadow-2xl">
  186. <div class="w-full flex justify-center mb-8 mt-6">
  187. <img src="/Millions/img/modal/fail_icon.png" class="w-[180px] h-auto object-contain" alt="Notification icon" />
  188. </div>
  189. <div class="px-2 text-center mb-10 flex-1 flex items-center justify-center">
  190. <p id="notificationMessage" class="text-black font-[800] text-[22px] leading-snug"></p>
  191. </div>
  192. <div class="w-full">
  193. <button onclick="closeNotificationModal()" class="w-full bg-[#0062FF] text-white font-[800] text-[20px] py-[12px] rounded-[14px] shadow-lg active:scale-95 transition-all">
  194. @Lang.try_again
  195. </button>
  196. </div>
  197. </div>
  198. </div>
  199. <div id="subMillionModal" class="sub-modal fixed inset-0 z-[100] flex items-center justify-center hidden px-6 font-bricolage">
  200. <div class="sub-modal__panel relative w-full max-w-[343px] bg-white rounded-[28px] overflow-hidden flex flex-col animate__animated animate__zoomIn animate__faster">
  201. <button type="button" onclick="closeSubModal()" class="sub-modal__close" aria-label="@SubText("millions_close")">
  202. <i class="fa-solid fa-xmark"></i>
  203. </button>
  204. <div id="subChoiceView" class="w-full flex flex-col">
  205. <!-- Header -->
  206. <div class="sub-modal__hero relative px-6 pt-7 pb-14 text-center overflow-hidden">
  207. <span class="sub-modal__badge">MILLIONS</span>
  208. <h2 class="text-gold-gradient font-[800] text-[26px] leading-tight mt-3 relative z-[1]">@SubText("sub_million_popup_title")</h2>
  209. </div>
  210. <img src="/Millions/assets/images/crown-balls.png" alt="" aria-hidden="true" class="sub-modal__crown" />
  211. <!-- Body -->
  212. <div class="px-6 pb-6 pt-2 flex flex-col">
  213. <p class="text-[#4a4a4a] text-[14px] leading-snug text-center mb-4">@SubText("sub_million_popup_desc")</p>
  214. <ul class="sub-modal__benefits mb-6">
  215. <li><span class="sub-modal__check"><i class="fa-solid fa-ticket"></i></span>@SubText("sub_million_benefit_daily")</li>
  216. <li><span class="sub-modal__check"><i class="fa-solid fa-bolt"></i></span>@SubText("sub_million_benefit_auto")</li>
  217. <li><span class="sub-modal__check"><i class="fa-solid fa-crown"></i></span>@SubText("sub_million_benefit_jackpot")</li>
  218. </ul>
  219. <button type="button" id="subRegisterBtn" onclick="registerSub()" class="sub-modal__primary">
  220. <span class="sub-modal__btn-label">@SubText("sub_million_btn_subscribe")</span>
  221. <span class="sub-modal__spinner" aria-hidden="true"></span>
  222. </button>
  223. <button type="button" onclick="buySingleTicket()" class="sub-modal__secondary mt-3">
  224. @SubText("sub_million_btn_buy_single")
  225. </button>
  226. </div>
  227. </div>
  228. <div id="subResultView" class="w-full flex-col items-center hidden px-6 pt-8 pb-6">
  229. <div id="subResultSuccess" class="hidden w-full flex-col items-center">
  230. <div class="sub-modal__result-icon sub-modal__result-icon--success mb-4">
  231. <i class="fa-solid fa-check"></i>
  232. </div>
  233. <h3 class="text-[#0a1f44] font-[800] text-[22px] leading-tight text-center mb-3">
  234. @SubText("sub_million_register_success")
  235. </h3>
  236. <p class="text-[#4a4a4a] text-[13.5px] leading-relaxed text-center mb-2 px-1">
  237. @SubText("sub_million_register_success_desc")
  238. </p>
  239. <p class="text-[#0a1f44] font-[700] text-[14px] leading-snug text-center mb-6">
  240. @SubText("sub_million_register_success_prompt")
  241. </p>
  242. <button type="button" onclick="buySingleTicket()" class="sub-modal__primary w-full">
  243. @SubText("sub_million_btn_buy_more")
  244. </button>
  245. <button type="button" onclick="closeSubModal()" class="sub-modal__btn-close mt-3 w-full">
  246. @SubText("millions_close")
  247. </button>
  248. </div>
  249. <div id="subResultFail" class="hidden w-full flex-col items-center">
  250. <div class="sub-modal__result-icon sub-modal__result-icon--fail mb-4">
  251. <i class="fa-solid fa-exclamation"></i>
  252. </div>
  253. <p class="text-black font-[800] text-[20px] leading-snug text-center mb-6">
  254. @SubText("sub_million_register_fail")
  255. </p>
  256. <button type="button" onclick="closeSubModal()" class="sub-modal__primary w-full">
  257. @SubText("millions_close")
  258. </button>
  259. </div>
  260. <div id="subResultInvalidMsisdn" class="hidden w-full flex-col items-center">
  261. <div class="sub-modal__result-icon sub-modal__result-icon--fail mb-4">
  262. <i class="fa-solid fa-phone-slash"></i>
  263. </div>
  264. <p class="text-black font-[800] text-[20px] leading-snug text-center mb-6">
  265. @SubText("sub_million_invalid_msisdn")
  266. </p>
  267. <button type="button" onclick="closeSubModal()" class="sub-modal__primary w-full">
  268. @SubText("millions_close")
  269. </button>
  270. </div>
  271. </div>
  272. </div>
  273. </div>
  274. @await Html.PartialAsync("~/Areas/Millions/Views/Shared/_BottomNavbar.cshtml")
  275. </div>
  276. @await Html.PartialAsync("~/Areas/Millions/Views/Home/PopupFreeTickit.cshtml")
  277. @section Scripts {
  278. <script src="/Millions/js/all.min.js"></script>
  279. <script>
  280. var systemUpgrading = false;
  281. let isCheckingTerm = false;
  282. function showNotification(message, code) {
  283. $("#notificationMessage").text(message);
  284. const $btn = $("#notificationModal button");
  285. if (code === "-2" || (message && message.includes("System is upgrading"))) {
  286. systemUpgrading = true;
  287. $btn.text("@Lang.login");
  288. } else {
  289. systemUpgrading = false;
  290. $btn.text("@Lang.try_again");
  291. }
  292. $("#notificationModal").removeClass("hidden").addClass("flex");
  293. }
  294. function closeNotificationModal() {
  295. $("#notificationModal").addClass("hidden").removeClass("flex");
  296. if (systemUpgrading) {
  297. window.location.href = subDomain + "/Account/Login";
  298. }
  299. }
  300. function checkTerm(termType) {
  301. if (isCheckingTerm) return;
  302. isCheckingTerm = true;
  303. var token = $('input[name="__RequestVerificationToken"]').val();
  304. $.ajax({
  305. url: subDomain + '/Millions/Home/TermResult',
  306. type: 'POST',
  307. data: {
  308. __RequestVerificationToken: token,
  309. termType: termType
  310. },
  311. success: function (res) {
  312. if (res.responseCode === "0") {
  313. if (res.listTerm && res.listTerm.length > 0) {
  314. var status = res.listTerm[0].status;
  315. if (status === "0" || status === "1") {
  316. location.href = subDomain + '/Millions/Home/BuyTicket?termType=' + termType;
  317. return;
  318. } else if (status === "2") {
  319. showNotification("@Lang.millions_game_locked");
  320. } else if (status === "3") {
  321. showNotification("@Lang.millions_updating_results");
  322. } else {
  323. showNotification("@Lang.millions_game_locked");
  324. }
  325. } else {
  326. showNotification("@Lang.no_results_found");
  327. }
  328. } else if (res.responseCode === "401") {
  329. window.location.href = subDomain + "/Account/Login";
  330. return;
  331. } else {
  332. showNotification(res.responseMessage || "@Lang.error_happened", res.responseCode);
  333. }
  334. isCheckingTerm = false;
  335. },
  336. error: function (err) {
  337. showNotification("@Lang.error_happened");
  338. isCheckingTerm = false;
  339. }
  340. });
  341. }
  342. // ===== Sub MILLION =====
  343. // null: unknown (check failed) -> fall back to the existing buy flow
  344. var isSubMillion = null;
  345. var pendingPlayTermType = null;
  346. var isRegisteringSub = false;
  347. var subCheckRequest = $.ajax({
  348. url: subDomain + '/Millions/Home/CheckSub',
  349. type: 'POST',
  350. data: { __RequestVerificationToken: $('input[name="__RequestVerificationToken"]').val() }
  351. }).done(function (res) {
  352. if (res && res.responseCode === "0") {
  353. isSubMillion = res.isSub === true;
  354. }
  355. });
  356. function onPlayNow(termType) {
  357. subCheckRequest.always(function () {
  358. if (isSubMillion === false) {
  359. openSubModal(termType);
  360. } else {
  361. checkTerm(termType);
  362. }
  363. });
  364. }
  365. function openSubModal(termType) {
  366. pendingPlayTermType = termType;
  367. $("#subResultView").addClass("hidden").removeClass("flex");
  368. $("#subChoiceView").removeClass("hidden").addClass("flex");
  369. $("#subRegisterBtn").prop("disabled", false).removeClass("is-loading");
  370. $("#subMillionModal").removeClass("hidden").addClass("flex");
  371. }
  372. function closeSubModal() {
  373. $("#subMillionModal").addClass("hidden").removeClass("flex");
  374. }
  375. $("#subMillionModal").on("click", function (e) {
  376. if (e.target === this && !isRegisteringSub) closeSubModal();
  377. });
  378. function showSubResult(resultId) {
  379. $("#subResultSuccess, #subResultFail, #subResultInvalidMsisdn").addClass("hidden").removeClass("flex");
  380. $("#" + resultId).removeClass("hidden").addClass("flex");
  381. $("#subChoiceView").addClass("hidden").removeClass("flex");
  382. $("#subResultView").removeClass("hidden").addClass("flex");
  383. }
  384. function buySingleTicket() {
  385. closeSubModal();
  386. checkTerm(pendingPlayTermType || '@Constants.Millions_CODE');
  387. }
  388. function registerSub() {
  389. if (isRegisteringSub) return;
  390. isRegisteringSub = true;
  391. $("#subRegisterBtn").prop("disabled", true).addClass("is-loading");
  392. $.ajax({
  393. url: subDomain + '/Millions/Home/RegisterSub',
  394. type: 'POST',
  395. data: { __RequestVerificationToken: $('input[name="__RequestVerificationToken"]').val() },
  396. success: function (res) {
  397. if (res.responseCode === "0") {
  398. isSubMillion = true;
  399. showSubResult("subResultSuccess");
  400. } else if (res.responseCode === "@Code.SESSION_EXPIRED") {
  401. window.location.href = subDomain + "/Account/Login";
  402. return;
  403. } else if (res.subCode === 5) {
  404. showSubResult("subResultInvalidMsisdn");
  405. } else {
  406. showSubResult("subResultFail");
  407. }
  408. },
  409. error: function () {
  410. showSubResult("subResultFail");
  411. },
  412. complete: function () {
  413. isRegisteringSub = false;
  414. $("#subRegisterBtn").removeClass("is-loading");
  415. }
  416. });
  417. }
  418. function startCountdown() {
  419. const targetHour = 23;
  420. const now = new Date();
  421. let target = new Date();
  422. target.setHours(targetHour, 0, 0, 0);
  423. if (now >= target) {
  424. target.setDate(target.getDate() + 1);
  425. }
  426. const options = { weekday: 'long', month: 'short', day: 'numeric', year: 'numeric' };
  427. const dateText = target.toLocaleDateString('en-US', options);
  428. const drawDateEl = document.getElementById('draw-date');
  429. if(drawDateEl) drawDateEl.innerText = dateText;
  430. }
  431. // Withdraw money function
  432. function transferWinMoney() {
  433. location.href = subDomain + '@Url.Action("TransferWinMoney", "Home", new { area = "Millions" })';
  434. }
  435. document.addEventListener('DOMContentLoaded', startCountdown);
  436. function setLanguage(newLang) {
  437. fetch(subDomain + '/Home/SetCulture?lang=' + newLang)
  438. .then(function () { location.reload(); })
  439. .catch(function () { location.reload(); });
  440. }
  441. document.addEventListener('DOMContentLoaded', function () {
  442. var btn = document.getElementById('langSwitchBtn');
  443. var menu = document.getElementById('langSwitchMenu');
  444. if (!btn || !menu) return;
  445. btn.addEventListener('click', function (e) {
  446. e.stopPropagation();
  447. menu.classList.toggle('hidden');
  448. });
  449. document.addEventListener('click', function () {
  450. menu.classList.add('hidden');
  451. });
  452. });
  453. </script>
  454. }