PageSourceSearch

https://degenstberg.be/wp-content/plugins/doctapp-core/assets/render/js/script.js?ver=7.1.2

js degenstberg.be collected 2026-10-02 00:26:27 UTC 46,809 bytes, 1,026 lines download raw bytes

1jQuery( document ).ready(function( $ ) {
2    'use strict';
3
4    var offDay;
5
6    jQuery("#emShowPM").css("display","none");
7    jQuery(".pt-timer").css("display","none");
8
9    var doctorAndFormContainer = jQuery(".pt-appointment-ticket-container");
10    if(doctorAndFormContainer){
11        jQuery(".pt-appointment-ticket-container").parent().children(".pt-doctors-and-form-container").css("display","none");;
12    }
13
14    // Enable BS tooltip feature
15    jQuery("body").tooltip({ selector: '[data-toggle=tooltip]' });
16
17
18    // Select a doctor
19    jQuery('.pt-select-doctor-button').on('click', function() {
20        scrollToTopDiv();
21        
22        jQuery(this).closest(".pt-doctor").addClass('selected');
23        
24        jQuery(this).closest(".pt-doctor").siblings().removeClass('selected');
25        jQuery(".pt-doctors-container").css({
26            'transition': 'all .4s ease-in-out',
27            'transform' : 'scale(0.8)',
28            'display' : 'none',
29            'opacity' : '0',
30            'height': '0'
31         });
32         jQuery(".pt-appointment-process-container").css({
33            'transition': 'all .8s ease-in-out',
34            'transform' : 'scale(1)',
35           'display' : 'block',
36            'opacity' : '1',
37            'height': '100%'
38         });
39
40         
41
42        var selectedService = jQuery(this).closest(".pt-doctor").children(".pt-doctor-excerpt").html();
43        jQuery('.pt-get-selected-doctor').html(selectedService);
44        
45        addServiceDateId();
46        disablePassedDays();
47        setTimeout(disableOffDays,500);
48        
49        // Only for the full day reservation doctors
50        var checkSlotEnabled = jQuery("article.pt-doctor.selected #pt_fullDayReserve").is(":checked");
51        if(checkSlotEnabled){
52            disableAleadyBookedDates();
53            enableAvailableDatesOfFullDayReservation();
54        } else {
55            enableDatesAsAvailableOnlyOnTimeSlot();
56        }
57
58        
59
60    });
61
62    function scrollToTopDiv(){
63        var scrollToptContainer = jQuery('.pt-plugin-container').offset();
64        window.scroll({
65            top: scrollToptContainer.top - 100,
66            left: scrollToptContainer.left
67          });
68    }
69
70    jQuery('.pt-change-doctor-btn').on('click', function() {
71        window.location.reload(false); 
72    });
73
74
75    // Calendar
76    var selectedYear = "";
77    var months = "";
78    var selectedMonth = "";
79    var selectedMonthNumber = "";
80    var selectedDate = "";
81    var days = "";
82    var selectedDay = "";
83    var selectedDateMonthYear = "";
84    var pt_selected_doctor_date_id_for_db = "";
85    var selectedDateMonthYearTimestamp = "";
86
87    jQuery('.pt-appointment-calendar').calendar({
88        date: new Date(),
89        autoSelect: false, // false by default
90        select: function(date) {
91            selectedYear = date.getFullYear();
92            months = ["Jan","Feb","March","April","May","June","July","Aug","Sept","Oct","Nov","Dec"];
93            selectedMonth = months[date.getMonth()];
94            selectedMonthNumber = date.getMonth();
95            selectedDate = date.getDate();
96            days = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
97            selectedDay = days[date.getDay()];
98            selectedDateMonthYear = selectedDate + selectedMonthNumber + selectedYear;
99
100            // For creating slot starting time
101            var selectedMonthNumberIncr = selectedMonthNumber + 1;
102            selectedDateMonthYearTimestamp = selectedYear +'-'+ selectedMonthNumberIncr +'-'+ selectedDate;
103
104        }
105    });
106
107
108    jQuery(document).on('click','.pt-appointment-calendar button.ic', function(){
109            addServiceDateId();  
110            onIcClickdisableOffDays();   
111            onIcClickdisablePassedDays(); 
112            var checkSlotEnabled = jQuery("article.pt-doctor.selected #pt_fullDayReserve").is(":checked");
113            if(checkSlotEnabled){
114                disableAleadyBookedDates();
115                enableAvailableDatesOfFullDayReservation();
116            } else {
117                enableDatesAsAvailableOnlyOnTimeSlot();
118            }
119            
120
121    });
122
123
124
125    var monthYearOnCalendar = "";
126    var ptServiceStartingDateGetDateTime = "";
127
128    // Disable passed dates
129    function addServiceDateId(){
130        
131        // Return today's date and time
132        var currentTime = new Date();
133        // returns the day of the month (from 1 to 31)
134        var currentDate = currentTime.getDate();
135        // returns the month (from 0 to 11)
136        var currentMonth = currentTime.getMonth() + 1;
137        // returns the year (four digits)
138        var currentYear = currentTime.getFullYear();
139        var activeYearValue = jQuery(".pt-appointment-calendar .year-month .month-head div").text();
140        activeYearValue = parseInt(activeYearValue, 10);
141        var eachActiveYearString = activeYearValue.toString();
142    
143        var activeMonthValue = jQuery(".pt-appointment-calendar .year-body tr td.active").data("month");
144        activeMonthValue = parseInt(activeMonthValue, 10);
145        var eachActiveMonthString = activeMonthValue.toString();
146
147        // Date Id
148        var pt_selected_doctor_id = jQuery("article.pt-doctor.selected #pt-doctor-id input").val();
149        var pt_selected_doctor_each_date_id = pt_selected_doctor_id +'-'+ eachActiveYearString +'-'+ eachActiveMonthString;
150        var i = 1;
151        for(i=1;i<=31; i++){
152            jQuery(".pt-appointment-calendar tbody.month-days tr td[data-date='" + i +"']").attr('data-doctordateid', pt_selected_doctor_each_date_id +'-'+ i).attr('title', 'Unvailable').addClass("unavailable pt-doctor-date-unavailable").attr('disabled', true).attr('data-toggle', 'tooltip');
153            
154        }
155
156
157    }
158
159
160    
161    var monthYearOnCalendar = "";
162    var ptServiceStartingDateGetDateTime = "";
163
164    // Disable Off days
165    function disableOffDays(){
166    
167        var offDays;
168        offDays = jQuery("article.pt-doctor.selected .emOffDays").map(function() {
169            return this.value;
170        }).get();
171        
172        jQuery.each( offDays, function( i, val ) {
173            offDay = jQuery(".pt-appointment-calendar tbody.month-days tr").children('td:nth-child('+ val +')').addClass("unavailable off-day").attr('disabled', true).attr('title', 'Weekly Off Day');
174            // Will stop running after "7"
175            return ( val !== 7 );
176
177        });
178
179    }
180
181    function onIcClickdisableOffDays(){
182        var offDays;
183        offDays = jQuery("article.pt-doctor.selected .emOffDays").map(function() {
184            return this.value;
185        }).get();
186
187        jQuery.each( offDays, function( i, val ) {
188            offDay = jQuery(".pt-appointment-calendar tbody.month-days tr").children('td:nth-child('+ val +')').addClass("unavailable off-day").attr('disabled', true).attr('title', 'Weekly Off Day');
189            // Will stop running after "7"
190            return ( val !== 7 );
191        });
192    
193        jQuery(".pt-appointment-calendar td.ripple-element").on("click", function(){
194
195            var isDisabled = jQuery(this).hasClass("unavailable"); 
196            if(!isDisabled){
197                jQuery('.date').html(selectedDay + ',  ' + selectedDate + ' ' + selectedMonth + ' ' + selectedYear);
198                jQuery(".pt-calendar-wrapper").css("display","none");
199                jQuery(".pt-change-date-btn").slideDown("slow");
200                jQuery(".pt-selected-date-wrapper").slideDown("slow");
201
202                pt_selected_doctor_date_id_for_db = jQuery(this).data("doctordateid");
203
204                var checkSlotEnabled = jQuery("article.pt-doctor.selected #pt_fullDayReserve").is(":checked");
205                if(checkSlotEnabled){
206                    fullDayReservationFunc();
207                } else {
208                    accordionAmPm();
209                    amSlotCalculate();
210                    pmSlotCalculate();
211                }
212                
213
214            };
215        });
216    }
217
218    // Disable passed dates
219    function disablePassedDays(){
220        // Return today's date and time
221        var currentTime = new Date();
222        // returns the day of the month (from 1 to 31)
223        var currentDate = currentTime.getDate();
224        // returns the month (from 0 to 11)
225        var currentMonth = currentTime.getMonth() + 1;
226        // returns the year (four digits)
227        var currentYear = currentTime.getFullYear();
228        var activeYearValue = jQuery(".pt-appointment-calendar .year-month .month-head div").text();
229        activeYearValue = parseInt(activeYearValue, 10);
230        var eachActiveYearString = activeYearValue.toString();
231    
232        var activeMonthValue = jQuery(".pt-appointment-calendar .year-body tr td.active").data("month");
233        activeMonthValue = parseInt(activeMonthValue, 10);
234        var eachActiveMonthString = activeMonthValue.toString();
235
236        var todayDateValue = jQuery(".pt-appointment-calendar tbody.month-days tr td.today").data("date");
237        var eachDateValue = jQuery(".pt-appointment-calendar tbody.month-days tr td").data("date");
238
239        if(currentYear === activeYearValue && currentMonth === activeMonthValue){
240            var i = 1;
241            for(i=1;i<todayDateValue; i++){
242                jQuery(".pt-appointment-calendar tbody.month-days tr td[data-date='" + i +"']").addClass("unavailable passed-day").attr('disabled', true).attr('title', 'Date Passed');
243            }
244        } 
245
246
247    }
248
249    // Onclick on arrow button
250    function onIcClickdisablePassedDays(){
251        // Return today's date and time
252        var currentTime = new Date();
253        // returns the day of the month (from 1 to 31)
254        var currentDate = currentTime.getDate();
255        // returns the month (from 0 to 11)
256        var currentMonth = currentTime.getMonth() + 1;
257        // returns the year (four digits)
258        var currentYear = currentTime.getFullYear();
259
260        var activeYearValue = jQuery(".pt-appointment-calendar .year-month .month-head div").text();
261        activeYearValue = parseInt(activeYearValue, 10);
262        var eachActiveYearString = activeYearValue.toString();
263
264        var activeMonthValue = jQuery(".pt-appointment-calendar .year-body tr td.active").data("month");
265        activeMonthValue = parseInt(activeMonthValue, 10);
266        var eachActiveMonthString = activeMonthValue.toString();
267
268        var todayDateValue = jQuery(".pt-appointment-calendar tbody.month-days tr td.today").data("date");
269        var eachDateValue = jQuery(".pt-appointment-calendar tbody.month-days tr td").data("date");
270
271
272        var i = 0;
273        if(currentYear == activeYearValue && currentMonth == activeMonthValue){
274            for(i=1;i<todayDateValue; i++){
275                jQuery(".pt-appointment-calendar tbody.month-days tr td[data-date='" + i +"']").addClass("unavailable passed-day").removeClass("available pt-doctor-date-available").attr('disabled', true).attr('title', 'Date Passed');
276            }
277            
278        } else if(currentYear == activeYearValue  && currentMonth > activeMonthValue){
279            todayDateValue = 31;
280            for(i;i<todayDateValue; i++){
281                jQuery(".pt-appointment-calendar tbody.month-days tr td").addClass("unavailable passed-day").removeClass("available pt-doctor-date-available").attr('disabled', true).attr('title', 'Date Passed');
282            }
283            
284        } else if(currentYear > activeYearValue){
285            todayDateValue = 31;
286            for(i;i<todayDateValue; i++){
287                jQuery(".pt-appointment-calendar tbody.month-days tr td").addClass("unavailable passed-day").removeClass("available pt-doctor-date-available").attr('disabled', true).attr('title', 'Date Passed');
288            }
289            
290        }
291
292
293
294        // Availability starts from
295        var ptServiceStartingDate = jQuery("article.pt-doctor.selected .pt_doctor_availability_starts_at").val();
296        var ptServiceStartingDateGetDate = new Date(ptServiceStartingDate);
297        var ptServiceStartingDateGetDateTime = ptServiceStartingDateGetDate.getTime();
298        var makeSmallerStartingDate = ptServiceStartingDateGetDateTime / 1000;
299        // Availability ends at
300        var ptServiceEndingDate = jQuery("article.pt-doctor.selected .pt_doctor_availability_ends_at").val();
301        var ptServiceEndingDateGetDate = new Date(ptServiceEndingDate);
302        var ptServiceEndingDateGetDateTime = ptServiceEndingDateGetDate.getTime();
303        var makeSmallerEndingDate = ptServiceEndingDateGetDateTime / 1000;
304
305        monthYearOnCalendar = eachActiveYearString +'-'+ eachActiveMonthString;
306
307        for(var i=1;i<=31; i++){
308            var datesOnCalendar = monthYearOnCalendar +'-'+ i;
309            var datesOnCalendarGetDate = new Date(datesOnCalendar);
310            var datesOnCalendarGetDateTime = datesOnCalendarGetDate.getTime();
311            var makeSmallerCDate = datesOnCalendarGetDateTime / 1000;
312            if(makeSmallerStartingDate <= makeSmallerCDate && makeSmallerCDate <= makeSmallerEndingDate){
313                jQuery(".pt-appointment-calendar tbody.month-days tr td[data-date='" + i +"']").attr('title', 'Available').removeClass("unavailable pt-doctor-date-unavailable").addClass("pt-doctor-date-available");
314            } 
315        }
316
317
318        
319
320
321    };
322
323    // Disable Off days Ends
324
325    // Enable available dates of Full day reservation
326
327    function enableAvailableDatesOfFullDayReservation(){
328        var activeYearValue = jQuery(".pt-appointment-calendar .year-month .month-head div").text();
329        activeYearValue = parseInt(activeYearValue, 10);
330        var eachActiveYearString = activeYearValue.toString();
331
332        var activeMonthValue = jQuery(".pt-appointment-calendar .year-body tr td.active").data("month");
333        activeMonthValue = parseInt(activeMonthValue, 10);
334        var eachActiveMonthString = activeMonthValue.toString();
335        // Availability starts from
336        var ptServiceStartingDate = jQuery("article.pt-doctor.selected .pt_doctor_availability_starts_at").val();
337        var ptServiceStartingDateGetDate = new Date(ptServiceStartingDate);
338        ptServiceStartingDateGetDateTime = ptServiceStartingDateGetDate.getTime();
339        var makeSmallerStartingDate = ptServiceStartingDateGetDateTime / 1000;
340        // Availability ends at
341        var ptServiceEndingDate = jQuery("article.pt-doctor.selected .pt_doctor_availability_ends_at").val();
342        var ptServiceEndingDateGetDate = new Date(ptServiceEndingDate);
343        var ptServiceEndingDateGetDateTime = ptServiceEndingDateGetDate.getTime();
344        var makeSmallerEndingDate = ptServiceEndingDateGetDateTime / 1000;
345
346        monthYearOnCalendar = eachActiveYearString +'-'+ eachActiveMonthString;
347        var pt_orders_per_slot = jQuery("article.pt-doctor.selected .pt-doctor-appointment-orders-per-slot input").val();
348        for(var i=1;i<=31; i++){
349            var datesOnCalendar = monthYearOnCalendar +'-'+ i;
350            var datesOnCalendarGetDate = new Date(datesOnCalendar);
351            var datesOnCalendarGetDateTime = datesOnCalendarGetDate.getTime();
352            var makeSmallerCDate = datesOnCalendarGetDateTime / 1000;
353            if(makeSmallerStartingDate <= makeSmallerCDate && makeSmallerCDate <= makeSmallerEndingDate){
354                jQuery(".pt-appointment-calendar tbody.month-days tr td[data-date='" + i +"']").attr('title', 'Available '+ pt_orders_per_slot).removeClass("unavailable pt-doctor-date-unavailable").addClass("pt-doctor-date-available"); 
355            }    
356        }
357    }
358
359    // Enable dates as available only for time slot bookings
360
361    function enableDatesAsAvailableOnlyOnTimeSlot(){   
362
363        var activeYearValue = jQuery(".pt-appointment-calendar .year-month .month-head div").text();
364        activeYearValue = parseInt(activeYearValue, 10);
365        var eachActiveYearString = activeYearValue.toString();
366
367        var activeMonthValue = jQuery(".pt-appointment-calendar .year-body tr td.active").data("month");
368        activeMonthValue = parseInt(activeMonthValue, 10);
369        var eachActiveMonthString = activeMonthValue.toString();
370        // Availability starts from
371        var ptServiceStartingDate = jQuery("article.pt-doctor.selected .pt_doctor_availability_starts_at").val();
372        var ptServiceStartingDateGetDate = new Date(ptServiceStartingDate);
373        ptServiceStartingDateGetDateTime = ptServiceStartingDateGetDate.getTime();
374        var makeSmallerStartingDate = ptServiceStartingDateGetDateTime / 1000;
375        // Availability ends at
376        var ptServiceEndingDate = jQuery("article.pt-doctor.selected .pt_doctor_availability_ends_at").val();
377        var ptServiceEndingDateGetDate = new Date(ptServiceEndingDate);
378        var ptServiceEndingDateGetDateTime = ptServiceEndingDateGetDate.getTime();
379        var makeSmallerEndingDate = ptServiceEndingDateGetDateTime / 1000;
380
381        monthYearOnCalendar = eachActiveYearString +'-'+ eachActiveMonthString;
382        for(var i=1;i<=31; i++){
383            var datesOnCalendar = monthYearOnCalendar +'-'+ i;
384            var datesOnCalendarGetDate = new Date(datesOnCalendar);
385            var datesOnCalendarGetDateTime = datesOnCalendarGetDate.getTime();
386            var makeSmallerCDate = datesOnCalendarGetDateTime / 1000;
387            if(makeSmallerStartingDate <= makeSmallerCDate && makeSmallerCDate <= makeSmallerEndingDate){
388                jQuery(".pt-appointment-calendar tbody.month-days tr td[data-date='" + i +"']").attr('title', 'Has Slots').removeClass("unavailable pt-doctor-date-unavailable").addClass("pt-doctor-date-available"); 
389            }
390                
391        }
392
393
394     }
395
396
397    // Disable Booked dates (Only for the full day reservation doctors)
398    function disableAleadyBookedDates(){
399        
400        jQuery(".pt-calender-loading-gif").css("display","flex");
401        
402        // check date availabilty with ajax
403        var pt_create_nonce = jQuery("#pt-create-nonce").val();
404        var pt_selected_doctor_id = jQuery("article.pt-doctor.selected #pt-doctor-id input").val();
405        var data = {
406            'action': 'pt_appointment_dates',
407            'security': pt_create_nonce,
408            'check_availability_of_date': pt_selected_doctor_id
409        };
410       // Disable the already booked dates with ajax
411        var bookedDates;
412        $.ajax({
413            type: 'POST',
414            url: frontend_ajax_object.ajaxurl,
415            data: data,
416            dataType:"json",
417            success: function(response) {
418                bookedDates = response;
419                if(response == 'error'){
420                    jQuery(".pt-appointment-calendar tbody.month-days tr td").addClass("unavailable already-booked").attr('title', 'Already Booked');
421                } else {
422                    $.each(response, function(index, slot) {
423                        var isOffDay = jQuery(".pt-appointment-calendar tbody.month-days tr td[data-doctordateid='" + slot.a
423ppointment_date_id +"']").hasClass("off-day"); 
424                        var isDatePassed = jQuery(".pt-appointment-calendar tbody.month-days tr td[data-doctordateid='" + slot.appointment_date_id +"']").hasClass("passed-day"); 
425                        var isunavailable = jQuery(".pt-appointment-calendar tbody.month-days tr td[data-doctordateid='" + slot.appointment_date_id +"']").hasClass("unavailable"); 
426                        
427                        if(!isOffDay && !isDatePassed && !isunavailable){ 
428                            if(slot.available_appointments == 0){
429                                jQuery(".pt-appointment-calendar tbody.month-days tr td[data-doctordateid='" + slot.appointment_date_id +"']").addClass("unavailable already-booked").attr('title', 'Already Booked');
430                            } else {                      
431                                jQuery(".pt-appointment-calendar tbody.month-days tr td[data-doctordateid='" + slot.appointment_date_id +"']").attr('title', 'Available '+ slot.available_appointments);
432                            }
433                        }
434                        
435                    });
436                }
437                
438                
439                jQuery(".pt-calender-loading-gif").fadeOut(1000);
440
441                
442            }
443
444        });
445
446    }
447
448    // Ends Disable Already booked date slots //
449    
450
451    // Date selection
452    jQuery(".pt-appointment-calendar td.ripple-element").on("click", function(){
453        
454        var isDisabled = jQuery(this).hasClass("unavailable"); 
455
456        if(!isDisabled){
457
458            pt_selected_doctor_date_id_for_db = jQuery(this).data("doctordateid");
459
460            jQuery('.date').html(selectedDay + ',  ' + selectedDate + ' ' + selectedMonth + ' ' + selectedYear);
461            jQuery(".pt-calendar-wrapper").css("display","none");
462            jQuery(".pt-change-date-btn").slideDown("slow");
463            jQuery(".pt-selected-date-wrapper").slideDown("slow");
464
465            var checkSlotEnabled = jQuery("article.pt-doctor.selected #pt_fullDayReserve").is(":checked");
466            if(checkSlotEnabled){
467                fullDayReservationFunc();
468            } else {
469                accordionAmPm();
470                amSlotCalculate();
471                pmSlotCalculate();
472            }
473               
474        };
475
476    });
477
478    
479
480
481
482    // Change Date
483    jQuery('.pt-change-date-btn').on('click', function(){
484        jQuery(".pt-timer").css("display","none");
485        jQuery(".pt-appointment-form-container").slideUp("slow");
486        jQuery(".pt-calendar-wrapper").slideDown(800);
487    });
488
489
490    //***********************************************/
491    // Create dynamic time slot for AM
492    //***********************************************/
493
494    // Slide show the Slot accordion
495    function accordionAmPm(){
496        
497        jQuery(".pt-timer").slideDown(800);
498        jQuery('#amButton').on('click', function(){
499            jQuery(this).addClass('active');
500            jQuery('#pmButton').removeClass('active');
501            jQuery('#emShowPM').slideUp();
502            jQuery('#emShowAM').slideDown(); 
503        });
504    
505        jQuery('#pmButton').on('click', function(){
506            jQuery(this).addClass('active');
507            jQuery('#amButton').removeClass('active');
508            jQuery('#emShowAM').slideUp();
509            jQuery('#emShowPM').slideDown();
510        });
511    }
512    
513
514
515    function amSlotCalculate() {
516
517        // Return today's date and time
518        var currentTime = new Date();
519        // get current time in miliseconds
520        var currentTimeInMiliSeconds = currentTime.getTime();
521        
522        // Get Selected Doctor Slot Duration
523        var amTimeSlotSelected = parseInt(jQuery("article.pt-doctor.selected .am-time-slot .amSlotDuration").val(), 10);
524        var amTimeSlot = amTimeSlotSelected;
525        // Get Selected Doctor Start and End Time (AM)
526        var amTimeOne = jQuery("article.pt-doctor.selected .amSlotStarts").val().split(':'), amTimeTwo = jQuery("article.pt-doctor.selected .amSlotEnds").val().split(':');
527        var amHoursOne = parseInt(amTimeOne[0], 10), 
528            amHoursTwo = parseInt(amTimeTwo[0], 10),
529            amMinsOne = parseInt(amTimeOne[1], 10),
530            amMinsTwo = parseInt(amTimeTwo[1], 10);
531
532        var amTotalHours = amHoursTwo - amHoursOne, amMinsDiffers = 0;
533
534        // get hours
535        if(amTotalHours < 0) amTotalHours = 24 + amTotalHours;
536        // get minutes
537        if(amMinsTwo >= amMinsOne) {
538            amMinsDiffers = amMinsTwo - amMinsOne;
539
540        } else {
541            amMinsDiffers = (amMinsTwo + 60) - amMinsOne;
542            amTotalHours--;
543        }
544        // Convert Available Hours to mins
545        var amHoursToMins = amTotalHours*60;
546        var totalMinsOfAM = amHoursToMins+amMinsDiffers;
547        // Count Number of Slots from available hours
548        var amTimeSlotNumber = totalMinsOfAM / amTimeSlot;
549        amTimeSlotNumber = Math.floor(amTimeSlotNumber);
550
551        // Create starting Total Mins from provided starting time by the admin ( amHoursOne, amMinsDiffers )
552        var amStartingHourToMins = amHoursOne*60 + amMinsOne - amTimeSlot;
553        // Create Ending Total Mins from provided starting time by the admin ( amHoursOne, amMinsDiffers )
554        var amEndingHourToMins = amHoursOne*60 + amMinsOne;
555        // Create variable for dynamically creating the Slots
556        var amStartingHour;
557        var amStartingMins;
558        var amEndingHour;
559        var amEndingMins;
560        // Make empty before appending the slots
561        var amSlot = jQuery('#emShowAM').empty();
562        
563        // Start for loop for SlotNumber times
564        for(var i=1; i<=amTimeSlotNumber; ++i){
565            amStartingHourToMins += amTimeSlot;
566            amStartingHour = Math.floor(amStartingHourToMins / 60);
567            amStartingMins = amStartingHourToMins % 60;
568            if(amStartingMins > 60 ) {
569                amStartingMins = amStartingMins - 60;
570                amStartingHour = amStartingHour + 1;
571            }
572            var amShowStartingHour = amStartingHour;
573            if(amShowStartingHour == "0" ) {
574                amShowStartingHour = amShowStartingHour + 12;
575            }
576
577            // Format the time lass than 9 ( Make 1 to 01, 9 to 09)
578            var amShowStartingMins = ("0" + amStartingMins).slice(-2);
579            amEndingHourToMins += amTimeSlot;
580            amEndingHour = Math.floor(amEndingHourToMins / 60);
581            amEndingMins = amEndingHourToMins % 60;
582            if(amEndingMins > 60 ) {
583                amEndingMins = amEndingMins - 60;
584                amEndingHour = amEndingHour + 1;
585            }
586            var showAmEndingHour = amEndingHour;
587            // Format the time lass than 9 ( Make 1 to 01, 9 to 09)
588            var showAmEndingMins = ("0" + amEndingMins).slice(-2);
589            if(showAmEndingMins == "00" ) {
590                showAmEndingMins = 59;
591                showAmEndingHour = showAmEndingHour - 1;
592            }
593
594            if(showAmEndingHour == "0" ) {
595                showAmEndingHour = showAmEndingHour + 12;
596            }
597
598            var pt_orders_per_slot = jQuery("article.pt-doctor.selected .pt-doctor-appointment-orders-per-slot input").val();
599            // Slot Id
600            var pt_selected_doctor_date_id_for_creating_slot_id = pt_selected_doctor_date_id_for_db;
601            var amSlotId = i + "-AM-"+ pt_selected_doctor_date_id_for_creating_slot_id;
602
603            var dateMonthYearOnCalendar = selectedDateMonthYearTimestamp +' '+ amShowStartingHour +':'+ amShowStartingMins;
604            var selectedNewDate = new Date(dateMonthYearOnCalendar);
605            var timeOfSlotInMs = selectedNewDate.getTime();
606
607            if(timeOfSlotInMs > currentTimeInMiliSeconds){
608                amSlot = jQuery('#emShowAM').append('<li class="list-group-item" data-slotId="'+ amSlotId +'"> <label> <input class="d-none pt-slotId" type="text" value="'+ amSlotId +'"> <input class="d-none pt-slot-starts-at" type="text" value="'+ amShowStartingHour +':'+ amShowStartingMins +'"> '+ amShowStartingHour +':'+ amShowStartingMins +' AM - '+ showAmEndingHour +':'+ showAmEndingMins +' AM  </label> <button type="button" class="btn btn-light pt-select-slot-button available" data-toggle="tooltip" title="Available '+ pt_orders_per_slot +'"> Available </button>  </li>');
609            } else {
610                amSlot = jQuery('#emShowAM').append('<li class="list-group-item" data-slotId="'+ amSlotId +'"> <label> <input class="d-none pt-slotId" type="text" value="'+ amSlotId +'"> <input class="d-none pt-slot-starts-at" type="text" value="'+ amShowStartingHour +':'+ amShowStartingMins +'"> '+ amShowStartingHour +':'+ amShowStartingMins +' AM - '+ showAmEndingHour +':'+ showAmEndingMins +' AM  </label> <button type="button" class="btn btn-light pt-select-slot-button booked" data-toggle="tooltip" title="Unavailable"> Time Passed </button>  </li>');
611            }         
612            
613        };
614
615
616    }
617    // Create dynamic time slot for AM Ends 
618
619    //***********************************************/ 
620    // Create dynamic time slot for PM starts
621    //***********************************************/ 
622
623    function pmSlotCalculate() {
624
625        // Return today's date and time
626        var currentTime = new Date();
627        // get current time in miliseconds
628        var currentTimeInMiliSeconds = currentTime.getTime();
629        
630        // Get Selected Doctor Slot Duration
631        var pmTimeSlotSelected = parseInt(jQuery("article.pt-doctor.selected .pm-time-slot .pmSlotDuration").val(), 10);
632        var pmTimeSlot = pmTimeSlotSelected;
633
634        // Get Selected Doctor Start and End Time (AM)
635        var pmTimeOne = jQuery("article.pt-doctor.selected .pmSlotStarts").val().split(':'), pmTimeTwo = jQuery("article.pt-doctor.selected .pmSlotEnds").val().split(':');
636        var pmHoursOne = parseInt(pmTimeOne[0], 10), 
637            pmHoursTwo = parseInt(pmTimeTwo[0], 10),
638            pmMinsOne = parseInt(pmTimeOne[1], 10),
639            pmMinsTwo = parseInt(pmTimeTwo[1], 10);
640
641        var pmTotalHours = pmHoursTwo - pmHoursOne, pmMinsDiffers = 0;
642        // get hours
643        if(pmTotalHours < 0) pmTotalHours = 24 + pmTotalHours;
644        // get minutes
645        if(pmMinsTwo >= pmMinsOne) {
646            pmMinsDiffers = pmMinsTwo - pmMinsOne;
647        } else {
648            pmMinsDiffers = (pmMinsTwo + 60) - pmMinsOne;
649            pmTotalHours--;
650        }
651        // Convert Available Hours to mins
652        var pmHoursToMins = pmTotalHours*60;
653        var totalMinsOfPM = pmHoursToMins+pmMinsDiffers;
654        // Count Number of Slots from available hours
655        var pmTimeSlotNumber = totalMinsOfPM / pmTimeSlot;
656        pmTimeSlotNumber = Math.floor(pmTimeSlotNumber);
657        // Create starting Total Mins from provided starting time by the admin ( pmHoursOne, pmMinsOne )
658        var pmStartingHourToMins = pmHoursOne*60 + pmMinsOne - pmTimeSlot;
659        // Create Ending Total Mins from provided starting time by the admin ( pmHoursOne, pmMinsOne )
660        var pmEndingHourToMins = pmHoursOne*60 + pmMinsOne;
661        // Create variable for dynamically creating the Slots
662        var pmStartingHour;
663        var pmStartingMins;
664        var pmEndingHour;
665        var pmEndingMins;
666        // Make empty before appending the slots
667        var pmSlot = jQuery('#emShowPM').empty();
668
669        // Start for loop for SlotNumber times
670        for(var i=1; i<=pmTimeSlotNumber; ++i){
671
672            pmStartingHourToMins += pmTimeSlot;
673            pmStartingHour = Math.floor(pmStartingHourToMins / 60);
674            pmStartingMins = pmStartingHourToMins % 60;
675            if(pmStartingMins > 60 ) {
676                pmStartingMins = pmStartingMins - 60;
677                pmStartingHour = pmStartingHour + 1;
678            }
679
680            var pmShowStartingHour = pmStartingHour;
681
682            if(pmShowStartingHour == "0" ) {
683                pmShowStartingHour = pmShowStartingHour + 12;
684            }
685
686            if(pmShowStartingHour > 12 ) {
687                pmShowStartingHour = pmShowStartingHour - 12;
688            }
689
690            // Format the time lass than 9 ( Make 1 to 01, 9 to 09)
691            var pmShowStartingMins = ("0" + pmStartingMins).slice(-2);
692            pmEndingHourToMins += pmTimeSlot;
693            pmEndingHour = Math.floor(pmEndingHourToMins / 60);
694            pmEndingMins = pmEndingHourToMins % 60;
695            if(pmEndingMins > 60 ) {
696                pmEndingMins = pmEndingMins - 60;
697                pmEndingHour = pmEndingHour + 1;
698            }
699
700
701            var showPmEndingHour = pmEndingHour;
702
703            // Format the time lass than 9 ( Make 1 to 01, 9 to 09)
704            var showPmEndingMins = ("0" + pmEndingMins).slice(-2);
705
706            if(showPmEndingMins == "00" ) {
707                showPmEndingMins = 59;
708                showPmEndingHour = showPmEndingHour - 1;
709            }
710
711            if(showPmEndingHour == "0" ) {
712                showPmEndingHour = showPmEndingHour + 12;
713            }
714
715            if(showPmEndingHour > 12 ) {
716                showPmEndingHour = showPmEndingHour - 12;
717            }
718
719            var pt_orders_per_slot = jQuery("article.pt-doctor.selected .pt-doctor-appointment-orders-per-slot input").val();
720
721            // Slot Id ( pt_selected_doctor_date_id_for_db is a global variable )
722            var pt_selected_doctor_date_id_for_creating_slot_id = pt_selected_doctor_date_id_for_db;
723            var pmSlotId = i + "-PM-"+ pt_selected_doctor_date_id_for_creating_slot_id;
724            var pmSlotStartingTimeInt = parseInt(pmShowStartingHour);
725            var pmSlotStartingTimeHour = 12 + pmSlotStartingTimeInt;
726
727
728            var dateMonthYearOnCalendar = selectedDateMonthYearTimestamp +' '+ pmSlotStartingTimeHour +':'+ pmShowStartingMins;
729            var selectedNewDate = new Date(dateMonthYearOnCalendar);
730            var timeOfSlotInMs = selectedNewDate.getTime();
731
732            if(timeOfSlotInMs > currentTimeInMiliSeconds){ 
733                pmSlot = jQuery('#emShowPM').append('<li class="list-group-item" data-slotId="'+ pmSlotId +'"> <label> <input class="d-none pt-slotId" type="text" value="'+ pmSlotId +'"> <input class="d-none pt-slot-starts-at" type="text" value="'+ pmSlotStartingTimeHour +':'+ pmShowStartingMins +'">  '+ pmShowStartingHour +':'+ pmShowStartingMins +' PM - '+ showPmEndingHour +':'+ showPmEndingMins +' PM </label> <button type="button" class="btn btn-light pt-select-slot-button available" data-toggle="tooltip" title="Available '+ pt_orders_per_slot +'"> Available </button>  </li>'); 
734             } else {
735                pmSlot = jQuery('#emShowPM').append('<li class="list-group-item" data-slotId="'+ pmSlotId +'"> <label> <input class="d-none pt-slotId" type="text" value="'+ pmSlotId +'"> <input class="d-none pt-slot-starts-at" type="text" value="'+ pmSlotStartingTimeHour +':'+ pmShowStartingMins +'">  '+ pmShowStartingHour +':'+ pmShowStartingMins +' PM - '+ showPmEndingHour +':'+ showPmEndingMins +' PM </label> <button type="button" class="btn btn-light pt-select-slot-button booked" data-toggle="tooltip" title="Unavailable"> Time Passed </button>  </li>'); 
736             }
737
738            
739        };
740
741        check_availability_of_Slot();
742
743    }
744
745    function check_availability_of_Slot(){
746        // Return today's date and time
747        var currentTime = new Date();
748        // get current time in miliseconds
749        var currentTimeInMiliSeconds = currentTime.getTime();
750
751        var pt_orders_per_slot = jQuery("article.pt-doctor.selected .pt-doctor-appointment-orders-per-slot input").val();
752        var pt_orders_per_slot_to_int = parseInt(pt_orders_per_slot);
753        /// check slot availabilty with ajax
754        jQuery(".pt-loading-gif").css("display","flex");
755        var pt_create_nonce = jQuery("#pt-create-nonce").val();
756        var pt_selected_date_id_for_slot_checking_from_db = pt_selected_doctor_date_id_for_db;
757        var pt_slot_action_data = {
758            'action': 'pt_appointment_slot',
759            'security': pt_create_nonce,
760            'check_slots_availability': pt_selected_date_id_for_slot_checking_from_db
761        };
762        $.ajax({
763            type: 'POST',
764            url: frontend_ajax_object.ajaxurl,
765            data: pt_slot_action_data,
766            dataType:"json",
767            success: function(pt_slot_response) {
768
769                if(pt_slot_response == 'error'){
770                    jQuery(".slots li button").addClass("booked").removeClass("available").attr('title', 'Already Booked').text("Booked");
771                } else {
772                    $.each(pt_slot_response, function(index, slot) {
773
774                        var availableOrdersInString = slot.available_appointments;
775                        var starting_time_ms = slot.starting_time_ms;
776                        var availableOrdersInInt = parseInt(availableOrdersInString);
777    
778                        if(starting_time_ms > currentTimeInMiliSeconds){
779                            if(availableOrdersInInt <= 0){
780                                jQuery(".slots li[data-slotid='" + slot.a
780ppointment_slot_id +"'] button").addClass("booked").removeClass("available").attr('title', 'Already Booked').text("Booked");
781                            } else {
782                                jQuery(".slots li[data-slotid='" + slot.appointment_slot_id +"'] button").text("Availabel").attr('title', "Availabel: "+ slot.available_appointments);
783                            }
784                        } else {
785                            jQuery(".slots li[data-slotid='" + slot.appointment_slot_id +"'] button").text("Time Passed").attr('title', "Unavailable").addClass("booked").removeClass("available");
786                        }
787                        
788                    });
789                }
790
791                
792
793                jQuery(".pt-loading-gif").fadeOut(1000);
794
795                SlotSelection();
796                
797            }
798
799          });
800
801    }
802
803    // Create dynamic time slot for PM Ends
804
805    // After selecting the full day reservation run this function
806    function fullDayReservationFunc() { 
807            
808
809            jQuery(".pt-timer").slideUp(800);
810            jQuery(".pt-appointment-form-container").slideDown("slow");
811            jQuery("#pt_user_fullName").focus();
812
813            // Cookie Decoded by getCookie function written below
814            var pt_user_cookie_FullName = getCookie("pt_user_fullName");
815            var pt_user_cookie_Email = getCookie("pt_user_email");
816            var pt_user_cookie_telephone = getCookie("pt_user_telephone");
817
818
819            // Fill the form fields with cookies
820            jQuery("#pt_user_fullName").val(pt_user_cookie_FullName);
821            jQuery("#pt_user_email").val(pt_user_cookie_Email);
822            jQuery("#pt_user_telephone").val(pt_user_cookie_telephone);
823
824
825            // Hidden Form Fields
826            var pt_selected_doctor_id = jQuery("article.pt-doctor.selected #pt-doctor-id input").val();
827            var pt_selected_doctor = jQuery(".pt-selected-doctor #pt-doctor-name").text();
828            var pt_selected_doctor_title = jQuery(".pt-selected-doctor .pt-doctor-title").text();
829            var pt_selected_doctor_location = jQuery(".pt-selected-doctor #pt-doctor-location").text();
830            var pt_admin_email = jQuery("article.pt-doctor.selected .pt-doctor-provider-email input").val();
831            var pt_booked_date = jQuery(".pt-selected-date label").text();
832            var pt_booked_doctor_price = jQuery(".pt-selected-doctor #pt-doctor-price").text();
833            var pt_selected_slot_id = pt_selected_doctor_date_id_for_db + "-Full-Day";
834            var pt_booked_time_slot = "Day Reservation";
835
836            var pt_slot_starts_at_for_db = selectedDateMonthYearTimestamp;
837            var pt_slot_starts_at_for_db_GetDate = new Date(pt_slot_starts_at_for_db);
838            var pt_slot_starts_at_for_db_GetDateTime = pt_slot_starts_at_for_db_GetDate.getTime();
839
840            var pt_orders_per_slot = jQuery("article.pt-doctor.selected .pt-doctor-appointment-orders-per-slot input").val();
841
842            jQuery("#pt_selected_doctor_id").val(pt_selected_doctor_id);
843            jQuery("#pt_selected_doctor").val(pt_selected_doctor);
844            jQuery("#pt_selected_doctor_title").val(pt_selected_doctor_title);
845            jQuery("#pt_selected_doctor_location").val(pt_selected_doctor_location);
846            jQuery("#pt_selected_doctor_email").val(pt_admin_email);
847            jQuery("#pt_selected_doctor_date").val(pt_booked_date);
848            jQuery("#pt_selected_doctor_price").val(pt_booked_doctor_price);
849            jQuery("#pt_selected_doctor_date_id").val(pt_selected_doctor_date_id_for_db);
850            jQuery("#pt_selected_slot_id").val(pt_selected_slot_id);
851            jQuery("#pt_selected_time_slot").val(pt_booked_time_slot);
852            jQuery("#pt_appointment_slot_starts_at").val(pt_slot_starts_at_for_db_GetDateTime);
853            jQuery("#pt_doctor_orders_per_slot").val(pt_orders_per_slot);
854
855
856    }
857
858
859    // Select Time slot
860    function SlotSelection() { 
861        
862        jQuery(".pt-select-slot-button.available").on("click", function(){
863            
864            var selectedSlot = jQuery(this).siblings().html();
865            jQuery('.time-slot').html(selectedSlot);
866            jQuery(".pt-change-time-slot-btn").slideDown("slow");
867            jQuery(".pt-timer").slideUp(800);
868            jQuery(".pt-appointment-form-container").slideDown("slow");
869            jQuery(".pt-selected-time-slot-wrapper").slideDown("slow");
870
871            jQuery("#pt_user_fullName").focus();
872
873            // Cookie Decoded by getCookie function written below
874            var pt_user_cookie_FullName = getCookie("pt_user_fullName");
875            var pt_user_cookie_Email = getCookie("pt_user_email");
876            var pt_user_cookie_telephone = getCookie("pt_user_telephone");
877
878            // Fill the form fields with cookies
879            jQuery("#pt_user_fullName").val(pt_user_cookie_FullName);
880            jQuery("#pt_user_email").val(pt_user_cookie_Email);
881            jQuery("#pt_user_telephone").val(pt_user_cookie_telephone);
882
883            // Hidden Form Fields
884            var pt_selected_doctor_id = jQuery("article.pt-doctor.selected #pt-doctor-id input").val();
885            var pt_selected_doctor = jQuery(".pt-selected-doctor #pt-doctor-name").text();
886            var pt_selected_doctor_title = jQuery(".pt-selected-doctor .pt-doctor-title").text();
887            var pt_selected_doctor_location = jQuery(".pt-selected-doctor #pt-doctor-location").text();
888            var pt_admin_email = jQuery("article.pt-doctor.selected .pt-doctor-provider-email input").val();
889            var pt_booked_date = jQuery(".pt-selected-date label").text();
890            var pt_booked_time_slot = jQuery(".pt-selected-time-slot label").text();
891            var pt_booked_doctor_price = jQuery(".pt-selected-doctor #pt-doctor-price").text();
892            var pt_selected_slot_id = jQuery(".pt-selected-time-slot label.time-slot input.pt-slotId").val();
893
894            var pt_slot_starts_at = jQuery(".pt-selected-time-slot label.time-slot input.pt-slot-starts-at").val();
895            var pt_slot_starts_at_for_db = selectedDateMonthYearTimestamp +' '+ pt_slot_starts_at;
896            var pt_slot_starts_at_for_db_GetDate = new Date(pt_slot_starts_at_for_db);
897            var pt_slot_starts_at_for_db_GetDateTime = pt_slot_starts_at_for_db_GetDate.getTime();
898
899            var pt_orders_per_slot = jQuery("article.pt-doctor.selected .pt-doctor-appointment-orders-per-slot input").val();
900
901            jQuery("#pt_selected_doctor_id").val(pt_selected_doctor_id);
902            jQuery("#pt_selected_doctor").val(pt_selected_doctor);
903            jQuery("#pt_selected_doctor_title").val(pt_selected_doctor_title);
904            jQuery("#pt_selected_doctor_location").val(pt_selected_doctor_location);
905            jQuery("#pt_selected_doctor_email").val(pt_admin_email);
906            jQuery("#pt_selected_doctor_date").val(pt_booked_date);
907            jQuery("#pt_selected_time_slot").val(pt_booked_time_slot);
908            jQuery("#pt_selected_doctor_price").val(pt_booked_doctor_price);
909            jQuery("#pt_selected_slot_id").val(pt_selected_slot_id);
910            jQuery("#pt_selected_doctor_date_id").val(pt_selected_doctor_date_id_for_db);
911            jQuery("#pt_appointment_slot_starts_at").val(pt_slot_starts_at_for_db_GetDateTime);
912            jQuery("#pt_doctor_orders_per_slot").val(pt_orders_per_slot);
913
914            changeTimeSlot();
915
916            
917
918        });
919
920
921    }
922
923
924    // Change Time slot
925    function changeTimeSlot(){
926
927        jQuery(".pt-change-time-slot-btn").on("click", function(){
928            jQuery(".pt-appointment-form-container").slideUp("slow");
929            jQuery(".pt-calendar-wrapper").slideUp(800);
930            jQuery(".pt-timer").slideDown(800);
931        });
932    }
933
934    // Browser Cookie ( On form submission set the browser cookies )
935    jQuery("#submitForm").on("click", function(){
936        checkCookie();
937    });
938
939    function setCookie(cname,cvalue,exdays) {    
940        var now = new Date();
941        var time = now.getTime();
942        var expireTime = time + 1000*3600*24*exdays;
943        now.setTime(expireTime);
944        var expires = "expires=" + now.toUTCString();
945        document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
946    }
947
948    function getCookie(cname) {
949        var name = cname + "=";
950        var decodedCookie = decodeURIComponent(document.cookie);
951        var ca = decodedCookie.split(';');
952        for(var i = 0; i < ca.length; i++) {
953        var c = ca[i];
954        while (c.charAt(0) == ' ') {
955            c = c.substring(1);
956        }
957        if (c.indexOf(name) == 0) {
958            return c.substring(name.length, c.length);
959        }
960        }
961        return "";
962    }
963        
964
965    function checkCookie() {
966        var pt_user_fullName= jQuery("#pt_user_fullName").val();
967        var pt_user_email = jQuery("#pt_user_email").val();
968        var pt_user_telephone = jQuery("#pt_user_telephone").val();
969        var ptCookieDuration = jQuery("#pt_cookie_duration").val();
970
971        if (pt_user_fullName!= "" && pt_user_fullName!= null) {
972            setCookie("pt_user_fullName", pt_user_fullName, ptCookieDuration);
973        }
974        if (pt_user_email != "" && pt_user_email != null) {
975            setCookie("pt_user_email", pt_user_email, ptCookieDuration);
976        }
977        if (pt_user_telephone != "" && pt_user_telephone != null) {
978            setCookie("pt_user_telephone", pt_user_telephone, ptCookieDuration);
979        }
980        
981    }
982    // Browser Cookie ( On form submission set the browser cookies ) Ends
983
984    (function() {
985        
986        // Disabling form submissions if there are invalid fields
987        window.addEventListener('load', function() {
988            // Fetch all the forms we want to apply custom Bootstrap validation styles to
989            var forms = document.getElementsByClassName('needs-validation');
990            // Loop over them and prevent submission
991            var validation = Array.prototype.filter.call(forms, function(form) {
992            form.addEventListener('submit', function(event) {
993                if (form.checkValidity() === false) {
994                event.preventDefault();
995                event.stopPropagation();
996                }
997                form.classList.add('was-validated');
998            }, false);
999            });
1000        }, false);
1001  
1002    })();
1003
1004    jQuery("#goBackButton").on("click", function(){
1005        history.back();
1006    });
1007
1008
1009    jQuery(function () {
1010		"use strict";
1011		var configChosen = {
1012		  '.chosen-select'           : {},
1013		  '.chosen-select-deselect'  : {allow_single_deselect:true},
1014		  '.chosen-select-no-single' : {disable_search_threshold:10},
1015		  '.chosen-select-no-results': {no_results_text:'Nothing Found'},
1016		  '.chosen-select-width'     : {width:"100%"}
1017		}
1018		for (var selector in configChosen) {
1019		  jQuery(selector).chosen(configChosen[selector]);
1020		}
1021    });
1022    
1023    
1024});
1025
1026// Ends document.ready function

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.