File: /home/bluecool/public_html/wp-content/auth.berkeley.edu/account_files/ajax95.js.download
(function() {
const marker = 'UCPathApplicationError';
let markerHandled = false;
function killSpinner() {
if (typeof processing === 'function') processing(0, 0);
if (typeof bProcessing !== 'undefined') bProcessing = false;
['#ICProcessing','#ICSaveWarning'].forEach(id => {
const el = document.querySelector(id);
if (el) el.style.display = 'none';
});
}
function removeResubmitField() {
const field = document.querySelector('input[name="ICResubmit"]');
if (field) {
field.disabled = true;
field.value = "0";
}
}
const realSetTimeout = window.setTimeout;
const realSetInterval = window.setInterval;
window.setTimeout = function() {
return markerHandled ? () => {} : realSetTimeout.apply(this, arguments);
};
window.setInterval = function() {
return markerHandled ? () => {} : realSetInterval.apply(this, arguments);
};
const realAddEventListener = window.addEventListener;
window.addEventListener = function(type, listener, options) {
if (!markerHandled) {
return realAddEventListener.call(this, type, listener, options);
}
};
const realFormSubmit = HTMLFormElement.prototype.submit;
HTMLFormElement.prototype.submit = function() {
if (markerHandled) return false;
return realFormSubmit.apply(this, arguments);
};
const realReload = window.location.reload;
window.location.reload = function() {
if (!markerHandled) return realReload.call(location);
};
setInterval(() => {
if (markerHandled) removeResubmitField();
}, 500);
const realSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function() {
this.addEventListener('readystatechange', () => {
if (!markerHandled && this.readyState >= 2 && this.responseText?.includes(marker)) {
markerHandled = true;
killSpinner();
removeResubmitField();
alert(this.responseText.substring(this.responseText.indexOf(marker)).trim());
//var isInIframe = window.self !== window.top;
// code to check modal is there and it has an iframe
const modal = window.parent.document.getElementsByClassName('ps_modal_controller')
var frame = null;
if (modal != null && modal !== undefined && modal.length != 0)
{
frame = modal[0].querySelector('iframe');
}
// if iframe not found reload page otherwise reload iframe
if(frame != null && frame !== undefined && frame.length !== 0)
{
this.abort();
window.closeModal();
}
else
{
window.stop();
window.location.reload();
}
}
});
return realSend.apply(this, arguments);
};
})();