This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit c7e6b82202361bc49a47e63ab5f7b25b56dce96a
Author: Daniel Gruno <[email protected]>
AuthorDate: Thu Nov 18 00:15:39 2021 +0100

    Consolidate+expand logging
---
 webui/js/source/listview-flat.js     |  6 +++---
 webui/js/source/listview-header.js   | 11 +++++------
 webui/js/source/listview-threaded.js |  3 +--
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/webui/js/source/listview-flat.js b/webui/js/source/listview-flat.js
index 1cc22e1..6e7e070 100644
--- a/webui/js/source/listview-flat.js
+++ b/webui/js/source/listview-flat.js
@@ -24,7 +24,7 @@ function calc_per_page() {
     let width = Math.max(body.scrollWidth,
         html.clientWidth, html.scrollWidth);
     let email_h = 40;
-    console.log("window area: %ux%u".format(width, height));
+    console.log("Window area: %ux%u".format(width, height));
     if (width < 600) {
         console.log("Using narrow view, halving emails per page...");
         email_h = 80;
@@ -32,17 +32,17 @@ function calc_per_page() {
     height -= 180;
     let per_page = Math.max(5, Math.floor(height / email_h));
     per_page -= per_page % 5;
+    console.log("We can display %u emails per page".format(per_page));
     return per_page;
 }
 
 function listview_flat(json, start) {
     let list = document.getElementById('emails');
     list.innerHTML = "";
-    let per_page = calc_per_page();
 
     let s = start || 0;
     if (json.emails && json.emails.length) {
-        for (n = s; n < (s + per_page); n++) {
+        for (n = s; n < (s + current_per_page); n++) {
             let z = json.emails.length - n - 1; // reverse order by default
             if (json.emails[z]) {
                 let item = listview_flat_element(json.emails[z], z);
diff --git a/webui/js/source/listview-header.js 
b/webui/js/source/listview-header.js
index 6fe1813..1f314d4 100644
--- a/webui/js/source/listview-header.js
+++ b/webui/js/source/listview-header.js
@@ -66,8 +66,7 @@ function listview_header(state, json) {
     });
 
     let chevrons = document.getElementById('listview_chevrons');
-    let per_page = calc_per_page();
-    current_per_page = per_page;
+    current_per_page = calc_per_page();
     current_index_pos = state.pos || 0;
     let first = 1;
     if (state && state.pos) {
@@ -77,10 +76,10 @@ function listview_header(state, json) {
         chevrons.innerHTML = "No topics to show";
         blobs = [];
     } else {
-        chevrons.innerHTML = "Showing <b>%u through %u</b> of <b>%u</b> 
topics&nbsp;".format(first, Math.min(first + per_page - 1, blobs.length), 
blobs.length || 0);
+        chevrons.innerHTML = "Showing <b>%u through %u</b> of <b>%u</b> 
topics&nbsp;".format(first, Math.min(first + current_per_page - 1, 
blobs.length), blobs.length || 0);
     }
 
-    let pprev = Math.max(0, first - per_page - 1);
+    let pprev = Math.max(0, first - current_per_page - 1);
     let cback = new HTML('button', {
         onclick: 'listview_header({pos: %u}, current_json);'.format(pprev),
         disabled: (first == 1) ? 'true' : null
@@ -89,10 +88,10 @@ function listview_header(state, json) {
     }, " "));
     chevrons.inject(cback);
 
-    let pnext = first + per_page - 1;
+    let pnext = first + current_per_page - 1;
     let cforward = new HTML('button', {
         onclick: 'listview_header({pos: %u}, current_json);'.format(pnext),
-        disabled: (first + per_page - 1 >= blobs.length) ? 'true' : null
+        disabled: (first + current_per_page - 1 >= blobs.length) ? 'true' : 
null
     }, new HTML('span', {
         class: 'glyphicon glyphicon-chevron-right'
     }, " "));
diff --git a/webui/js/source/listview-threaded.js 
b/webui/js/source/listview-threaded.js
index 8346842..8112d15 100644
--- a/webui/js/source/listview-threaded.js
+++ b/webui/js/source/listview-threaded.js
@@ -27,11 +27,10 @@ function calc_email_width() {
 function listview_threaded(json, start) {
     let list = document.getElementById('emails');
     list.innerHTML = "";
-    let per_page = calc_per_page();
 
     let s = start || 0;
     if (json.thread_struct && json.thread_struct.length) {
-        for (let n = s; n < (s + per_page); n++) {
+        for (let n = s; n < (s + current_per_page); n++) {
             let z = json.thread_struct.length - n - 1; // reverse order by 
default
             if (json.thread_struct[z]) {
                 let item = listview_threaded_element(json.thread_struct[z], z);

Reply via email to