PageSourceSearch

https://www.lovelysmilesortho.com/wp-content/uploads/2025/07/builder_appointment_migrated.js

js lovelysmilesortho.com collected 2026-10-08 02:12:58 UTC 40,923 bytes, 1,186 lines download raw bytes

1// Combined js for appointment Versions 1 and 2
2// div id ='speciality-service' is compulsory for V2 and mustnot be used in V1
3var height;
4var loc_pref = 2;
5var selected_location_data = null;
6var clientEncrptKey = null;
7//Dynamic component - one which can switch appointment form based on time based/preference based working hour selection from console
8var dynamic_component = false;
9
10if (document.getElementById("pref-based")) {
11  dynamic_component = true;
12  console.log("dynamic", dynamic_component);
13}
14
15$(function () {
16  var locationId = "";
17  var countLengthOfDoctor = $("#appointment #profile .col-md-6").length;
18  var countLengthOfLocation = $("#appointment #home .col-md-6").length;
19
20  if ($("#locationdropdown").length > 0) {
21    $("#locationdropdown").on("change", function () {
22      var locationId = this.value;
23      filterDocForLocationVersion1(locationId);
24      $('#appointment-form input[name="location"]').val(locationId);
25      showLocationDays(locationId);
26    });
27  }
28  if ($("#teamdropdown").length > 0) {
29    $("#teamdropdown").on("change", function () {
30      var docname = $("#teamdropdown  option:selected").text();
31      $('#appointment-form input[name="Preferred"]').val("Dr " + docname);
32      var memberId = this.value;
33      $('#appointment-form input[name="member"]').val(memberId);
34    });
35  }
36
37  $("[data-get-location]").click(function (e) {
38    e.preventDefault();
39    locationId = $(this).attr("data-get-location");
40    $('#appointment-form input[name="location"]').val(locationId);
41    filterServiceForLocation(locationId);
42    showLocationDays(locationId);
43    const selectedLocation = location_data.filter(
44      (loc) => loc.id === parseInt(locationId, 10)
45    );
46    if (selectedLocation.length) {
47      getSelectedLocation(selectedLocation[0].address, selectedLocation[0].id);
48    }
49    var href = $(this).attr("href");
50    $("[aria-controls]").parent().removeClass("active");
51    $("#appointment .tabs .tab-pane").removeClass("active");
52  });
53
54  $("[data-get-service]").click(function (e) {
55    e.preventDefault();
56    var serviceId = $(this).attr("data-get-service");
57    $('#appointment-form input[name="speciality"]').val(serviceId);
58    var serviceName = $(this).attr("data-get-speciality");
59    filterDocForLocation(parseInt(locationId, 10), parseInt(serviceId, 10));
60    getServiceDetails(serviceName);
61    $("[aria-controls]").parent().removeClass("active");
62    $("#appointment .tabs .tab-pane").removeClass("active");
63  });
64  $("[data-id]").click(function (e) {
65    e.preventDefault();
66    team_memberId = $(this).attr("data-id");
67    $('#appointment-form input[name="member"]').val(team_memberId);
68    const selectedTeam = teams.filter(
69      (team) => team.id === parseInt(team_memberId, 10)
70    );
71    if (selectedTeam.length) {
72      getUserDetails(
73        selectedTeam[0].profile_pic_cropped,
74        selectedTeam[0].name,
75        selectedTeam[0].specialty,
76        selectedTeam[0].id
77      );
78    }
79  });
80
81  $("[data-select-team]").click(function (e) {
82    e.preventDefault();
83    team_memberId = $(this).attr("data-select-team");
84    $('#appointment-form input[name="member"]').val(team_memberId);
85  });
86
87  $(".recent-box").click(function () {
88    var memberId = $(this).data("id");
89    $("[aria-controls]").parent().removeClass("active");
90    // $("[aria-controls='messages']").parent().addClass("active");
91  });
92  $("[data-select-team]").click(function (e) {
93    e.preventDefault();
94    var teamId = $(this).attr("data-select-team");
95    getAvailablityOfLocandDoc(parseInt(teamId, 10));
96  });
97  //Setting Default location and doctor
98  var firstLocation = $("[data-get-location]").first();
99  if (firstLocation.length > 0) {
100    var locationId = firstLocation.data("get-location");
101    showLocationDays(locationId);
102    $('#appointment-form input[name="location"]').val(locationId);
103  }
104
105  $(".datepicker").datepicker({
106    format: "yyyy-mm-dd",
107    orientation: "bottom",
108    container: "#datetimepicker1",
109  });
110  $("#datetimepicker1").on("changeDate", function (ev) {
111    $(this).datepicker("hide");
112  });
113  $("#selected-doc-image-mob").attr(
114    "src",
115    $("input[name='member-image']").data("src")
116  );
117  $("#selected-doc-image").attr(
118    "src",
119    $("input[name='member-image']").data("src")
120  );
121  $("#selected-doc-name").text($("input[name='member-name']").data("name"));
122  $(".selected-doc-name").text($("input[name='member-name']").data("name"));
123  $(".selected-doc-spec").text(
124    $("input[name='member-speciality']").data("speciality")
125  );
126  var team_memberId = "";
127  if ($('#appointment-form input[name="member"]').val() == "") {
128    team_memberId = $('#appointment input[name="member-id"]').data("id");
129  } else {
130    team_memberId = $('#appointment-form input[name="member"]').val();
131  }
132  //CHANGES DONE BY SAMAD
133  // if(team_memberId){
134  //     getAvailablityOfLocandDoc(team_memberId,locationId,serviceId)
135  // }
136  ///////////////////////////
137  $("#appointment #speciality-service #profile .recent-box").on(
138    "click",
139    function () {
140      $(this).parents().find("#appointment .modal-content").addClass("height");
141    }
142  );
143
144  $(".location-box").on("click", function () {
145    $(this).parents().find("#appointment .modal-content").addClass("height");
146    height = $("#appointment").height();
147  });
148
149  $(".previous-location").on("click", function () {
150    $(this).parents().find(".select-service").removeClass("active");
151    $(this).parents().find(".select-doctor").removeClass("active");
152    $(this).parents().find(".fill-form").removeClass("active");
153    $(this).parents().find(".select-location").addClass("active");
154    $(this).parents().find("#appointment .modal-content").removeClass("height");
155  });
156  $(".previous-service").on("click", function () {
157    $(this).parents().find(".select-doctor").removeClass("active");
158    $(this).parents().find(".fill-form").removeClass("active");
159    $(this).parents().find(".select-service").addClass("active");
160    $(this).parents().find("#appointment .modal-content").removeClass("height");
161  });
162
163  $(".previous-doctor").on("click", function () {
164    $(this).parents().find(".fill-form").removeClass("active");
165    $(this).parents().find(".select-doctor").addClass("active");
166  });
167
168  // Theme 2 related
169  $("#patientTypeWithSwitch").on("change", function (e) {
170    patient_type = this.checked ? "New Patient" : "Existing Patient";
171    if (patient_type == "New Patient") {
172      patient_type = false;
173    } else {
174      patient_type = true;
175    }
176    $("#patient_type").val(patient_type);
177  });
178
179  $("#appointment-form")
180    .submit(function (e) {
181      e.preventDefault();
182    })
183    .validate({
184      rules: {
185        firstname: {
186          required: true,
187        },
188        lastname: {
189          required: true,
190        },
191        email: {
192          email: true,
193          required: true,
194        },
195        phone: {
196          required: true,
197          number: true,
198          maxlength: 10,
199          minlength: 10,
200        },
201        days: {
202          required: true,
203        },
204        times: {
205          required: true,
206        },
207        //CHANGES DONE BY SAMAD
208
209        date_slot: {
210          required: true,
211        },
212        dob: {
213          required: false,
214        },
215        reasonforvisit: {
216          required: false,
217        },
218        ///////////////////////
219      },
220      messages: {
221        firstname: { required: "Please enter your first name" },
222        lastname: { required: "Please enter your last name" },
223        email: {
224          required: "Please enter your email address",
225        },
226        phone: {
227          required: "Please enter your phone number",
228          maxlength: jQuery.validator.format("Please enter {0} digits."),
229          minlength: jQuery.validator.format("Please enter {0} digits."),
230        },
231        days: {
232          required: "Please select a day",
233          //                    maxlength: jQuery.validator.format("Please enter {0} digits."),
234          //                    minlength: jQuery.validator.format("Please enter {0} digits.")
235        },
236        times: {
237          required: "Please select a timing",
238          //                    maxlength: jQuery.validator.format("Please enter {0} digits."),
239          //                    minlength: jQuery.validator.format("Please enter {0} digits.")
240        },
241        //CHANGES DONE BY SAMAD
242        date_slot: {
243          required: "Please select a timing",
244        },
245        //                dob: {
246        //                    required: "Date of birth required"
247        //
248        //                },
249        // reasonforvisit: {
250        //     required: "Please select a reason for visit"
251
252        // }
253        //////////////////////
254      },
255      focusCleanup: true,
256      onfocusout: function (element) {
257        $(element).valid();
258      },
259      tooltip_options: {
260        firstname: { placement: "bottom" },
261        lastname: { placement: "bottom" },
262        email: { placement: "bottom" },
263        phone: { placement: "bottom" },
264        reasonforvisit: { placement: "bottom" },
265      },
266      //Submit Handler Function
267      submitHandler: function (form) {
268        console.log("here");
269        serialized_form_data = $("#appointment-form").serialize();
270        attributes = serialized_form_data.split("&");
271        attributes_dict = {};
272        accepted_keys = [
273          "g-recaptcha-response",
274          "location",
275          "recaptcha",
276          "member",
277          "locationdropdown",
278          "teamdropdown",
279          "days",
280          "times",
281          "email",
282          "firstname",
283          "lastname",
284          "phone",
285          "patientType",
286          "date_slot",
287          "dob",
288          "reasonforvisit",
289          "speciality",
290        ];
291        attributes.forEach(function (attr) {
292          var key = attr.split("=")[0];
293          var value = attr.split("=")[1];
294          key = key
295            .replace(/\+/g, " ")
296            .replace(/\%2F/g, "-")
297            .replace(/\%2C/g, ",")
298            .replace(/\%3A/g, ":");
299          if (value != "") {
300            if (!accepted_keys.includes(key)) {
301              attributes_dict[key] = value
302                .replace("%40", "@")
303                .replace(/\+/g, " ")
304                .replace(/\%2F/g, "-")
305                .replace(/\%2C/g, ",")
306                .replace(/\%3A/g, ":");
307            }
308          }
309        });
310        var team_memberId = "";
311        if ($('#appointment-form input[name="member"]').val() == "") {
312          team_memberId = $('#appointment input[name="member-id"]').data("id");
313          if (isNaN(team_memberId)) {
314            team_memberId = $('#appointment input[name="member-id"]').data(
315              "select-team"
316            );
317          }
318        } else {
319          team_memberId = $('#appointment-form input[name="member"]').val();
320        }
321
322        //CHANGED DONE BY SAMAD
323        day_time_or_date_timing = false;
324        if (
325          $('#appointment-form input[name="date_slot"]:checked').length > 0 ||
326          ($('#appointment-form input[name="days"]:checked').length > 0 &&
327            $('#appointment-form input[name="times"]:checked').length > 0)
328        ) {
329          day_time_or_date_timing = true;
330        }
331
332        var specialityId = $(
333          '#appointment-form input[name="speciality"]'
334        ).val();
335        var reasonforvisit = document.getElementById("reasonforvisit");
336        if (reasonforvisit) {
337          specialityId = reasonforvisit.value;
338        }
339        if (specialityId == "others" || specialityId == "Consultation") {
340          specialityId = null;
341        }
342        ////////////////
343        if (
344          $("#appointment-form input[name='firstname']").val() == "" ||
345          $("#appointment-form input[name='lastname']").val() == "" ||
346          $("#appointment-form input[name='email']").val() == "" ||
347          $('#appointment-form input[name="recaptcha"]').val() == "" ||
348          $("#appointment-form input[name='phone']").val().length < 10 ||
349          !day_time_or_date_timing ||
350          specialityId == "placeholder"
351        ) {
352          $("#errorAll").css("visibility", "visible");
353        } else {
354          var selectedDays = [];
355          if ($('#appointment-form input[name="days"]:checked').length > 0) {
356            $('#appointment-form input[name="days"]:checked').each(function (
357              e
358            ) {
359              console.log("selected day", $(this).val());
360              selectedDays.push($(this).val());
361            });
362          }
363
364          //            else{
365          //                selectedDays.push($('#appointment-form input[name="days"]').val());
366          //            }
367          var selectedTimes = [];
368          if ($('#appointment-form input[name="times"]:checked').length > 0) {
369            $('#appointment-form input[name="times"]:checked').each(function (
370              e
371            ) {
372              selectedTimes.push($(this).val());
373            });
374          }
375          //            else{
376          //                 $('#appointment-form input[name="times"]').each(function (e) {
377          //                    selectedTimes.push($(this).val());
378          //                  });
379          //            }
380          //CHANGES DONE BY SAMAD
381          times = selectedTimes.join(", ");
382          days = selectedDays.join(", ");
383          appointment_date = "";
384          timing_start = "";
385          timing_end = "";
386          if (
387            $('#appointment-form input[name="date_slot"]:checked').length > 0
388          ) {
389            appointment_date_timing = $(
390              '#appointment-form input[name="date_slot"]:checked'
391            )
392              .val()
393              .split(",");
394            appointment_date = appointment_date_timing[0];
395            appointment_date = appointment_date + "T00:00:00Z";
396            timing_start = appointment_date_timing[1];
397            timing_end = appointment_date_timing[2];
398          }
399          dob = $("#appointment-form input[name='dob']").val();
400          if (dob) {
401            let dateFormat = new Date(dob);
402            let formatedDOB = [
403              dateFormat.getFullYear(),
404              dateFormat.getMonth() + 1,
405              dateFormat.getDate(),
406            ].join("-");
407            dob = formatedDOB + "T00:00:00Z";
408          }
409          if (loc_pref == 1 || (!selectedDays && !selectedTimes)) {
410            days = appointment_date;
411            times = timing_start + "-" + timing_end;
412          }
413
414          /////////////////////
415          patient_type = $(
416            "#appointment-form input[name='patientType']:checked"
417          ).val();
418          patient_name = "";
419          if ($("#appointment-form input[name='firstname']").val()) {
420            patient_name = $("#appointment-form input[name='firstname']").val();
421          }
422          if ($("#appointment-form input[name='lastname']").val()) {
423            patient_name =
424              patient_name +
425              " " +
426              $("#appointment-form input[name='lastname']").val();
427          }
428          if (patient_type == undefined) {
429            patient_type = $("#patient_type").val();
430            if (patient_type == "New Patient" || patient_type === "false") {
431              patient_type = false;
432            } else {
433              patient_type = true;
434            }
435          } else if (typeof patient_type != "boolean") {
436            if (patient_type == "New Patient") {
437              patient_type = false;
438            } else {
439              patient_type = true;
440            }
441          }
442          var data = {
443            reason: "consultation",
444            insurance: "insurance",
445            location: parseInt(
446              $('#appointment-form input[name="location"]').val()
447            ),
448            days: days,
449            time: times,
450            patient_name: patient_name,
451            email: $("#appointment-form input[name='email']").val(),
452            mobile: $("#appointment-form input[name='phone']").val(),
453            existing_patient: patient_type,
454            g_recaptcha_response: $(
455              '#appointment-form input[name="recaptcha"]'
456            ).val(),
457            team_member: parseInt(team_memberId),
458            extra_data: JSON.stringify(attributes_dict),
459            //CHANGED DONE BY SAMAD
460            appointment_date: appointment_date,
461            from_time: timing_start,
462            to_time: timing_end,
463            dob: dob,
464            speciality: specialityId,
465            ////////////////////
466          };
467          var website_url =
468            window.location.protocol + "//" + location.host.split(":")[0];
469          try {
470            if (clientEncKey) clientEncrptKey = clientEncKey;
471          } catch (e) {
472            console.log("clientEnc not found");
473          }
474          try {
475            if (clientEncrptKey) {
476              data = {
477                ...data,
478                patient_name: encryptClientData(data.patient_name),
479                email: encryptClientData(data.email),
480                mobile: encryptClientData(data.mobile),
481              };
482            }
483            var $button = $("#submit");
484            $button.prop("disabled", true);
485            $.ajax({
486              dataType: "json",
487              type: "POST",
488              url: GP_WEBSITES_API_URL + "/api/website/appointments/",
489              headers: { "GP-Host": window.location.hostname },
490              data: data,
491              success: function (json) {
492                if (appointment_success_redirect.length > 1) {
493                  $.ajax({
494                    type: "get",
495                    url: appointment_success_redirect,
496                    statusCode: {
497                      404: function () {
498                        $("#success-appointment").modal("show");
499                      },
500                      200: function () {
501                        window.location =
502                          website_url + appointment_success_redirect;
503                      },
504                    },
505                  });
506                } else if ($("#success-popup").length > 0) {
507                  $("p.dynamic-text").text(appointment_popup_text);
508                  $("#success-popup").modal("show");
509                } else {
510                  $("#success-appointment").modal("show");
511                }
512                $("#appointment-form")[0].reset();
513
514                $("#appointment").modal("hide");
515                resetAppointmentCaptcha();
516              },
517              error: function (json) {
518                $("#error-appointment").modal("show");
519              },
520              complete: function () {
521                $button.prop("disabled", false);
522              },
523            });
524          } catch (e) {
525            console.log(e);
526          }
527        }
528      },
529    });
530
531  $("#success-popup").on("hidden.bs.modal", function () {
532    location.reload();
533  });
534  $("#success-appointment").on("hidden.bs.modal", function () {
535    location.reload();
536  });
537  // TEST CODE BLOCK
538  $("#appointment").on("hidden.bs.modal", function () {
539    var tabs = $(this).find(".modal-body").find(".tabs > div");
540    $(this).find("form").trigger("reset");
541    if (tabs.length > 1) {
542      tabs.removeClass("active");
543      $(tabs[0]).addClass("active");
544    }
545    $("#appointment-form .tooltip").remove();
546    resetAppointmentCaptcha();
547    $("#errorAll").css("visibility", "hidden");
548  });
549});
550
551function showLocationDays(locationId) {
552  var locationId = parseInt(locationId);
553  console.log("dyn", dynamic_component);
554  selected_location_data = location_data.filter(
555    (loc) => loc.id === locationId
556  )[0];
557  var total_timings = selected_location_data["working_hours"].length;
558  var i;
559  var highlightFirstDay = false;
560  for (i = 0; i < total_timings; i++) {
561    var location_timing = selected_location_data["working_hours"][i];
562    var dayText = location_timing["days"];
563    $("#checkbox-" + (i + 1)).prop("checked", false);
564    if (location_timing.off) {
565      $("#appointment-form div.inline[data-day='" + dayText + "']").hide();
566    } else {
567      if (!dynamic_component) {
568        $("#appointment-form div.inline[data-day='" + dayText + "']").show();
569      } else {
570        //For hiding days marked as 'working', but no sessions like morning/afternoon/eve are selected
571        var flex_times = selected_location_data.flexible_timings;
572        flex_times.forEach(function (day) {
573          if (day.key == dayText) {
574            off_day = true;
575            day.value.forEach(function (slot) {
576              console.log("off entered", slot.value);
577              if (slot.value) {
578                off_day = false;
579              }
580            });
581            if (off_day) {
582              $(
583                "#appointment-form div.inline[data-day='" + dayText + "']"
584              ).hide();
585            } else {
586              $(
587                "#appointment-form div.inline[data-day='" + dayText + "']"
588              ).show();
589            }
590          }
591        });
592      }
593      if (!highlightFirstDay && dynamic_component) {
594        console.log(i + 1);
595        $("#checkbox-" + (i + 1))
596          .prop("checked", true)
597          .trigger("change");
598        highlightFirstDay = true;
599      }
600    }
601  }
602}
603
604function getUserDetails(image, name, speciality, id) {
605  $("#selected-doc-image-mob").attr("src", image);
606  $("#selected-doc-image").attr("src", image);
607  $("#selected-doc-name").text(name);
608  $(".selected-doc-name").text(name);
609  $(".selected-doc-spec").text(speciality);
610}
611function getServiceDetails(speciality) {
612  $(".selected-service").text(speciality);
613  $("#selected-service").text(speciality);
614}
615
616function getSelectedLocation(name, location_id) {
617  $(".selected_location").text(name);
618  const locationIndex = location_data.findIndex(
619    (loc) => loc.id === location_id
620  );
621  var selected_location_data = location_data[locationIndex];
622  loc_pref = selected_location_data["preference"];
623  if (loc_pref == null) {
624    loc_pref = 2;
625  }
626}
627
628function getSelectedLocationPhone(location, phone) {
629  $(".selected_location").text(location);
630  $(".selected_phone").text(phone);
631}
632
633// Updates Done by Judith
634
635function showSlider() {
636  var setInvisible = function (elem) {
637    elem.css("visibility", "hidden");
638  };
639  var setVisible = function (elem) {
640    elem.css("visibility", "visible");
641  };
642
643  var elem = $(".availablity-items-div");
644  var items = elem.children();
645
646  // insert arrow buttons
647  elem.prepend(
648    '<div id="right-button" style="visibility: hidden;"><a href="#"><</a></div>'
649  );
650  elem.append('  <div id="left-button"><a href="#">></a></div>');
651  items.wrapAll('<div id="inner" />');
652  elem.find("#inner").wrap('<div id="builder-dynamic-outer"/>');
653
654  var outer = $("#builder-dynamic-outer");
655
656  var updateUI = function () {
657    var maxWidth = outer.outerWidth(true);
658    var actualWidth = 0;
659    $.each($("#inner >"), function (i, item) {
660      actualWidth += $(item).outerWidth(true);
661    });
662
663    if (actualWidth <= maxWidth) {
664      setVisible($("#left-button"));
665    }
666  };
667  updateUI();
668
669  $("#right-button").click(function () {
670    var leftPos = outer.scrollLeft();
671    outer.animate(
672      {
673        scrollLeft: leftPos - 200,
674      },
675      800,
676      function () {
677        //   debugger;
678        if ($("#outer").scrollLeft() <= 0) {
679          setInvisible($("#right-button"));
680        }
681      }
682    );
683  });
684
685  $("#left-button").click(function () {
686    setVisible($("#right-button"));
687    var leftPos = outer.scrollLeft();
688    outer.animate(
689      {
690        scrollLeft: leftPos + 200,
691      },
692      800
693    );
694  });
695
696  $(window).resize(function () {
697    updateUI();
698  });
699}
700// ******************************** For slots based on Clinic's Business Hours (Not considering doctor's timings)****************
701//For time slots based on business-hours of the clinic
702function getAvailablityOfLocandDoc(team_member_id, location_id, service_id) {
703  if (!location_id) {
704    location_id = $('#appointment-form input[name="location"]').val();
705  }
706  if (!service_id) {
707    service_id = $('#appointment-form input[name="speciality"]').val();
708  }
709  //Dynamic component - Appointment slots are days and sessions if preference based timing is selected in console,else timeslots
710  // var dynamic_component = false;
711  // if (document.getElementById('pref-based')) {
712  //     dynamic_component = true;
713  // }
714
715  if (
716    dynamic_component == false ||
717    (dynamic_component == true && loc_pref == 1)
718  ) {
719    $("#pref-based").hide();
720
721    $("#time-based").show();
722
723    $(".loader").attr("style", "visibility: visible");
724
725    $(".availablity-items-div").empty();
726    var data = {
727      location_id: location_id,
728      team_member: team_member_id,
729      service_id: service_id,
730    };
731    $.ajax({
732      dataType: "json",
733      type: "GET",
734      url:
735        GP_WEBSITES_API_URL +
736        "/api/appointment/appointments/v2/get-appointment-availability/",
737      headers: { "GP-Host": window.location.hostname },
738      data: data,
739      success: function (data) {
740        if (data[0].length > 1) {
741          showslots(data);
742        } else {
743          failure_msg();
744        }
745      },
746      error: function () {
747        failure_msg();
748      },
749    });
750  } else {
751    $(".loader").attr("style", "visibility: hidden");
752    $("#time-based").hide();
753    $("#pref-based").show();
754  }
755}
756
757//****************************** For slots based on Selected Doctor's Timings*****************************/
758// For time slots based on doctor timings
759function getDoctorSlots(team_member_id, location_id, service_id) {
760  if (!location_id) {
761    location_id = $('#appointment-form input[name="location"]').val();
762  }
763  if (!service_id) {
764    service_id = $('#appointment-form input[name="speciality"]').val();
765  }
766  if (
767    dynamic_component == false ||
768    (dynamic_component == true && loc_pref == 1)
769  ) {
770    $("#pref-based").hide();
771
772    $("#time-based").show();
773    $(".loader").attr("style", "visibility: visible");
774
775    $(".availablity-items-div").empty();
776    var data = {
777      location_id: location_id,
778      team_member: team_member_id,
779      service_id: service_id,
780    };
781    $.ajax({
782      dataType: "json",
783      type: "GET",
784      url:
785        GP_WEBSITES_API_URL +
786        "/api/appointment/appointments/v2/get-doctor-availability/",
787      headers: { "GP-Host": window.location.hostname },
788      data: data,
789      success: function (data) {
790        if (data[0].length > 1) {
791          showslots(data);
792        } else {
793          failure_msg();
794        }
795      },
796      error: function () {
797        failure_msg();
798      },
799    });
800  } else {
801    $(".loader").attr("style", "visibility: hidden");
802    $("#time-based").hide();
803    $("#pref-based").show();
804  }
805}
806
807//To display timeslots on success response from api call getAvailablityOfLocandDoc and getDoctorSlots
808function showslots(data) {
809  var item_div = "";
810  $(".availablity-items-div").append(item_div);
811  data.forEach(function (item, index) {
812    var more_length = 0;
813    var html = "";
814    item.forEach(function (day, index) {
815      var time_slot = "";
816      var time_slots = "";
817      var more = "";
818      var class_name = parseInt(day.date_and_month.split(" ").join(""));
819      if (day.week_of === false) {
820        if (day.time_slots.length >= 4) {
821          more =
822            '<p class="builder-dynamic-slots-more"><a type="button" onclick="hide_and_show_slots(' +
823            class_name +
824            ')">MORE..</a></p>';
825        }
826        day.time_slots.forEach(function (time, index) {
827          var Id = parseInt(time.start);
828          var inputId =
829            time.start.split(" ")[0].split(":").join("") + Id + class_name;
830          var day_date_and_month = parseInt(day.date_and_month);
831          if (index <= 4) {
832            time_slot +=
833              '<li class="' +
834              class_name +
835              "-show " +
836              class_name +
837              '-slot-item" id=' +
838              index +
839              "><input onclick=timingCheckboxClick(" +
840              inputId +
841              "," +
842              day_date_and_month +
843              '); id="' +
844              inputId +
845              '" class=builder-dynamic-check name=date_slot type=checkbox value="' +
846              day.date +
847              "," +
848              time.start +
849              "," +
850              time.end +
851              '"><label for=' +
852              day.date_and_month +
853              "-" +
854              time.start +
855              " class=builder-dynamic-v2><span>" +
856              time.start +
857              "</span></label></li>";
858          } else {
859            time_slot +=
860              '<li class="' +
861              class_name +
862              "-hide " +
863              class_name +
864              '-slot-item" id=' +
865              index +
866              ' style="display:none"><input onclick=timingCheckboxClick(' +
867              inputId +
868              "," +
869              day_date_and_month +
870              '); id="' +
871              inputId +
872              '" class=builder-dynamic-check name=date_slot type=checkbox value="' +
873              day.date +
874              "," +
875              time.start +
876              "," +
877              time.end +
878              '"><label for=' +
879              day.date_and_month +
880              "-" +
881              time.start +
882              " class=builder-dynamic-v2><span>" +
883              time.start +
884              "</span></label></li>";
885          }
886        });
887        time_slots =
888          '<ul class="builder-dynamic-time-list"> ' + time_slot + "</ul>";
889      } else {
890        more = "";
891      }
892      html +=
893        "<div class=builder-dynamic-app-v2 days-group data-day=" +
894        day.day +
895        '><div class="builder-dynamic-checkbox-custom-circle" id=' +
896        day.date_and_month +
897        "><span>" +
898        day.day +
899        "</span></div><h6>" +
900        day.date_and_month +
901        "</h6>" +
902        time_slots +
903        more +
904        "</div>";
905    });
906    $(".loader").attr("style", "visibility: hidden");
907    $(".availablity-items-div").append(html);
908  });
909  showSlider();
910}
911
912function failure_msg() {
913  $("#appointment").modal("toggle");
914  $("#pageMessage").modal("toggle");
915}
916
917//********************************End of slots logic ************************/
918
919//Function to get doctor id/service from class attrs
920// ids are of format (loc+service-loc+service*doc) or (loc-loc-loc*serviceid)
921//Splits doc-id or service id from this id string
922function getDoctorOrServiceIdandLocations(ids) {
923  var ser_or_doc;
924  doc_n_locations = ids.split("*");
925  ser_or_doc = doc_n_locations[doc_n_locations.length - 1];
926  locations = ids.substring(0, ids.indexOf(ser_or_doc) - 1);
927  return [locations, ser_or_doc];
928}
929
930//To filter doctors for a loc and service pair
931function filterDocForLocation(location_id, service_id) {
932  var single_doc;
933  var elements = $("[data-doc-location]");
934  var doc_count = 0;
935  //For showing onlly services mapped specifically to a location
936  elements.each(function (index) {
937    var ids = $(this).data("doc-location").replace(/\s+/g, "").trim();
938    if (ids.length > 0) ids = ids.replaceAll(",", "");
939    [locations, doc] = getDoctorOrServiceIdandLocations(ids);
940    ids = locations.split("-");
941    ids = ids.filter(function (v) {
942      return v !== "+";
943    });
944    if (ids.length >= 0 && ids.indexOf(location_id + "+" + service_id) < 0) {
945      $(this).hide();
946    } else {
947      $(this).show();
948      doc_count = doc_count + 1;
949      single_doc = doc;
950    }
951  });
952
953  //Logic to hide 'doctor tab' for single doc
954  if (doc_count <= 1) {
955    if (doc_count <= 0) {
956      $('a[data-get-service^="' + service_id + '"]').each(function () {
957        var oldUrl = $(this).attr("href");
958        var newUrl = oldUrl.replace("#profile", "#home");
959        $(this).attr("href", newUrl);
960      });
961      $('a[data-get-location^="' + location_id + '"]').each(function () {
962        var oldUrl = $(this).attr("href"); // Get current url
963        var newUrl = oldUrl.replace("#profile", "#home"); // Create new url
964        $(this).attr("href", newUrl); // Set href value
965      });
966      $("#appointment").modal("toggle");
967      $("#pageMessage").modal("toggle");
968      return;
969    } else {
970      $('a[data-get-location^="' + location_id + '"]').each(function () {
971        var oldUrl = $(this).attr("href"); // Get current url
972        var newUrl = oldUrl.replace("#profile", "#messages"); // Create new url
973        $(this).attr("href", newUrl); // Set href value
974      });
975      $('a[data-get-service^="' + service_id + '"]').each(function () {
976        var oldUrl = $(this).attr("href");
977        var newUrl = oldUrl.replace("#profile", "#messages");
978        $(this).attr("href", newUrl);
979      });
980      $("#profile").removeClass("active");
981      $("#messages").addClass("active");
982      $('a[data-id^="' + single_doc + '"]').each(function () {
983        $(this).trigger("click");
984      });
985      $('#appointment-form input[name="member"]').val(single_doc);
986      if ($("#doc-slot").length) {
987        getDoctorSlots(single_doc, location_id, service_id);
988      } else {
989        getAvailablityOfLocandDoc(single_doc, location_id, service_id);
990      }
991    }
992  }
993}
994
995//For Appointment Verison1 - no services
996function filterDocForLocationVersion1(location_id) {
997  var elements = $("[data-doc-location]");
998  elements.each(function (index) {
999    var ids = $(this).data("doc-location").replace(/\s+/g, "").trim();
1000    ids = ids.split("-");
1001    ids = ids.filter(function (v) {
1002      return v !== "";
1003    });
1004    if (ids.length > 0 && ids.indexOf(location_id) < 0) {
1005      $(this).hide();
1006    } else {
1007      $(this).show();
1008    }
1009  });
1010}
1011
1012//For Appointment Version2 -with services and date time
1013//To filter services mapped to a selected Location
1014function filterServiceForLocation(location_id) {
1015  //*******div id 'speciality-service' is required for New version Components only.This distinguishes old and new versions of appointment
1016  if ($("#speciality-service").length < 1) {
1017    $('#appointment-form input[name="speciality"]').val(null);
1018    filterDocForLocationVersion1(location_id);
1019  } else {
1020    $("a[data-get-service]").each(function () {
1021      var oldUrl = $(this).attr("href");
1022      var newUrl = oldUrl
1023        .replace("#home", "#profile")
1024        .replace("#messages", "#profile");
1025      $(this).attr("href", newUrl);
1026    });
1027    var service_count = 0;
1028    var single_service;
1029    var elements = $("[data-service-location]");
1030    elements.each(function (index) {
1031      var ids = $(this).data("service-location").replace(/\s+/g, "").trim();
1032      [locations, service] = getDoctorOrServiceIdandLocations(ids);
1033      ids = Array.from(new Set(locations.split("-")));
1034      ids = ids.filter(function (v) {
1035        return v !== "";
1036      });
1037      if (ids.length >= 0 && ids.indexOf(location_id) < 0) {
1038        $(this).hide();
1039      } else {
1040        $(this).show();
1041        service_count = service_count + 1;
1042        single_service = service;
1043      }
1044    });
1045
1046    //Logic to hide 'service tab' for single service only
1047
1048    if (service_count <= 1) {
1049      if (service_count <= 0) {
1050        $('a[data-get-location^="' + location_id + '"]').each(function () {
1051          var oldUrl = $(this).attr("href"); // Get current url
1052          var newUrl = oldUrl.replace("#speciality-service", "#home"); // Create new url
1053          $(this).attr("href", newUrl); // Set href value
1054        });
1055        $("#appointment").modal("toggle");
1056        $("#pageMessage").modal("toggle");
1057        return;
1058      } else {
1059        $('a[data-get-location^="' + location_id + '"]').each(function () {
1060          var oldUrl = $(this).attr("href"); // Get current url
1061          var newUrl = oldUrl.replace("#speciality-service", "#profile"); // Create new url
1062          $(this).attr("href", newUrl); // Set href value
1063        });
1064        $('a[data-get-service^="' + single_service + '"]').each(function () {
1065          var oldUrl = $(this).attr("href");
1066          var newUrl = oldUrl.replace("#speciality-service", "#profile");
1067          $(this).attr("href", newUrl);
1068        });
1069
1070        $("#speciality-service").removeClass("active");
1071        $("#profile").addClass("active");
1072        $('a[data-get-service^="' + single_service + '"]').each(function () {
1073          $(this).trigger("click");
1074        });
1075        $('#appointment-form input[name="speciality"]').val(single_service);
1076      }
1077    } else {
1078      $("#speciality-service").addClass("active");
1079    }
1080  }
1081}
1082
1083//CHANGES DONE BY SAMAD
1084function hide_and_show_slots(class_name) {
1085  var showElements = $("." + class_name + "-show");
1086  var allSlotItems = $("." + class_name + "-slot-item");
1087  var hideElements = $("." + class_name + "-hide");
1088  showElements.each(function (index) {
1089    showElements[index].style.display = "none";
1090    showElements[index].classList.add(class_name + "-hide");
1091    showElements[index].classList.remove(class_name + "-show");
1092  });
1093  lengthOfShowsLi = parseInt(showElements.length - 1);
1094  lengthOfallSlotItems = parseInt(allSlotItems.length - 1);
1095  lastItemIdofallSlotItems = parseInt(allSlotItems[lengthOfallSlotItems].id);
1096  lastShowLiId = parseInt(showElements[lengthOfShowsLi].id);
1097  if (lastShowLiId == lastItemIdofallSlotItems) {
1098    lastShowLiId = -1;
1099  }
1100  for (i = lastShowLiId + 1; i <= lastShowLiId + 5; i++) {
1101    allSlotItems.each(function (index) {
1102      if (i == allSlotItems[index].id) {
1103        allSlotItems[index].style.display = "block";
1104        allSlotItems[index].classList.add(class_name + "-show");
1105        allSlotItems[index].classList.remove(class_name + "-hide");
1106      } else if (allSlotItems[index].style.display != "block") {
1107        allSlotItems[index].style.display = "none";
1108        allSlotItems[index].classList.add(class_name + "-hide");
1109        allSlotItems[index].classList.remove(class_name + "-show");
1110      }
1111    });
1112  }
1113}
1114//CHANGES DONE BY SAMAD
1115function timingCheckboxClick(checkboxId, dayId) {
1116  var allDays = $(".builder-dynamic-checkbox-custom-circle");
1117  var allTimingBoxes = $(".builder-dynamic-check");
1118  allTimingBoxes.each(function (index) {
1119    if (allTimingBoxes[index].id == checkboxId) {
1120      allTimingBoxes[index].checked = true;
1121    } else {
1122      allTimingBoxes[index].checked = false;
1123    }
1124  });
1125  allDays.each(function (index) {
1126    if (allDays[index].id == dayId) {
1127      $(this).css("background-color", "#DB4A34");
1128      $(this).find("span").css("color", "#FFFFEE");
1129    } else {
1130      $(this).css("background-color", "");
1131      $(this).find("span").css("color", "#DB4A34");
1132    }
1133  });
1134}
1135$('input[name="days"]').change(function () {
1136  if (dynamic_component) {
1137    var weekday = new Array(7);
1138    weekday[0] = "Monday";
1139    weekday[1] = "Tuesday";
1140    weekday[2] = "Wednesday";
1141    weekday[3] = "Thursday";
1142    weekday[4] = "Friday";
1143    weekday[5] = "Saturday";
1144    weekday[6] = "Sunday";
1145
1146    var selectedDay = $(this).val();
1147    selected_location_data.flexible_timings.forEach(function (day) {
1148      if (day.key == selectedDay) {
1149        day.value.forEach(function (slot) {
1150          if (slot.value)
1151            $(
1152              "#appointment-form div.inline[data-time='" + slot.key + "']"
1153            ).show();
1154          else
1155            $(
1156              "#appointment-form div.inline[data-time='" + slot.key + "']"
1157            ).hide();
1158        });
1159      } else {
1160        var index = weekday.indexOf(day.key) + 1;
1161        $("#checkbox-" + index).prop("checked", false);
1162      }
1163    });
1164  }
1165});
1166
1167// To filter mapped services based on location for single location
1168var loc = $("#loc");
1169
1170function updateChange() {
1171  if ($(loc).val()) {
1172    filterServiceForLocation($(loc).val());
1173  }
1174}
1175
1176loc.on("change", updateChange);
1177//To call updateChange only when appointment modal is open
1178$("#appointment").on("shown.bs.modal", function (e) {
1179  updateChange();
1180});
1181
1182setTimeout(() => {
1183  encryptClientData = function (msg) {
1184    return msg;
1185  };
1186}, 4000);

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.