1var openHours = []; 2function gravityDatePickerFix() { 3 if (typeof gform !== 'undefined') { 4 gform.addFilter('gform_datepicker_options_pre_init', function (optionsObj, formId, fieldId) { 5 if (autolab_datepicker.autolab_scheduler.enabled.includes(formId)) { 6 //apply only on schedule and appointment forms 7 setTimeout(function () { 8 jQuery('.datepicker').datepicker({}).attr('readonly', 'readonly'); 9 }, 500); 10 var wait = autolab_datepicker.autolab_scheduler.wait_time; 11 var week_start = autolab_datepicker.autolab_scheduler.week_start; 12 var d = new Date(); // for now 13 var day = d.getDay(); 14 var h = d.getHours(); // => 9 15 var m = d.getMinutes(); // => 30 16 var addDay = 0; //Add Day if after hours 17 if (autolab_datepicker.autolab_scheduler.hours[day].close.split(':')[0] <= h && autolab_datepicker.autolab_scheduler.midnight_reset !== 'Yes') { 18 addDay = 1; 19 } 20 if (wait <= 0) { 21 wait = 1 + addDay; 22 } else { 23 wait = Math.ceil(wait / 24) + addDay; 24 } 25 if (!week_start) { 26 week_start = 0; 27 } 28 if (autolab_datepicker.autolab_scheduler.same_day === 'Yes' && !autolab_datepicker.autolab_scheduler.closed_days.includes(day)) { 29 wait = 0; 30 } 31 32 cdaycount = 0; 33 while (autolab_datepicker.autolab_scheduler.closed_days.includes(day + cdaycount)) { 34 wait++; 35 cdaycount++; 36 } 37 38 optionsObj.firstDay = week_start; //set first day to Sunday 39 optionsObj.minDate = +wait; 40 optionsObj.maxDate = '+3M +10D'; 41 optionsObj.showOn = 'both'; 42 optionsObj.dateFormat = 'mm/dd/yy'; 43 optionsObj.buttonImage = 'https://hub.autoshopdashboard.com/autoshopplugins/theme_assets/common/calendar-img.png'; //pull calendar image from CDN 44 optionsObj.beforeShowDay = function (date) { 45 var disabledDays = autolab_datepicker.autolab_scheduler.blackout, 46 currentDate = jQuery.datepicker.formatDate('mm/dd/yy', date), 47 day = date.getDay(); 48 49 return [!(disabledDays.indexOf(currentDate) != -1 || autolab_datepicker.autolab_scheduler.closed_days.includes(day))]; //Disable blackout days and selected days of the week 50 }; 51 optionsObj.onClose = function () { 52 autolab_schedule_times('#input_' + formId + '_' + fieldId); //Fire time options function on close 53 }; 54 } //add else init datepicker 55 56 return optionsObj; 57 }); 58 } 59} 60 61function isToday(someDate) { 62 var today = new Date(); 63 return someDate.getDate() == today.getDate() && someDate.getMonth() == today.getMonth() && someDate.getFullYear() == today.getFullYear(); 64} 65 66function markupCheck(fieldId) { 67 var timeSelect = jQuery(fieldId.replace('input', 'field')).next('li').attr('id'); 68 if (!timeSelect) { 69 timeSelect = jQuery(fieldId.replace('input', 'field')).next('div').attr('id'); 70 } 71 timeSelect = jQuery('#' + timeSelect.replace('field', 'input')); 72 var selected = new Date(jQuery(fieldId).val()); 73 if (selected instanceof Date) { 74 var today = new Date(); 75 var day = selected.getDay(); 76 if (day !== undefined) { 77 openHours = as_get_hours(day, selected); 78 //clear options 79 jQuery(timeSelect).empty(); 80 81 //set blank option 82 var option = jQuery('<option></option>').attr('value', '').text('Choose a Time'); 83 jQuery(timeSelect).append(option); 84 let $morning = true; 85 //add options to select 86 openHours.forEach(function (e) { 87 let t = e.split(':'); 88 if (!$morning && t[0] < 12) { 89 t[0] = parseInt(t[0]) + 12; 90 } 91 if (t[0] > 12) { 92 t[0] = t[0] - 12; 93 e = t[0] + ':' + t[1] + ' PM'; 94 } else if (t[0] == 12) { 95 e = t[0] + ':' + t[1] + ' PM'; 96 if ($morning) { 97 $morning = false;
98 } 99 } else if (t[0] == 0) { 100 e = '12:' + t[1] + ' AM'; 101 } else { 102 e = t[0] + ':' + t[1] + ' AM'; 103 } 104 option = jQuery('<option></option>').attr('value', e).text(e); 105 jQuery(timeSelect).append(option); 106 }); 107 } 108 } 109} 110 111function as_get_hours(day, selected) { 112 if (false) { 113 //check for integration will go here 114 } else if (isNaN(day) === false) { 115 var open = autolab_datepicker.autolab_scheduler.hours[day].open.split(':'); //get open hours for the selected day 116 var close = autolab_datepicker.autolab_scheduler.hours[day].close.split(':'); //get close hours for the selected day 117 var formatedSelected = jQuery.datepicker.formatDate('mm/dd/yy', selected); 118 if (autolab_datepicker.autolab_scheduler.hours[day].advanced) { 119 var advanced = autolab_datepicker.autolab_scheduler.hours[day].advanced; 120 if (advanced[advanced.length - 1] === ',') { 121 advanced = advanced.substring(0, advanced.length - 1); 122 } 123 openHours = advanced.split(','); //remove hours that have already passed today is selected 124 if (isToday(selected) && autolab_datepicker.autolab_scheduler.same_day === 'Yes') { 125 var h = today.getHours() + autolab_datepicker.autolab_scheduler.same_day_buffer; 126 var oH = open[0]; 127 var oM = open[1]; 128 var cH = close[0]; 129 var cM = close[1]; 130 var ccount = oH; 131 while (ccount <= cH) { 132 if (openHours.includes(ccount + ':00')) { 133 //TDL 134 } 135 ccount++; 136 } 137 } 138 } else if (autolab_datepicker.autolab_scheduler.partial_days && autolab_datepicker.autolab_scheduler.partial_days[formatedSelected] != undefined) { 139 autolab_datepicker.autolab_scheduler.partial_days[formatedSelected].hours.pop(); 140 openHours = autolab_datepicker.autolab_scheduler.partial_days[formatedSelected].hours; 141 } else { 142 openHours = autolab_default_hours(open, close, day, selected); 143 } 144 } 145 return openHours; 146} 147 148function autolab_schedule_times(fieldId) { 149 markupCheck(fieldId); 150} 151 152function autolab_default_hours(open, close, day, selected) { 153 var closeHour = parseInt(close[0]); 154 if (closeHour < 12) { 155 closeHour += 12; 156 } 157 var count = (closeHour - open[0]) * 2 - 1; 158 if (count > 24) { 159 count = count - 24; 160 } 161 if (open[1] == '30' && close[1] == '30') { 162 count = count; 163 } else if (close[1] == '30') { 164 count = count + 1; 165 } else if (open[1] == '30') { 166 count = count - 1; 167 } 168 var i = 0; 169 var isHalf = false; 170 if (open[1] == '30') { 171 isHalf = true; 172 } 173 var h = open[0] * 1; 174 if (isToday(selected) && autolab_datepicker.autolab_scheduler.same_day === 'Yes') { 175 var today = new Date(); 176 h = today.getHours() + autolab_datepicker.autolab_scheduler.same_day_buffer; 177 count = (closeHour - h) * 2 - 2; 178 if (count > 24) { 179 count = count - 24; 180 } 181 if (h > 12) { 182 h = h - 12; 183 } 184 } 185 var m = open[1]; 186 openHours = []; // reset array; 187 //build array of time slots 188 while (i <= count) { 189 if (m == '30') { 190 openHours.push(h + ':' + m); 191 m = '00'; 192 h++; 193 if (h > 12) { 194 h = h - 12; 195 } 196 } else { 197 openHours.push(h + ':' + m); 198 m = '30'; 199 } 200 i++; 201 } 202 return openHours; 203} 204 205jQuery(document).ready(gravityDatePickerFix());
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.