Skip to content

Commit 8b2ade5

Browse files
committed
Refact JS calls for creating notices
1 parent a2e7d16 commit 8b2ade5

File tree

16 files changed

+149
-211
lines changed

16 files changed

+149
-211
lines changed

modules/2fa/site.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
$(function () {
2-
function tFaToast(message, timer = 3000) {
3-
Hm_Notices.show([message]);
4-
const tm = setTimeout(function () {
5-
Hm_Notices.hide(true);
6-
clearTimeout(tm);
7-
}, timer);
8-
}
9-
102
function focusElement(elem) {
113
elem.focus();
124
elem.select();
@@ -79,7 +71,7 @@ $(function () {
7971

8072
if (checked && !verified) {
8173
$(this).prop("checked", false);
82-
tFaToast(err_msg('You need to verify your 2 factor authentication code before processing'));
74+
Hm_Notices.show('You need to verify your 2 factor authentication code before processing', 'warning');
8375
return;
8476
}
8577
});
@@ -138,11 +130,7 @@ $(function () {
138130
var code = getInputCode();
139131

140132
if (!code) {
141-
tFaToast(err_msg("You need to enter the verification code"));
142-
var tm = setTimeout(function () {
143-
Hm_Notices.hide(true);
144-
clearTimeout(tm);
145-
}, 2000);
133+
Hm_Notices.show("You need to enter the verification code", 'warning');
146134
return;
147135
}
148136

@@ -157,13 +145,13 @@ $(function () {
157145
verified = true;
158146
formInput.prop("checked", true);
159147
confirmationBtn.addClass("valid");
160-
tFaToast("2 factor authentication enabled");
148+
Hm_Notices.show("2 factor authentication enabled");
161149
} else {
162150
verified = false;
163151
formInput.prop("checked", false);
164152
$(".tfa_confirmation_input_digit").addClass("invalid");
165153
confirmationBtn.addClass("invalid").addClass("shake");
166-
tFaToast("ERR2 factor authentication code does not match");
154+
Hm_Notices.show("2 factor authentication code does not match", 'danger');
167155
}
168156
confirmationBtn.text("Verify code").removeClass("loading");
169157
}

modules/advanced_search/site.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,22 +364,22 @@ var process_advanced_search = function() {
364364
Hm_Notices.hide(true);
365365
var terms = get_adv_terms();
366366
if (terms.length == 0) {
367-
Hm_Notices.show([err_msg('You must enter at least one search term')]);
367+
Hm_Notices.show('You must enter at least one search term', 'warning');
368368
return;
369369
}
370370
const sources = get_adv_sources();
371371
if (sources.length == 0) {
372-
Hm_Notices.show([err_msg('You must select at least one source')]);
372+
Hm_Notices.show('You must select at least one source', 'warning');
373373
return;
374374
}
375375
var targets = get_adv_targets();
376376
if (targets.length == 0) {
377-
Hm_Notices.show([err_msg('You must have at least one target')]);
377+
Hm_Notices.show('You must have at least one target', 'warning');
378378
return;
379379
}
380380
var times = get_adv_times();
381381
if (times.length == 0) {
382-
Hm_Notices.show([err_msg('You must enter at least one time range')]);
382+
Hm_Notices.show('You must enter at least one time range', 'warning');
383383
return;
384384
}
385385
var other = get_adv_other();

modules/contacts/js_modules/route_handlers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function applyContactsPageHandlers() {
1919
const allowed_characters = ['+','-','(',')'];
2020
for (let chain_counter = 0; chain_counter < contact_phone.length; chain_counter++) {
2121
if(!(regex_number.test(contact_phone[chain_counter])) && !(allowed_characters.indexOf(contact_phone[chain_counter]) > -1)){
22-
Hm_Notices.show([hm_trans("This phone number appears to contain invalid character (s).\nIf you are sure ignore this warning and continue!")]);
22+
Hm_Notices.show("This phone number appears to contain invalid character (s).\nIf you are sure ignore this warning and continue!", "warning");
2323
$(this).off();
2424
}
2525
}

modules/core/js_modules/actions/pagination.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ async function changePage(toPage, button, offsets) {
6868
display_imap_mailbox(messagesStore.rows, null, messagesStore.list);
6969
$(".pagination .current").text(toPage);
7070
} catch (error) {
71-
Hm_Utils.add_sys_message("Failed to fetch content", "danger");
71+
Hm_Notices.show("Failed to fetch content", "danger");
7272
} finally {
7373
$(button).removeClass('active');
7474
refreshNextButton(toPage);

modules/core/js_modules/actions/privacy_controls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async function addSenderToImagesWhitelist(email) {
88
], (response) => {
99
resolve(response);
1010
}, [], false, undefined, () => {
11-
Hm_Notices.show([`ERRAn error occured while adding the sender to the whitelist`]);
11+
Hm_Notices.show('An error occured while adding the sender to the whitelist', 'danger');
1212
reject();
1313
});
1414
});

modules/core/js_modules/actions/sortCombinedLists.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ async function sortCombinedLists(sortValue) {
1010
Hm_Utils.tbody().attr('id', messagesStore.list);
1111
display_imap_mailbox(messagesStore.rows, null, messagesStore.list);
1212
} catch (error) {
13-
Hm_Utils.add_sys_message('Failed to load messages', 'danger');
13+
Hm_Notices.show('Failed to load messages', 'danger');
1414
}
1515
}

modules/core/navigation/navigation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ async function navigate(url) {
9191

9292
trackLocationSearchChanges();
9393
} catch (error) {
94-
Hm_Notices.show([`ERR${error.message}`]);
94+
Hm_Notices.show(error.message, 'danger');
9595
} finally {
9696
hideRoutingToast();
9797
}

0 commit comments

Comments
 (0)