Skip to content

Commit 49d6f04

Browse files
committed
fix(frontend): pass xhr to the ajax callback functions, so they can read the headers as well (for example)
1 parent dc109e1 commit 49d6f04

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

modules/core/site.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ var Hm_Ajax = {
120120
Hm_Ajax.icon_loading_id = false;
121121
},
122122

123-
process_callback_hooks: function(name, res) {
123+
process_callback_hooks: function(name, res, xhr) {
124124
var hook;
125125
var func;
126126
for (var i in Hm_Ajax.callback_hooks) {
127127
hook = Hm_Ajax.callback_hooks[i];
128128
if (hook[0] == name || hook[0] == '*') {
129129
func = hook[1];
130-
func(res);
130+
func(res, xhr);
131131
if (hook[0] == '*') {
132132
if ($.inArray(hook, Hm_Ajax.p_callbacks) === -1) {
133133
Hm_Ajax.p_callbacks.push(hook);
@@ -172,7 +172,7 @@ var Hm_Ajax_Request = function() { return {
172172
url.searchParams.set(configItem.name, configItem.value);
173173
}
174174
}
175-
175+
176176
xhr.open('POST', url.toString())
177177
if (config.signal) {
178178
config.signal.addEventListener('abort', function() {
@@ -266,7 +266,7 @@ var Hm_Ajax_Request = function() { return {
266266
if (this.callback) {
267267
this.callback(res);
268268
}
269-
Hm_Ajax.process_callback_hooks(this.name, res);
269+
Hm_Ajax.process_callback_hooks(this.name, res, xhr);
270270
}
271271
},
272272

@@ -368,7 +368,7 @@ Hm_Modal.prototype = {
368368
`;
369369

370370
$('body').append(modal);
371-
371+
372372
this.modal = $(`#${this.opts.modalId}`);
373373
this.modalContent = this.modal.find('.modal-body');
374374
this.modalTitle = this.modal.find('.modal-title');
@@ -383,7 +383,7 @@ Hm_Modal.prototype = {
383383
this.customButtons.forEach(btn => {
384384
btn.element.off('click', btn.handler);
385385
});
386-
386+
387387
if (this.bsModal) {
388388
this.bsModal.dispose();
389389
}
@@ -394,7 +394,7 @@ Hm_Modal.prototype = {
394394

395395
recreateButtons: function() {
396396
this.modalFooter.children().not('.btn-secondary').remove();
397-
397+
398398
this.customButtons.forEach(btn => {
399399
this.createButton(btn.label, btn.classes, btn.handler);
400400
});
@@ -483,7 +483,7 @@ class Hm_Alert {
483483
closeButton.setAttribute('aria-label', 'Close');
484484
alert.appendChild(closeButton);
485485
}
486-
486+
487487
this.container.appendChild(alert);
488488

489489
if (dismissible) {
@@ -972,7 +972,7 @@ function Message_List() {
972972
this.prev_next_links = function(msgUid, listPath = getListPathParam(), cb = null) {
973973
let prevUrl;
974974
let nextUrl;
975-
975+
976976
const target = $('.msg_text .small_header').last();
977977
let filter = `${getParam('keyword')}_${getParam('filter')}`;
978978
if (getParam('search_terms')) {
@@ -1340,11 +1340,11 @@ var Hm_Folders = {
13401340
let transformValue = '';
13411341
if ($(this).attr('aria-expanded') == 'true') {
13421342
transformValue = 'rotate(180deg)';
1343-
1343+
13441344
} else {
13451345
transformValue = 'rotate(0deg)';
13461346
}
1347-
1347+
13481348
$(this).find('i').css('transform', transformValue);
13491349
});
13501350
$('.update_message_list').on("click", function(e) {
@@ -1369,7 +1369,7 @@ var Hm_Folders = {
13691369
hl_selected_menu: function() {
13701370
const page = getPageNameParam();
13711371
const path = getListPathParam();
1372-
1372+
13731373
$('.folder_list').find('*').removeClass('selected_menu');
13741374
if (path) {
13751375
if (page == 'message_list' || page == 'message') {
@@ -1554,7 +1554,7 @@ var Hm_Utils = {
15541554
if (force_on) {
15551555
$(class_name).css('display', 'none');
15561556
}
1557-
$(`[data-bs-target="${class_name}"]`).trigger('click');
1557+
$(`[data-bs-target="${class_name}"]`).trigger('click');
15581558
Hm_Utils.save_to_local_storage('formatted_folder_list', $('.folder_list').html());
15591559
}
15601560
return false;
@@ -2177,7 +2177,7 @@ function handleSmtpImapCheckboxChange(checkbox) {
21772177
if ($('#srv_setup_stepper_is_sender').prop('checked') && $('#srv_setup_stepper_is_receiver').prop('checked')) {
21782178
$('#srv_setup_stepper_profile_bloc').show();
21792179
$('#srv_setup_stepper_profile_checkbox_bloc').show();
2180-
2180+
21812181
} else if(! $('#srv_setup_stepper_is_sender').prop('checked') || ! $('#srv_setup_stepper_is_receiver').prop('checked')) {
21822182
$('#srv_setup_stepper_profile_bloc').hide();
21832183
$('#srv_setup_stepper_profile_checkbox_bloc').hide();
@@ -2229,7 +2229,7 @@ function display_config_step(stepNumber) {
22292229
$(`#${item.key}-error`).text('Required');
22302230
isValid = false;
22312231
}
2232-
2232+
22332233
} else {
22342234
$(`#${item.key}-error`).text('');
22352235
}
@@ -2513,14 +2513,14 @@ const handleExternalResources = (inline) => {
25132513
};
25142514

25152515
const observeMessageTextMutationAndHandleExternalResources = (inline) => {
2516-
const message = document.querySelector('.msg_text');
2516+
const message = document.querySelector('.msg_text');
25172517
if (message) {
25182518
new MutationObserver(function (mutations) {
25192519
mutations.forEach(function (mutation) {
25202520
if (mutation.addedNodes.length > 0) {
25212521
mutation.addedNodes.forEach(function (node) {
25222522
if (node.classList.contains('msg_text_inner')) {
2523-
handleExternalResources(inline);
2523+
handleExternalResources(inline);
25242524
}
25252525
});
25262526
}

0 commit comments

Comments
 (0)