You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2021/11/17 23:17:21 UTC

[incubator-ponymail-foal] branch master updated (399e3ed -> dcc7677)

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

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


    from 399e3ed  Drop unread variables and narrow scope
     new 56ae2e4  classify
     new c7e6b82  Consolidate+expand logging
     new 529f59b  use new swipe detector class
     new c221ada  ´regen JS
     new dcc7677  Merge branch 'master' of github.com:apache/incubator-ponymail-foal

The 5 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                 | 128 ++++++++++++++++++-----------------
 webui/js/source/listview-flat.js     |   6 +-
 webui/js/source/listview-header.js   |  11 ++-
 webui/js/source/listview-threaded.js |   3 +-
 webui/js/source/swipe.js             | 106 +++++++++++++++--------------
 webui/list.html                      |   6 +-
 6 files changed, 136 insertions(+), 124 deletions(-)

[incubator-ponymail-foal] 01/05: classify

Posted by hu...@apache.org.
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 56ae2e4fc952bbb273322a29d620a136375c3474
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Nov 18 00:14:58 2021 +0100

    classify
---
 webui/js/source/swipe.js | 106 +++++++++++++++++++++++++----------------------
 1 file changed, 57 insertions(+), 49 deletions(-)

diff --git a/webui/js/source/swipe.js b/webui/js/source/swipe.js
index ca88d81..67097d9 100644
--- a/webui/js/source/swipe.js
+++ b/webui/js/source/swipe.js
@@ -1,57 +1,65 @@
 const SWIPE_THRESHOLD = 50; // Need at least this long a swipe before we register it
-let xDown;
-let yDown;
-
-// touch/swipe begins                                                                         
-function touchStart(evt) {
-    let firstTouch = (evt.touches || evt.originalEvent.touches)[0];
-    xDown = firstTouch.clientX;
-    yDown = firstTouch.clientY;
-}
 
-// Touch/swipe ends
-function touchEnd(evt) {
-    if (!xDown || !yDown) return
-    let xUp = evt.changedTouches[0].clientX;
-    let yUp = evt.changedTouches[0].clientY;
-
-    let xDiff = Math.abs(xDown - xUp);
-    let yDiff = Math.abs(yDown - yUp);
-    let coords = {
-        detail: {
-            swipestart: {
-                coords: [xDown, yDown]
-            },
-            swipestop: {
-                coords: [xUp, yUp]
+class SwipeDetector {
+    constructor(target = document, threshold = SWIPE_THRESHOLD) {
+        this.xDown = null;
+        this.yDown = null;
+        this.xUp = null;
+        this.yUp = null;
+        this.threshold = threshold;
+        this.target = target;
+
+        console.log("Attaching swipe detector to element ", target);
+        target.addEventListener("touchstart", this.touchStart, false);
+        target.addEventListener("touchend", this.touchEnd, false);
+    }
+
+    setCallback(direction = "left", callback_function ) {
+        document.addEventListener(`swipe${direction}`, callback_function);
+    }
+
+    touchStart(evt) {
+        let firstTouch = (evt.touches || evt.originalEvent.touches)[0];
+        this.xDown = firstTouch.clientX;
+        this.yDown = firstTouch.clientY;
+    }
+
+    touchEnd(evt) {
+        if (!this.xDown || !this.yDown) return
+        this.xUp = evt.changedTouches[0].clientX;
+        this.yUp = evt.changedTouches[0].clientY;
+
+        let xDiff = Math.abs(this.xDown - this.xUp);
+        let yDiff = Math.abs(this.yDown - this.yUp);
+        let coords = {
+            detail: {
+                swipestart: {
+                    coords: [this.xDown, this.yDown]
+                },
+                swipestop: {
+                    coords: [this.xUp, this.yUp]
+                }
+            }
+        };
+        // If the swipe was too short, abort
+        if (Math.sqrt(xDiff ** 2 + yDiff ** 2) < this.threshold) return
+
+        // Which direction??
+        if (xDiff > yDiff) {
+            if (xDiff > 0) {
+                document.dispatchEvent(new CustomEvent("swipeleft", coords));
+            } else {
+                document.dispatchEvent(new CustomEvent("swiperight", coords));
             }
-        }
-    };
-    // If the swipe was too short, abort
-    if (Math.sqrt(xDiff ** 2 + yDiff ** 2) < SWIPE_THRESHOLD) return
-
-    // Which direction??
-    if (xDiff > yDiff) {
-        if (xDiff > 0) {
-            document.dispatchEvent(new CustomEvent("swipeleft", coords));
-        } else {
-            document.dispatchEvent(new CustomEvent("swiperight", coords));
-        }
-    } else {
-        if (yDiff > 0) {
-            document.dispatchEvent(new CustomEvent("swipeup", coords));
         } else {
-            document.dispatchEvent(new CustomEvent("swipedown", coords));
+            if (yDiff > 0) {
+                document.dispatchEvent(new CustomEvent("swipeup", coords));
+            } else {
+                document.dispatchEvent(new CustomEvent("swipedown", coords));
+            }
         }
+        this.xDown = null;
+        this.yDown = null;
     }
 
-    xDown = null;
-    yDown = null;
-};
-
-function attachSwipe(elm) {
-    console.log("Attaching swipe detector to element ", elm);
-    elm.addEventListener("touchstart", touchStart, false);
-    elm.addEventListener("touchend", touchEnd, false);
 }
-

[incubator-ponymail-foal] 02/05: Consolidate+expand logging

Posted by hu...@apache.org.
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 <hu...@apache.org>
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);

[incubator-ponymail-foal] 03/05: use new swipe detector class

Posted by hu...@apache.org.
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 529f59b8e7f3860f0bbad54c9a0ac687a3819056
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Nov 18 00:15:55 2021 +0100

    use new swipe detector class
---
 webui/list.html | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/webui/list.html b/webui/list.html
index a13dc5f..4053bcd 100644
--- a/webui/list.html
+++ b/webui/list.html
@@ -179,9 +179,9 @@ the License. -->
     <div id="splash" class="splash fade-in"> &nbsp; </div>
     <div style="clear: both;"></div>
     <script type="text/javascript">
-      attachSwipe(document.getElementById("emails"));
-      document.addEventListener("swipeleft", ponymail_swipe);
-      document.addEventListener("swiperight", ponymail_swipe);
+      let swipeDetect = new SwipeDetector(document.getElementById("emails"));
+      swipeDetect.setCallback('left', ponymail_swipe);
+      swipeDetect.setCallback('right', ponymail_swipe);
     </script>
   </body>
 </html>

[incubator-ponymail-foal] 04/05: ´regen JS

Posted by hu...@apache.org.
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 c221ada188ce1724b31d41e71bdf4cb8ef0e33d9
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Nov 18 00:16:10 2021 +0100

    ´regen JS
---
 webui/js/ponymail.js | 128 +++++++++++++++++++++++++++------------------------
 1 file changed, 67 insertions(+), 61 deletions(-)

diff --git a/webui/js/ponymail.js b/webui/js/ponymail.js
index 738224a..b090df6 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 = "35b7658";
+const PONYMAIL_REVISION = "529f59b";
 
 
 
@@ -2092,7 +2092,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;
@@ -2100,17 +2100,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);
@@ -2252,8 +2252,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) {
@@ -2263,10 +2262,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
@@ -2275,10 +2274,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'
     }, " "));
@@ -2557,11 +2556,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);
@@ -4336,59 +4334,67 @@ async function sidebar_stats(json) {
 ******************************************/
 
 const SWIPE_THRESHOLD = 50; // Need at least this long a swipe before we register it
-let xDown;
-let yDown;
-
-// touch/swipe begins                                                                         
-function touchStart(evt) {
-    let firstTouch = (evt.touches || evt.originalEvent.touches)[0];
-    xDown = firstTouch.clientX;
-    yDown = firstTouch.clientY;
-}
 
-// Touch/swipe ends
-function touchEnd(evt) {
-    if (!xDown || !yDown) return
-    let xUp = evt.changedTouches[0].clientX;
-    let yUp = evt.changedTouches[0].clientY;
-
-    let xDiff = Math.abs(xDown - xUp);
-    let yDiff = Math.abs(yDown - yUp);
-    let coords = {
-        detail: {
-            swipestart: {
-                coords: [xDown, yDown]
-            },
-            swipestop: {
-                coords: [xUp, yUp]
+class SwipeDetector {
+    constructor(target = document, threshold = SWIPE_THRESHOLD) {
+        this.xDown = null;
+        this.yDown = null;
+        this.xUp = null;
+        this.yUp = null;
+        this.threshold = threshold;
+        this.target = target;
+
+        console.log("Attaching swipe detector to element ", target);
+        target.addEventListener("touchstart", this.touchStart, false);
+        target.addEventListener("touchend", this.touchEnd, false);
+    }
+
+    setCallback(direction = "left", callback_function ) {
+        document.addEventListener(`swipe${direction}`, callback_function);
+    }
+
+    touchStart(evt) {
+        let firstTouch = (evt.touches || evt.originalEvent.touches)[0];
+        this.xDown = firstTouch.clientX;
+        this.yDown = firstTouch.clientY;
+    }
+
+    touchEnd(evt) {
+        if (!this.xDown || !this.yDown) return
+        this.xUp = evt.changedTouches[0].clientX;
+        this.yUp = evt.changedTouches[0].clientY;
+
+        let xDiff = Math.abs(this.xDown - this.xUp);
+        let yDiff = Math.abs(this.yDown - this.yUp);
+        let coords = {
+            detail: {
+                swipestart: {
+                    coords: [this.xDown, this.yDown]
+                },
+                swipestop: {
+                    coords: [this.xUp, this.yUp]
+                }
+            }
+        };
+        // If the swipe was too short, abort
+        if (Math.sqrt(xDiff ** 2 + yDiff ** 2) < this.threshold) return
+
+        // Which direction??
+        if (xDiff > yDiff) {
+            if (xDiff > 0) {
+                document.dispatchEvent(new CustomEvent("swipeleft", coords));
+            } else {
+                document.dispatchEvent(new CustomEvent("swiperight", coords));
             }
-        }
-    };
-    // If the swipe was too short, abort
-    if (Math.sqrt(xDiff ** 2 + yDiff ** 2) < SWIPE_THRESHOLD) return
-
-    // Which direction??
-    if (xDiff > yDiff) {
-        if (xDiff > 0) {
-            document.dispatchEvent(new CustomEvent("swipeleft", coords));
-        } else {
-            document.dispatchEvent(new CustomEvent("swiperight", coords));
-        }
-    } else {
-        if (yDiff > 0) {
-            document.dispatchEvent(new CustomEvent("swipeup", coords));
         } else {
-            document.dispatchEvent(new CustomEvent("swipedown", coords));
+            if (yDiff > 0) {
+                document.dispatchEvent(new CustomEvent("swipeup", coords));
+            } else {
+                document.dispatchEvent(new CustomEvent("swipedown", coords));
+            }
         }
+        this.xDown = null;
+        this.yDown = null;
     }
 
-    xDown = null;
-    yDown = null;
-};
-
-function attachSwipe(elm) {
-    console.log("Attaching swipe detector to element ", elm);
-    elm.addEventListener("touchstart", touchStart, false);
-    elm.addEventListener("touchend", touchEnd, false);
 }
-

[incubator-ponymail-foal] 05/05: Merge branch 'master' of github.com:apache/incubator-ponymail-foal

Posted by hu...@apache.org.
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 dcc767712f6b5b3fe7eb387cfe527039cf3fc319
Merge: c221ada 399e3ed
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Nov 18 00:17:11 2021 +0100

    Merge branch 'master' of github.com:apache/incubator-ponymail-foal

 webui/js/ponymail.js        | 10 +++-------
 webui/js/source/composer.js |  8 ++------
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --cc webui/js/ponymail.js
index b090df6,29efef4..cd95c14
--- a/webui/js/ponymail.js
+++ b/webui/js/ponymail.js
@@@ -16,7 -16,7 +16,7 @@@
  */
  // THIS IS AN AUTOMATICALLY COMBINED FILE. PLEASE EDIT source/*.js!!
  
- const PONYMAIL_REVISION = "529f59b";
 -const PONYMAIL_REVISION = "7d8e568";
++const PONYMAIL_REVISION = "c221ada";