|
@@ -37,17 +37,14 @@
|
|
|
<h1 class="font-bricolage">@Lang.results</h1>
|
|
<h1 class="font-bricolage">@Lang.results</h1>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
- <!-- Selection Bar: Side-by-side dates and search -->
|
|
|
|
|
|
|
+ <!-- Selection Bar: Date range and search -->
|
|
|
<div class="selection-bar bg-white rounded-t-[30px] px-4 pt-4 pb-2">
|
|
<div class="selection-bar bg-white rounded-t-[30px] px-4 pt-4 pb-2">
|
|
|
<div class="flex gap-3">
|
|
<div class="flex gap-3">
|
|
|
- <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">
|
|
|
|
|
|
|
+ <div class="date-range-input flex-1 cursor-pointer relative bg-white border border-gray-200 rounded-lg p-2 flex items-center gap-2">
|
|
|
<img src="/Millions/img/icon_calendar.svg" class="w-5 h-5" />
|
|
<img src="/Millions/img/icon_calendar.svg" class="w-5 h-5" />
|
|
|
- <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 />
|
|
|
|
|
- <i class="fas fa-caret-down text-gray-400"></i>
|
|
|
|
|
- </div>
|
|
|
|
|
- <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">
|
|
|
|
|
- <img src="/Millions/img/icon_calendar.svg" class="w-5 h-5" />
|
|
|
|
|
- <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 />
|
|
|
|
|
|
|
+ <input type="text" id="dateRange" class="bg-transparent border-none outline-none font-bold text-[13px] w-full ml-1 cursor-pointer" readonly />
|
|
|
|
|
+ <input type="hidden" id="fromDate" value="@Model.fromDate" />
|
|
|
|
|
+ <input type="hidden" id="toDate" value="@Model.toDate" />
|
|
|
<i class="fas fa-caret-down text-gray-400"></i>
|
|
<i class="fas fa-caret-down text-gray-400"></i>
|
|
|
</div>
|
|
</div>
|
|
|
<button id="btnSearch" class="btn-search-red !w-12 !h-12 flex items-center justify-center bg-[#0062FF] text-white rounded-xl shadow-md" onclick="triggerSearch()">
|
|
<button id="btnSearch" class="btn-search-red !w-12 !h-12 flex items-center justify-center bg-[#0062FF] text-white rounded-xl shadow-md" onclick="triggerSearch()">
|
|
@@ -110,18 +107,58 @@
|
|
|
{ code: '@Constants.Millions_CODE', name: 'Millions', color: '#0062FF' }
|
|
{ code: '@Constants.Millions_CODE', name: 'Millions', color: '#0062FF' }
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
- function initBrandedFlatpickr(selector, yearStart, yearEnd) {
|
|
|
|
|
|
|
+ function formatDateForDisplay(date) {
|
|
|
|
|
+ return flatpickr.formatDate(date, "d/m/Y");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function formatDateForRequest(date) {
|
|
|
|
|
+ return flatpickr.formatDate(date, "Y-m-d");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function getDateFromRequestValue(value) {
|
|
|
|
|
+ return flatpickr.parseDate(value, "Y-m-d");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function setRangeText(fromDate, toDate) {
|
|
|
|
|
+ document.getElementById("dateRange").value = `${formatDateForDisplay(fromDate)} - ${formatDateForDisplay(toDate)}`;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function syncRangeFields(selectedDates) {
|
|
|
|
|
+ if (selectedDates.length === 0) return;
|
|
|
|
|
+
|
|
|
|
|
+ const fromDate = selectedDates[0];
|
|
|
|
|
+ const toDate = selectedDates.length > 1 ? selectedDates[1] : selectedDates[0];
|
|
|
|
|
+
|
|
|
|
|
+ document.getElementById("fromDate").value = formatDateForRequest(fromDate);
|
|
|
|
|
+ document.getElementById("toDate").value = formatDateForRequest(toDate);
|
|
|
|
|
+ setRangeText(fromDate, toDate);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function initBrandedRangePicker(selector, yearStart, yearEnd) {
|
|
|
const inputEl = document.querySelector(selector);
|
|
const inputEl = document.querySelector(selector);
|
|
|
- const wrapper = inputEl.closest('.date-pick-input');
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const wrapper = inputEl.closest('.date-range-input');
|
|
|
|
|
+ const fromDate = getDateFromRequestValue(document.getElementById("fromDate").value);
|
|
|
|
|
+ const toDate = getDateFromRequestValue(document.getElementById("toDate").value);
|
|
|
|
|
+
|
|
|
|
|
+ setRangeText(fromDate, toDate);
|
|
|
|
|
+
|
|
|
flatpickr(selector, {
|
|
flatpickr(selector, {
|
|
|
|
|
+ mode: "range",
|
|
|
dateFormat: "Y-m-d",
|
|
dateFormat: "Y-m-d",
|
|
|
- altInput: true,
|
|
|
|
|
- altFormat: "M d, Y",
|
|
|
|
|
- altInputClass: "bg-transparent border-none outline-none font-bold text-[13px] w-full ml-1 cursor-pointer",
|
|
|
|
|
|
|
+ defaultDate: [fromDate, toDate],
|
|
|
disableMobile: true,
|
|
disableMobile: true,
|
|
|
monthSelectorType: "dropdown",
|
|
monthSelectorType: "dropdown",
|
|
|
appendTo: wrapper,
|
|
appendTo: wrapper,
|
|
|
|
|
+ onChange: function (selectedDates) {
|
|
|
|
|
+ syncRangeFields(selectedDates);
|
|
|
|
|
+ },
|
|
|
|
|
+ onClose: function (selectedDates, dateStr, instance) {
|
|
|
|
|
+ syncRangeFields(selectedDates);
|
|
|
|
|
+ if (selectedDates.length === 1) {
|
|
|
|
|
+ instance.setDate([selectedDates[0], selectedDates[0]], false);
|
|
|
|
|
+ setRangeText(selectedDates[0], selectedDates[0]);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
onReady: function (selectedDates, dateStr, instance) {
|
|
onReady: function (selectedDates, dateStr, instance) {
|
|
|
instance.calendarContainer.style.zIndex = "9999";
|
|
instance.calendarContainer.style.zIndex = "9999";
|
|
|
const yearInput = instance.calendarContainer.querySelector(".numInput.cur-year");
|
|
const yearInput = instance.calendarContainer.querySelector(".numInput.cur-year");
|
|
@@ -148,8 +185,7 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
- initBrandedFlatpickr("#fromDate", 2020, 2030);
|
|
|
|
|
- initBrandedFlatpickr("#toDate", 2020, 2030);
|
|
|
|
|
|
|
+ initBrandedRangePicker("#dateRange", 2020, 2030);
|
|
|
triggerSearch(); // Initial load for all games
|
|
triggerSearch(); // Initial load for all games
|
|
|
});
|
|
});
|
|
|
|
|
|