Results.cshtml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. @model LotteryWebApp.Models.TermResultHistoryModel
  2. @{
  3. ViewData["Title"] = "LotteryV2 - Results History";
  4. Layout = "~/Areas/LotteryV2/Views/Shared/_Layout.cshtml";
  5. ViewData["ActiveTab"] = "Results";
  6. }
  7. @using LotteryWebApp.Languages;
  8. @section Styles {
  9. <script src="https://cdn.tailwindcss.com"></script>
  10. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  11. <!-- Flatpickr for premium calendar -->
  12. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
  13. <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
  14. <link rel="stylesheet" href="/LotteryV2/css/site.css" />
  15. <link rel="stylesheet" href="/LotteryV2/css/results.css" />
  16. }
  17. <div class="main-container results-container animate__animated animate__fadeIn pb-40 relative">
  18. <!-- Header Group: Fixed at Top -->
  19. <div class="fixed top-0 left-1/2 -translate-x-1/2 w-full max-w-[414px] z-[100] bg-[#F3F4F6] pb-2 shadow-md">
  20. <!-- Header: Matches Figma (Right Image) -->
  21. <div class="results-top-header">
  22. <a href="javascript:history.back()" class="back-btn">
  23. <i class="fas fa-arrow-left"></i>
  24. </a>
  25. <h1 class="font-bricolage">@Lang.results</h1>
  26. </div>
  27. <!-- Selection Bar: Side-by-side dates and search -->
  28. <div class="selection-bar bg-white/50 backdrop-blur-sm px-4 pt-4 pb-2">
  29. <div class="flex gap-3">
  30. <div class="date-pick-input flex-1 cursor-pointer relative bg-white border border-gray-200 rounded-lg p-2 flex items-center gap-2">
  31. <img src="/LotteryV2/img/icon_calendar.svg" class="w-5 h-5" />
  32. <input type="text" id="fromDate" value="@Model.fromDate" class="bg-transparent border-none outline-none font-bold text-[13px] w-full ml-1 cursor-pointer" readonly />
  33. <i class="fas fa-caret-down text-gray-400"></i>
  34. </div>
  35. <div class="date-pick-input flex-1 cursor-pointer relative bg-white border border-gray-200 rounded-lg p-2 flex items-center gap-2">
  36. <img src="/LotteryV2/img/icon_calendar.svg" class="w-5 h-5" />
  37. <input type="text" id="toDate" value="@Model.toDate" class="bg-transparent border-none outline-none font-bold text-[13px] w-full ml-1 cursor-pointer" readonly />
  38. <i class="fas fa-caret-down text-gray-400"></i>
  39. </div>
  40. <button id="btnSearch" class="btn-search-red !w-12 !h-12 flex items-center justify-center bg-[#EE0033] text-white rounded-xl shadow-md" onclick="triggerSearch()">
  41. <i class="fas fa-search"></i>
  42. </button>
  43. </div>
  44. </div>
  45. <!-- Column Headers (Time & Results) -->
  46. <div class="px-4 mt-2">
  47. <div class="flex gap-3">
  48. <div class="flex-1 bg-white rounded-xl py-2 text-center text-[11px] font-black text-gray-800 shadow-sm border border-gray-100">
  49. @Lang.time
  50. </div>
  51. <div class="flex-[2] bg-white rounded-xl py-2 text-center text-[11px] font-black text-[#EE0033] shadow-sm border border-gray-100">
  52. @Lang.results
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <!-- Spacer to push content down below fixed header (~180px) -->
  58. <div class="h-[180px]"></div>
  59. <!-- Result List Container -->
  60. <div id="results-list-container" class="results-items-list px-4 min-h-[300px]">
  61. <partial name="_TermResultHistoryV2" model="Model" />
  62. </div>
  63. <!-- Bottom Promo Bar (Matches Bottom message with yellow text) -->
  64. <div class="fixed bottom-[74px] left-1/2 -translate-x-1/2 w-full max-w-[414px] bg-[#EE0033] text-white py-2 text-center text-[12px] font-bold tracking-wide z-40 flex flex-col items-center justify-center overflow-hidden h-auto shadow-md">
  65. <div class="flex flex-col items-center w-full animate-slide-up">
  66. <!-- Row 1 -->
  67. <div class="opacity-90">@Lang.have_chance_to_get</div>
  68. <!-- Row 2 -->
  69. <div class="text-[18px] font-black text-[#FBF3A7] mt-0.5">
  70. @Lang.jackpot_today_htg
  71. </div>
  72. </div>
  73. </div>
  74. <!-- Shared Bottom Navbar -->
  75. <partial name="_BottomNavbar" />
  76. </div>
  77. @section Scripts {
  78. <script>
  79. function initBrandedFlatpickr(selector, yearStart, yearEnd) {
  80. const container = document.querySelector(".results-container") || document.querySelector(".main-container");
  81. flatpickr(selector, {
  82. dateFormat: "Y-m-d", // Actual value used for search
  83. altInput: true,
  84. altFormat: "M d, Y", // Premium display format
  85. altInputClass: "bg-transparent border-none outline-none font-bold text-[13px] w-full ml-1 cursor-pointer",
  86. disableMobile: "true",
  87. monthSelectorType: "dropdown",
  88. appendTo: container,
  89. onReady: function (selectedDates, dateStr, instance) {
  90. const yearInput = instance.calendarContainer.querySelector(".numInput.cur-year");
  91. if (yearInput) {
  92. const yearSelect = document.createElement("select");
  93. yearSelect.className = "flatpickr-monthDropdown-months cur-year-select";
  94. yearSelect.style.cssText = "appearance:none; font-weight:800; border:none; background:transparent; color:white; cursor:pointer; margin-left:4px; outline:none; font-family:inherit; font-size:inherit;";
  95. for (let y = yearEnd; y >= yearStart; y--) {
  96. const opt = document.createElement("option");
  97. opt.value = y;
  98. opt.text = y;
  99. opt.style.color = "#333";
  100. if (y === instance.currentYear) opt.selected = true;
  101. yearSelect.appendChild(opt);
  102. }
  103. yearSelect.addEventListener("change", function () {
  104. instance.changeYear(parseInt(this.value));
  105. });
  106. yearInput.style.display = "none";
  107. yearInput.parentNode.appendChild(yearSelect);
  108. instance.set("onChange", function(d, s, i) {
  109. yearSelect.value = i.currentYear;
  110. });
  111. }
  112. }
  113. });
  114. }
  115. document.addEventListener('DOMContentLoaded', function() {
  116. initBrandedFlatpickr("#fromDate", 2020, 2030);
  117. initBrandedFlatpickr("#toDate", 2020, 2030);
  118. });
  119. function triggerSearch() {
  120. const fromDate = document.getElementById("fromDate").value;
  121. const toDate = document.getElementById("toDate").value;
  122. const termType = "@Model.termType";
  123. const btn = document.getElementById("btnSearch");
  124. const container = document.getElementById("results-list-container");
  125. // UI Feedback: Loading state
  126. btn.disabled = true;
  127. btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i>';
  128. container.style.opacity = "0.5";
  129. // AJAX Call to TermResultHistory
  130. fetch(subDomain + `/LotteryV2/Home/TermResultHistory?termType=${termType}&fromDate=${fromDate}&toDate=${toDate}`)
  131. .then(response => response.text())
  132. .then(html => {
  133. container.innerHTML = html;
  134. container.style.opacity = "1";
  135. btn.disabled = false;
  136. btn.innerHTML = '<i class="fas fa-search"></i>';
  137. })
  138. .catch(error => {
  139. console.error('Error fetching results:', error);
  140. container.style.opacity = "1";
  141. btn.disabled = false;
  142. btn.innerHTML = '<i class="fas fa-search"></i>';
  143. alert('Error fetching draw results. Please try again.');
  144. });
  145. }
  146. function switchMainTab(type, el) {
  147. const btns = el.parentElement.querySelectorAll('.tab-btn');
  148. btns.forEach(b => {
  149. b.style.color = '#1F2937';
  150. b.style.border = 'none';
  151. b.classList.remove('active');
  152. });
  153. el.style.color = '#EE0033';
  154. el.style.border = '1.5px solid #EE0033';
  155. el.classList.add('active');
  156. }
  157. </script>
  158. }