Hi! For some reason, my qualtrics survey does not seem to run smoothly on Microsoft Edge. The error message “something went wrong - we were unable to connect to our servers. Please check your internet connection and try again” appears repeatedly even with stable network.
There is a custom code embedded to hide the time option for calendar >
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
// Function to click a specific time in the time picker when a day is selected
function clickSpecificTime(timeText = '12:00 AM') {
const timeItems = document.querySelectorAll('.react-datepicker__time-list-item');
for (const item of timeItems) {
if (item.textContent.trim() === timeText) {
item.click(); // Select the desired time
break;
}
}
}
// Attach click listeners to each day in the calendar
function attachDayClickListeners() {
const dayElements = document.querySelectorAll('.react-datepicker__day');
dayElements.forEach(day => {
if (!day.dataset.listenerAttached) {
// Add a click listener to select the time after a day is clicked
day.addEventListener('click', () => {
setTimeout(() => {
clickSpecificTime('12:00 AM');
}, 50); // Delay to ensure the day actually gets selected
});
// Mark this day element so listener does not reattach
day.dataset.listenerAttached = 'true';
}
});
}
// Override the input's value setter to prevent "12:00 AM" from being set
function overrideInputValueSetter() {
const inputs = document.querySelectorAll('input.text-input');
inputs.forEach(input => {
// Get the original value property descriptor
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value');
// Only override if it's configurable and hasn't been overridden already
if (descriptor && descriptor.configurable && !input.dataset.overrideApplied) {
Object.defineProperty(input, 'value', {
get() {
return descriptor.get.call(this); // Use the original getter
},
set(newValue) {
// Strip out "12:00 AM" before setting the value
const cleanValue = newValue.replace(/\s*12:00\s?[AP]M/i, '');
descriptor.set.call(this, cleanValue);
},
configurable: true,
enumerable: true
});
// Mark this input so does not override again
input.dataset.overrideApplied = 'true';
// Remove timestamp on page load
const currentValue = input.value;
const cleanedValue = currentValue.replace(/\s*12:00\s?[AP]M/i, '');
input.value = cleanedValue;
}
});
}
// Observe the DOM for changes to re-attach listeners and override setters as needed
let globalObserver = new MutationObserver(() => {
attachDayClickListeners(); // Re-attach day click listeners
overrideInputValueSetter(); // Re-apply input value overrides
});
globalObserver.observe(document.body, {
childList: true,
subtree: true
});
// Initial setup on page load
attachDayClickListeners();
overrideInputValueSetter();
// Remove the observers on page submit
Qualtrics.SurveyEngine.addOnPageSubmit(function (type) {
if (globalObserver) {
globalObserver.disconnect();
globalObserver = null;
}
});
});
Does anyone have a tip regarding what might be happening? Thank you!
