JS optimization

This commit is contained in:
Dr Masroor Ehsan 2025-01-21 11:20:40 +06:00
parent 5a5177fea7
commit b58abde84b

View File

@ -138,10 +138,9 @@ function generateUrl() {
altInput: true, altInput: true,
altFormat: "j M (D)", altFormat: "j M (D)",
disable: [ disable: [
function (givenDate) { givenDate => {
const today = new Date(); const maxDate = new Date();
const maxDate = new Date(today); maxDate.setDate(maxDate.getDate() + 1);
maxDate.setDate(today.getDate() + 1);
return givenDate > maxDate; return givenDate > maxDate;
} }
] ]
@ -155,29 +154,20 @@ function (givenDate) {
$('#search_button').on('click', function () { $('#search_button').on('click', function () {
resetParams(); resetParams();
const study_range = fp_study.selectedDates; const ranges = [
if (study_range.length == 2) { {picker: fp_study, from: '_study_from', to: '_study_to'},
_study_from = formatDate(study_range[0]); {picker: fp_receive, from: '_receive_from', to: '_receive_to'},
_study_to = formatDate(study_range[1]); {picker: fp_assign, from: '_assign_from', to: '_assign_to'},
} {picker: fp_read, from: '_read_from', to: '_read_to'}
];
const receive_range = fp_receive.selectedDates; ranges.forEach(range => {
if (receive_range.length == 2) { const selectedDates = range.picker.selectedDates;
_receive_from = formatDate(receive_range[0]); if (selectedDates.length === 2) {
_receive_to = formatDate(receive_range[1]); window[range.from] = formatDate(selectedDates[0]);
} window[range.to] = formatDate(selectedDates[1]);
const assign_range = fp_assign.selectedDates;
if (assign_range.length == 2) {
_assign_from = formatDate(assign_range[0]);
_assign_to = formatDate(assign_range[1]);
}
const read_range = fp_read.selectedDates;
if (read_range.length == 2) {
_read_from = formatDate(read_range[0]);
_read_to = formatDate(read_range[1]);
} }
});
const modalityArray = []; const modalityArray = [];
@foreach ($modalities as $modality) @foreach ($modalities as $modality)