Open
Open
openButton.addEventListener('click', function () {
var therightslot = ""; // Define therightslot variable
var idPatterns = ["AppointmentDate1", "AppointmentDate2", "AppointmentDate3",
"AppointmentDate4", "AppointmentDate5"];
var selectedDivs = [];
idPatterns.forEach(function (idPattern) {
var divsWithInput = document.querySelectorAll("div:has(input#" + idPattern +
")");
selectedDivs = selectedDivs.concat(Array.from(divsWithInput));
});
var visibleDivs = selectedDivs.filter(function (div) {
return getComputedStyle(div).display !== "none";
});
visibleDivs.sort(function (a, b) {
var indexA = Array.from(a.parentNode.children).indexOf(a);
var indexB = Array.from(b.parentNode.children).indexOf(b);
return indexB - indexA;
});
var highestIndexDiv = visibleDivs[0];
var foundInput = highestIndexDiv.querySelector('input');
var appdateid = foundInput.id;
$('#' + appdateid).data("kendoDatePicker").open();
var dates = document.querySelectorAll('a.k-link');
dates.forEach((date) => {
if (date.title == "Monday, october 23, 2023") date.click();
});
// Simulate a delay of one second before running the slot button functionality
setTimeout(function () {
var slotids = ['AppointmentSlot1', 'AppointmentSlot2', 'AppointmentSlot3',
'AppointmentSlot4', 'AppointmentSlot5'];
slotids.forEach(function (slotid) {
var slotelement = $(".k-widget.k-dropdown.form-control[aria-owns='" + slotid
+ "_listbox']");
if (slotelement.is(":visible")) {
therightslot = "AppointmentSlot" + slotid.slice(15);
}
});
var slotval = document.getElementById(therightslot);
slotval.style.display = 'block';
slotval.value = '08:30-09:30';
}, 1000); // Delay of one second
});
containerDiv.appendChild(openButton);