This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git
commit 8298a78170159ada0b57f67931ed229d30c67a07 Author: Sebb <[email protected]> AuthorDate: Sat Jan 8 00:15:43 2022 +0000 Simplify using for of loop --- webui/js/source/composer.js | 4 ++-- webui/js/source/key-commands.js | 16 ++++++++-------- webui/js/source/list-index.js | 7 +++---- webui/js/source/render-email.js | 6 ++---- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/webui/js/source/composer.js b/webui/js/source/composer.js index cce3738..7aabb8f 100644 --- a/webui/js/source/composer.js +++ b/webui/js/source/composer.js @@ -80,8 +80,8 @@ function compose_email(replyto, list) { }); s.inject(new HTML('option', {}, G_ponymail_preferences.login.credentials.email)); if (G_ponymail_preferences.login && G_ponymail_preferences.login.alternates) { - for (let z = 0; z < G_ponymail_preferences.login.alternates.length; z++) { - s.inject(new HTML('option', {}, G_ponymail_preferences.login.alternates[z])); + for (let alternate of G_ponymail_preferences.login.alternates) { + s.inject(new HTML('option', {}, alternate)); } } form.push(new HTML('br')); diff --git a/webui/js/source/key-commands.js b/webui/js/source/key-commands.js index 2b2b893..ce61553 100644 --- a/webui/js/source/key-commands.js +++ b/webui/js/source/key-commands.js @@ -107,10 +107,10 @@ function hideWindows(force_all) { // Finally, check for other opened emails, close 'em all let placeholders = document.getElementsByClassName('email_placeholder'); - for (let i = 0; i < placeholders.length; i++) { - if (placeholders[i].style.display == 'block') { - console.log("Hiding placeholder %s".format(placeholders[i].getAttribute('id'))); - placeholders[i].style.display = 'none'; + for (let placeholder of placeholders) { + if (placeholder.style.display == 'block') { + console.log("Hiding placeholder %s".format(placeholder.getAttribute('id'))); + placeholder.style.display = 'none'; // Reset scroll cache try { window.scrollTo(0, 0); @@ -119,10 +119,10 @@ function hideWindows(force_all) { } placeholders = document.getElementsByClassName('email_placeholder_chatty'); - for (let i = 0; i < placeholders.length; i++) { - if (placeholders[i].style.display == 'block') { - console.log("Hiding placeholder %s".format(placeholders[i].getAttribute('id'))); - placeholders[i].style.display = 'none'; + for (let placeholder of placeholders) { + if (placeholder.style.display == 'block') { + console.log("Hiding placeholder %s".format(placeholder.getAttribute('id'))); + placeholder.style.display = 'none'; // Reset scroll cache try { window.scrollTo(0, 0); diff --git a/webui/js/source/list-index.js b/webui/js/source/list-index.js index f38aa7e..d508bb8 100644 --- a/webui/js/source/list-index.js +++ b/webui/js/source/list-index.js @@ -34,8 +34,8 @@ function list_index(state, json) { } } else { let letters = 'abcdefghijklmnopqrstuvwxyz#'; - for (let i = 0; i < letters.length; i++) { - let xletter = letters[i].toUpperCase(); // declared above + for (let char of letters) { + let xletter = char.toUpperCase(); let li = new HTML('li', { onclick: 'list_index({letter: "%s"});'.format(xletter), class: (xletter == 'A') ? 'active' : null @@ -73,8 +73,7 @@ function list_index_onepage(state, json) { let domains = Object.keys(json.lists); domains.sort(); let letter = ''; - for (let i = 0; i < domains.length; i++) { - let domain = domains[i]; + for (let domain of domains) { let l = domain[0]; if (l != letter) { letter = l; diff --git a/webui/js/source/render-email.js b/webui/js/source/render-email.js index 31ab4d3..a6a9179 100644 --- a/webui/js/source/render-email.js +++ b/webui/js/source/render-email.js @@ -133,8 +133,7 @@ async function render_email(state, json) { class: 'email_key' }, "Attachment(s): "); let alinks = []; - for (let n = 0; n < json.attachments.length; n++) { - let attachment = json.attachments[n]; + for (let attachment of json.attachments) { let link = `${G_apiURL}api/email.lua?attachment=true&id=${json.mid}&file=${attachment.hash}`; let a = new HTML('a', { href: link, @@ -274,8 +273,7 @@ async function render_email_chatty(state, json) { class: 'email_key' }, "Attachment(s):"); let alinks = []; - for (let n = 0; n < json.attachments.length; n++) { - let attachment = json.attachments[n]; + for (let attachment of json.attachments) { let link = `${G_apiURL}api/email.lua?attachment=true&id=${json.mid}&file=${attachment.hash}`; let a = new HTML('a', { href: link,
