easyappointments/assets/js/app.js

57 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-11-29 11:01:02 +03:00
/* ----------------------------------------------------------------------------
2022-01-18 15:05:42 +03:00
* Easy!Appointments - Online Appointment Scheduler
2021-11-29 11:01:02 +03:00
*
* @author A.Tselegidis <alextselegidis@gmail.com>
2021-12-18 19:43:45 +03:00
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
2021-11-29 11:01:02 +03:00
* @since v1.5.0
* ---------------------------------------------------------------------------- */
/**
* App global namespace object.
*
* This script should be loaded before the other modules in order to define the global application namespace.
*/
2021-11-29 11:01:02 +03:00
window.App = (function () {
function onAjaxError(event, jqXHR, textStatus, errorThrown) {
console.error('Unexpected HTTP Error: ', jqXHR, textStatus, errorThrown);
let response;
try {
response = JSON.parse(jqXHR.responseText); // JSON response
} catch (error) {
response = {message: jqXHR.responseText}; // String response
}
if (!response) {
return;
}
if (App.Utils.Message) {
App.Utils.Message.show(lang('unexpected_issues'), lang('unexpected_issues_message'));
$('<div/>', {
'class': 'card',
'html': [
$('<div/>', {
'class': 'card-body',
'html': response.message || '→ No error information provided.'
})
]
}).appendTo('#message-box');
}
}
$(document).ajaxError(onAjaxError);
2021-11-29 11:01:02 +03:00
return {
Components: {},
Http: {},
Layouts: {},
Pages: {},
Utils: {}
2021-11-29 11:01:02 +03:00
};
})();