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 2016/09/03 08:40:47 UTC

[3/3] incubator-ponymail git commit: regen JS

regen JS


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/743bb187
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/743bb187
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/743bb187

Branch: refs/heads/coffee-and-cake
Commit: 743bb187f8be51e5ca87fce06fa7ea1f64af9cf7
Parents: d05c26e
Author: Daniel Gruno <hu...@apache.org>
Authored: Sat Sep 3 10:40:30 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Sat Sep 3 10:40:30 2016 +0200

----------------------------------------------------------------------
 site/js/ponymail-coffee.js | 60 +++++++++++++++++++++++++++++++++++------
 1 file changed, 52 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/743bb187/site/js/ponymail-coffee.js
----------------------------------------------------------------------
diff --git a/site/js/ponymail-coffee.js b/site/js/ponymail-coffee.js
index ddd8d7e..c1706bf 100644
--- a/site/js/ponymail-coffee.js
+++ b/site/js/ponymail-coffee.js
@@ -765,16 +765,24 @@ BasicListView = (function() {
 
   /* json: from stats.lua, rpp = results per page, pos = starting position (from 0) */
   function BasicListView(json1, rpp1, pos1) {
+    var hd;
     this.json = json1;
     this.rpp = rpp1 != null ? rpp1 : 15;
     this.pos = pos1 != null ? pos1 : 0;
 
+    /* Set the header first */
+    hd = get('header');
+    if (this.json.list) {
+      hd.empty().inject(this.json.list + ", past 30 days:");
+    }
+
     /* Get and clear the list view */
     this.lv = get('listview');
     this.lv = this.lv.empty();
 
     /* If we got results, use scroll() to display from result 0 on */
     if (isArray(this.json.thread_struct) && this.json.thread_struct.length > 0) {
+      this.json.thread_struct.reverse();
       this.scroll(this.rpp, this.pos);
     } else {
 
@@ -787,14 +795,15 @@ BasicListView = (function() {
   /* scroll: scroll to a position and show N emails/threads */
 
   BasicListView.prototype.scroll = function(rpp, pos) {
+    var avatar, date, date_style, diff, item, j, len, noeml, now, original, people, ref, sender, stats, subject;
+    this.lastScroll = new Date().getTime();
+    now = new Date().getTime() / 1000;
 
     /* Clear the list view */
-    var item, j, len, noeml, original, people, ref, results;
     this.lv = this.lv.empty();
 
     /* For each email result,... */
-    ref = this.json.thread_struct;
-    results = [];
+    ref = this.json.thread_struct.slice(pos, pos + rpp);
     for (j = 0, len = ref.length; j < len; j++) {
       item = ref[j];
       original = this.findEmail(item.tid);
@@ -805,15 +814,39 @@ BasicListView = (function() {
         noeml = this.countEmail(item);
 
         /* Render the email in the LV */
+        avatar = new HTML('img', {
+          src: "https://secure.gravatar.com/avatar/" + original.gravatar + ".png?s=24&r=g&d=mm"
+        });
+        sender = new HTML('div', {}, original.from.replace(/\s*<.+>/, ""));
+        subject = new HTML('div', {}, [
+          original.subject, new HTML('br'), new HTML('span', {
+            style: {
+              color: "#999",
+              fontSize: "0.7rem"
+            }
+          }, item.body)
+        ]);
+        stats = new HTML('div', {
+          "class": "listview_right"
+        }, " " + people + " people, " + noeml + " replies");
+
+        /* Add date; yellow if <= 1day, grey otherwise */
+        date_style = "listview_grey";
+        if ((now - 86400 * 4) < item.epoch) {
+          date_style = "listview_yellow";
+        }
+        date = new HTML('div', {
+          "class": "listview_right " + date_style
+        }, new Date(item.epoch * 1000).ISOBare());
         item = new HTML('div', {
           "class": "listview_item"
-        }, original.subject + " - " + people + " and " + noeml + " replies.");
-        results.push(this.lv.inject(item));
-      } else {
-        results.push(void 0);
+        }, [avatar, sender, subject, date, stats]);
+        this.lv.inject(item);
       }
     }
-    return results;
+    now = new Date().getTime();
+    diff = now - this.lastScroll;
+    return this.lv.inject("Rendered in " + parseInt(diff) + "ms.");
   };
 
 
@@ -1144,6 +1177,17 @@ Number.prototype.pad = function(n) {
 };
 
 
+/* Func for converting a date to YYYY-MM-DD */
+
+Date.prototype.ISOBare = function() {
+  var d, m, y;
+  y = this.getFullYear();
+  m = this.getMonth() + 1;
+  d = this.getDate();
+  return y + "-" + m.pad(2) + "-" + d.pad(2);
+};
+
+
 /* isArray: function to detect if an object is an array */
 
 isArray = function(value) {