You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2021/11/18 01:54:21 UTC
[incubator-ponymail-foal] branch master updated (44b1b75 -> 916e452)
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git.
from 44b1b75 Simplify using for-of loops
new e93bb0b Simplify using for-of loops; var => let
new 916e452 Regen
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
webui/js/ponymail.js | 64 +++++++++++++++++--------------------
webui/js/source/listview-header.js | 31 ++++++++----------
webui/js/source/primer.js | 18 +++++------
webui/js/source/search.js | 3 +-
webui/js/source/sidebar-calendar.js | 8 ++---
webui/js/source/sidebar-stats.js | 2 +-
6 files changed, 59 insertions(+), 67 deletions(-)
[incubator-ponymail-foal] 02/02: Regen
Posted by se...@apache.org.
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 916e4521af69b91415dc84eb1b5b63b2966af8b1
Author: Sebb <se...@apache.org>
AuthorDate: Thu Nov 18 01:54:08 2021 +0000
Regen
---
webui/js/ponymail.js | 64 ++++++++++++++++++++++++----------------------------
1 file changed, 30 insertions(+), 34 deletions(-)
diff --git a/webui/js/ponymail.js b/webui/js/ponymail.js
index 31e471e..8c6e02e 100644
--- a/webui/js/ponymail.js
+++ b/webui/js/ponymail.js
@@ -16,7 +16,7 @@
*/
// THIS IS AN AUTOMATICALLY COMBINED FILE. PLEASE EDIT source/*.js!!
-const PONYMAIL_REVISION = "2048044";
+const PONYMAIL_REVISION = "e93bb0b";
@@ -2296,8 +2296,7 @@ function listview_list_lists(state, json) {
if (state && state.to) {
let tab = undefined;
let tabs = lists.childNodes;
- for (var i = 0; i < tabs.length; i++) {
- let xtab = tabs[i];
+ for (let xtab of tabs) {
if ((state.to == 'search' && xtab.getAttribute('id') == 'tab_search') || (xtab.innerText == state.to || xtab.getAttribute('data-list') == state.to)) {
tab = xtab;
tab.setAttribute("class", state.to == 'search' ? 'search' : 'active');
@@ -2316,19 +2315,19 @@ function listview_list_lists(state, json) {
if (isHash(json.lists) && json.lists[current_domain]) {
let lists_sorted = [];
- for (var list in json.lists[current_domain]) {
+ for (let list in json.lists[current_domain]) {
lists_sorted.push([list, json.lists[current_domain][list]]);
}
lists_sorted.sort((a, b) => b[1] - a[1]);
let alists = [];
- for (var i = 0; i < lists_sorted.length; i++) alists.push(lists_sorted[i][0]);
+ for (let list of lists_sorted) alists.push(list[0]);
if (current_list != '*' && current_domain != '*') {
alists.remove(current_list);
alists.unshift(current_list);
}
let maxlists = (searching && 3 || 4);
if (alists.length == maxlists + 1) maxlists++; // skip drop-down if only one additional list (#54)
- for (var i = 0; i < alists.length; i++) {
+ for (let i = 0; i < alists.length; i++) {
if (i >= maxlists) break;
let listname = alists[i];
let listnametxt = listname;
@@ -2345,7 +2344,7 @@ function listview_list_lists(state, json) {
if (alists.length > maxlists) {
let other_lists_sorted = [];
- for (var i = maxlists; i < alists.length; i++) {
+ for (let i = maxlists; i < alists.length; i++) {
other_lists_sorted.push(alists[i]);
}
other_lists_sorted.sort();
@@ -2361,8 +2360,7 @@ function listview_list_lists(state, json) {
selected: 'selected'
}, 'Other lists (%u):'.format(other_lists_sorted.length)));
li.inject(otherlists);
- for (var i = 0; i < other_lists_sorted.length; i++) {
- let listname = other_lists_sorted[i];
+ for (let listname of other_lists_sorted) {
let opt = new HTML('option', {
value: "%s@%s".format(listname, current_domain)
}, listname);
@@ -2372,8 +2370,8 @@ function listview_list_lists(state, json) {
}
// All lists, for narrow UI
let all_lists_narrow = [];
- for (var i = 0; i < alists.length; i++) {
- all_lists_narrow.push(alists[i]);
+ for (let alist of alists) {
+ all_lists_narrow.push(alist);
}
all_lists_narrow.sort();
let li = new HTML('li', {
@@ -2388,8 +2386,7 @@ function listview_list_lists(state, json) {
selected: 'selected'
}, "%s@%s".format(current_list, current_domain)));
li.inject(otherlists);
- for (var i = 0; i < all_lists_narrow.length; i++) {
- let listname = all_lists_narrow[i];
+ for (let listname of all_lists_narrow) {
let opt = new HTML('option', {
value: "%s@%s".format(listname, current_domain)
}, listname);
@@ -2416,7 +2413,7 @@ function listview_list_lists(state, json) {
if (!select || select_primed) return;
let opts = {}
let doms = [];
- for (var domain in json.lists) {
+ for (let domain in json.lists) {
let option = new HTML('option', {
value: domain
}, domain);
@@ -2433,8 +2430,8 @@ function listview_list_lists(state, json) {
}, "Available projects (%u):".format(no_projects));
select.inject(title);
doms.sort();
- for (var i = 0; i < doms.length; i++) {
- select.inject(opts[doms[i]]);
+ for (let dom of doms) {
+ select.inject(opts[dom]);
}
select.style.display = "inline-block";
select_primed = true; // mark it primed so we don't generate it again later
@@ -2448,12 +2445,12 @@ function switch_project(domain) {
if (ponymail_preferences && ponymail_preferences.lists[domain]) {
// Switch to the most populous, but not commits/cvs
let lists_sorted = [];
- for (var list in ponymail_preferences.lists[domain]) {
+ for (let list in ponymail_preferences.lists[domain]) {
lists_sorted.push([list, ponymail_preferences.lists[domain][list]]);
}
lists_sorted.sort((a, b) => b[1] - a[1]);
let lists = [];
- for (var i = 0; i < lists_sorted.length; i++) lists.push(lists_sorted[i][0]);
+ for (let list of lists_sorted) lists.push(list[0]);
let listname = lists[0];
let n = 1;
if (lists.length > n) {
@@ -3338,8 +3335,8 @@ function post_prime(state) {
if (!(state && state.search)) {
if (state && state.array) {
collated_json = {};
- for (var i = 0; i < state.array.length; i++) {
- let list = state.array[i].split('@');
+ for (let entry of state.array) {
+ let list = entry.split('@');
sURL = '%sapi/stats.lua?list=%s&domain=%s'.format(apiURL, list[0], list[1]);
GET(sURL, render_virtual_inbox, state);
}
@@ -3431,15 +3428,15 @@ function render_virtual_inbox(state, json) {
if (json) {
collated_json.emails = collated_json.emails || [];
collated_json.thread_struct = collated_json.thread_struct || [];
- for (var i = 0; i < json.emails.length; i++) {
- collated_json.emails.push(json.emails[i]);
+ for (let email of json.emails) {
+ collated_json.emails.push(email);
}
- for (var i = 0; i < json.thread_struct.length; i++) {
- collated_json.thread_struct.push(json.thread_struct[i]);
+ for (let thread_struct of json.thread_struct) {
+ collated_json.thread_struct.push(thread_struct);
}
}
- for (var k in async_escrow) {
+ for (let _ in async_escrow) {
return;
}
@@ -3476,8 +3473,8 @@ function unshortenID(mid) {
// Some old shortlinks begin with 'B', so let's be backwards compatible for now.
if (mid[0] == 'Z' || mid[0] == 'B') {
// remove padding
- var id1 = parseInt(mid.substr(1, 7).replace(/-/g, ""), 36)
- var id2 = parseInt(mid.substr(8, 7).replace(/-/g, ""), 36)
+ let id1 = parseInt(mid.substr(1, 7).replace(/-/g, ""), 36)
+ let id2 = parseInt(mid.substr(8, 7).replace(/-/g, ""), 36)
id1 = id1.toString(16)
id2 = id2.toString(16)
@@ -4040,8 +4037,7 @@ function search_set_list(what) {
ponymail_search_list = what;
let links = document.getElementsByClassName('searchlistoption');
let whatxt = "this list"
- for (let i = 0; i < links.length; i++) {
- let el = links[i];
+ for (let el of links) {
if (el.getAttribute("id").match(what)) {
el.setAttribute("class", "searchlistoption checked");
whatxt = el.innerText.toLowerCase();
@@ -4099,14 +4095,14 @@ function renderCalendar(FY, FM, LY, LM, activity = null) {
cdiv.inject(chevron);
// Create divs for each year, assign all visible
- for (var Y = SY; Y >= FY; Y--) {
+ for (let Y = SY; Y >= FY; Y--) {
let ydiv = new HTML('div', {
class: 'sidebar_calendar_year',
id: 'sidebar_calendar_' + N++
});
ydiv.inject(txt(Y));
ydiv.inject(new HTML('br'));
- for (var i = 0; i < MONTHS_SHORTENED.length; i++) {
+ for (let i = 0; i < MONTHS_SHORTENED.length; i++) {
let mon = MONTHS_SHORTENED[i];
let mdiv = new HTML('div', {
onclick: 'calendar_click(%u, %u);'.format(Y, i + 1),
@@ -4163,7 +4159,7 @@ function renderCalendar(FY, FM, LY, LM, activity = null) {
// If we have > 4 years, hide the rest
if (N > calendar_years_shown) {
- for (var i = calendar_years_shown; i < N; i++) {
+ for (let i = calendar_years_shown; i < N; i++) {
let obj = document.getElementById('sidebar_calendar_' + i);
if (obj) {
obj.style.display = "none";
@@ -4188,7 +4184,7 @@ function calendar_scroll(me, x) {
}
- for (var i = 0; i < years.length; i++) {
+ for (let i = 0; i < years.length; i++) {
let year = years[i];
if (typeof(year) == 'object') {
if (i >= calendar_index && i < (calendar_index + Math.abs(x))) {
@@ -4267,7 +4263,7 @@ async function sidebar_stats(json) {
// Top 10 participants
obj.inject("Found %u emails by %u authors, divided into %u topics.".format(json.emails.length, json.numparts, json.no_threads));
obj.inject(new HTML('h5', {}, "Most active authors:"));
- for (var i = 0; i < json.participants.length; i++) {
+ for (let i = 0; i < json.participants.length; i++) {
if (i >= 5) {
break;
}
[incubator-ponymail-foal] 01/02: Simplify using for-of loops; var => let
Posted by se...@apache.org.
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 e93bb0b2bfd3819fa60f9d046eb775be18764467
Author: Sebb <se...@apache.org>
AuthorDate: Thu Nov 18 01:53:41 2021 +0000
Simplify using for-of loops; var => let
---
webui/js/source/listview-header.js | 31 ++++++++++++++-----------------
webui/js/source/primer.js | 18 +++++++++---------
webui/js/source/search.js | 3 +--
webui/js/source/sidebar-calendar.js | 8 ++++----
webui/js/source/sidebar-stats.js | 2 +-
5 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/webui/js/source/listview-header.js b/webui/js/source/listview-header.js
index 274ce59..548c838 100644
--- a/webui/js/source/listview-header.js
+++ b/webui/js/source/listview-header.js
@@ -129,8 +129,7 @@ function listview_list_lists(state, json) {
if (state && state.to) {
let tab = undefined;
let tabs = lists.childNodes;
- for (var i = 0; i < tabs.length; i++) {
- let xtab = tabs[i];
+ for (let xtab of tabs) {
if ((state.to == 'search' && xtab.getAttribute('id') == 'tab_search') || (xtab.innerText == state.to || xtab.getAttribute('data-list') == state.to)) {
tab = xtab;
tab.setAttribute("class", state.to == 'search' ? 'search' : 'active');
@@ -149,19 +148,19 @@ function listview_list_lists(state, json) {
if (isHash(json.lists) && json.lists[current_domain]) {
let lists_sorted = [];
- for (var list in json.lists[current_domain]) {
+ for (let list in json.lists[current_domain]) {
lists_sorted.push([list, json.lists[current_domain][list]]);
}
lists_sorted.sort((a, b) => b[1] - a[1]);
let alists = [];
- for (var i = 0; i < lists_sorted.length; i++) alists.push(lists_sorted[i][0]);
+ for (let list of lists_sorted) alists.push(list[0]);
if (current_list != '*' && current_domain != '*') {
alists.remove(current_list);
alists.unshift(current_list);
}
let maxlists = (searching && 3 || 4);
if (alists.length == maxlists + 1) maxlists++; // skip drop-down if only one additional list (#54)
- for (var i = 0; i < alists.length; i++) {
+ for (let i = 0; i < alists.length; i++) {
if (i >= maxlists) break;
let listname = alists[i];
let listnametxt = listname;
@@ -178,7 +177,7 @@ function listview_list_lists(state, json) {
if (alists.length > maxlists) {
let other_lists_sorted = [];
- for (var i = maxlists; i < alists.length; i++) {
+ for (let i = maxlists; i < alists.length; i++) {
other_lists_sorted.push(alists[i]);
}
other_lists_sorted.sort();
@@ -194,8 +193,7 @@ function listview_list_lists(state, json) {
selected: 'selected'
}, 'Other lists (%u):'.format(other_lists_sorted.length)));
li.inject(otherlists);
- for (var i = 0; i < other_lists_sorted.length; i++) {
- let listname = other_lists_sorted[i];
+ for (let listname of other_lists_sorted) {
let opt = new HTML('option', {
value: "%s@%s".format(listname, current_domain)
}, listname);
@@ -205,8 +203,8 @@ function listview_list_lists(state, json) {
}
// All lists, for narrow UI
let all_lists_narrow = [];
- for (var i = 0; i < alists.length; i++) {
- all_lists_narrow.push(alists[i]);
+ for (let alist of alists) {
+ all_lists_narrow.push(alist);
}
all_lists_narrow.sort();
let li = new HTML('li', {
@@ -221,8 +219,7 @@ function listview_list_lists(state, json) {
selected: 'selected'
}, "%s@%s".format(current_list, current_domain)));
li.inject(otherlists);
- for (var i = 0; i < all_lists_narrow.length; i++) {
- let listname = all_lists_narrow[i];
+ for (let listname of all_lists_narrow) {
let opt = new HTML('option', {
value: "%s@%s".format(listname, current_domain)
}, listname);
@@ -249,7 +246,7 @@ function listview_list_lists(state, json) {
if (!select || select_primed) return;
let opts = {}
let doms = [];
- for (var domain in json.lists) {
+ for (let domain in json.lists) {
let option = new HTML('option', {
value: domain
}, domain);
@@ -266,8 +263,8 @@ function listview_list_lists(state, json) {
}, "Available projects (%u):".format(no_projects));
select.inject(title);
doms.sort();
- for (var i = 0; i < doms.length; i++) {
- select.inject(opts[doms[i]]);
+ for (let dom of doms) {
+ select.inject(opts[dom]);
}
select.style.display = "inline-block";
select_primed = true; // mark it primed so we don't generate it again later
@@ -281,12 +278,12 @@ function switch_project(domain) {
if (ponymail_preferences && ponymail_preferences.lists[domain]) {
// Switch to the most populous, but not commits/cvs
let lists_sorted = [];
- for (var list in ponymail_preferences.lists[domain]) {
+ for (let list in ponymail_preferences.lists[domain]) {
lists_sorted.push([list, ponymail_preferences.lists[domain][list]]);
}
lists_sorted.sort((a, b) => b[1] - a[1]);
let lists = [];
- for (var i = 0; i < lists_sorted.length; i++) lists.push(lists_sorted[i][0]);
+ for (let list of lists_sorted) lists.push(list[0]);
let listname = lists[0];
let n = 1;
if (lists.length > n) {
diff --git a/webui/js/source/primer.js b/webui/js/source/primer.js
index 3e547b1..7ec9ead 100644
--- a/webui/js/source/primer.js
+++ b/webui/js/source/primer.js
@@ -68,8 +68,8 @@ function post_prime(state) {
if (!(state && state.search)) {
if (state && state.array) {
collated_json = {};
- for (var i = 0; i < state.array.length; i++) {
- let list = state.array[i].split('@');
+ for (let entry of state.array) {
+ let list = entry.split('@');
sURL = '%sapi/stats.lua?list=%s&domain=%s'.format(apiURL, list[0], list[1]);
GET(sURL, render_virtual_inbox, state);
}
@@ -161,15 +161,15 @@ function render_virtual_inbox(state, json) {
if (json) {
collated_json.emails = collated_json.emails || [];
collated_json.thread_struct = collated_json.thread_struct || [];
- for (var i = 0; i < json.emails.length; i++) {
- collated_json.emails.push(json.emails[i]);
+ for (let email of json.emails) {
+ collated_json.emails.push(email);
}
- for (var i = 0; i < json.thread_struct.length; i++) {
- collated_json.thread_struct.push(json.thread_struct[i]);
+ for (let thread_struct of json.thread_struct) {
+ collated_json.thread_struct.push(thread_struct);
}
}
- for (var k in async_escrow) {
+ for (let _ in async_escrow) {
return;
}
@@ -206,8 +206,8 @@ function unshortenID(mid) {
// Some old shortlinks begin with 'B', so let's be backwards compatible for now.
if (mid[0] == 'Z' || mid[0] == 'B') {
// remove padding
- var id1 = parseInt(mid.substr(1, 7).replace(/-/g, ""), 36)
- var id2 = parseInt(mid.substr(8, 7).replace(/-/g, ""), 36)
+ let id1 = parseInt(mid.substr(1, 7).replace(/-/g, ""), 36)
+ let id2 = parseInt(mid.substr(8, 7).replace(/-/g, ""), 36)
id1 = id1.toString(16)
id2 = id2.toString(16)
diff --git a/webui/js/source/search.js b/webui/js/source/search.js
index 05ac076..9935a56 100644
--- a/webui/js/source/search.js
+++ b/webui/js/source/search.js
@@ -68,8 +68,7 @@ function search_set_list(what) {
ponymail_search_list = what;
let links = document.getElementsByClassName('searchlistoption');
let whatxt = "this list"
- for (let i = 0; i < links.length; i++) {
- let el = links[i];
+ for (let el of links) {
if (el.getAttribute("id").match(what)) {
el.setAttribute("class", "searchlistoption checked");
whatxt = el.innerText.toLowerCase();
diff --git a/webui/js/source/sidebar-calendar.js b/webui/js/source/sidebar-calendar.js
index 72b0906..ca2dea6 100644
--- a/webui/js/source/sidebar-calendar.js
+++ b/webui/js/source/sidebar-calendar.js
@@ -58,14 +58,14 @@ function renderCalendar(FY, FM, LY, LM, activity = null) {
cdiv.inject(chevron);
// Create divs for each year, assign all visible
- for (var Y = SY; Y >= FY; Y--) {
+ for (let Y = SY; Y >= FY; Y--) {
let ydiv = new HTML('div', {
class: 'sidebar_calendar_year',
id: 'sidebar_calendar_' + N++
});
ydiv.inject(txt(Y));
ydiv.inject(new HTML('br'));
- for (var i = 0; i < MONTHS_SHORTENED.length; i++) {
+ for (let i = 0; i < MONTHS_SHORTENED.length; i++) {
let mon = MONTHS_SHORTENED[i];
let mdiv = new HTML('div', {
onclick: 'calendar_click(%u, %u);'.format(Y, i + 1),
@@ -122,7 +122,7 @@ function renderCalendar(FY, FM, LY, LM, activity = null) {
// If we have > 4 years, hide the rest
if (N > calendar_years_shown) {
- for (var i = calendar_years_shown; i < N; i++) {
+ for (let i = calendar_years_shown; i < N; i++) {
let obj = document.getElementById('sidebar_calendar_' + i);
if (obj) {
obj.style.display = "none";
@@ -147,7 +147,7 @@ function calendar_scroll(me, x) {
}
- for (var i = 0; i < years.length; i++) {
+ for (let i = 0; i < years.length; i++) {
let year = years[i];
if (typeof(year) == 'object') {
if (i >= calendar_index && i < (calendar_index + Math.abs(x))) {
diff --git a/webui/js/source/sidebar-stats.js b/webui/js/source/sidebar-stats.js
index 9f60925..7fe38b7 100644
--- a/webui/js/source/sidebar-stats.js
+++ b/webui/js/source/sidebar-stats.js
@@ -43,7 +43,7 @@ async function sidebar_stats(json) {
// Top 10 participants
obj.inject("Found %u emails by %u authors, divided into %u topics.".format(json.emails.length, json.numparts, json.no_threads));
obj.inject(new HTML('h5', {}, "Most active authors:"));
- for (var i = 0; i < json.participants.length; i++) {
+ for (let i = 0; i < json.participants.length; i++) {
if (i >= 5) {
break;
}