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 09:18:54 UTC

[5/5] 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/ebb64dc4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/ebb64dc4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/ebb64dc4

Branch: refs/heads/coffee-and-cake
Commit: ebb64dc4059aa70a82ffb1630ad979813e6c4d7d
Parents: dad2769
Author: Daniel Gruno <hu...@apache.org>
Authored: Sat Sep 3 11:18:35 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Sat Sep 3 11:18:35 2016 +0200

----------------------------------------------------------------------
 site/js/ponymail-coffee.js | 94 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 79 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ebb64dc4/site/js/ponymail-coffee.js
----------------------------------------------------------------------
diff --git a/site/js/ponymail-coffee.js b/site/js/ponymail-coffee.js
index c1706bf..a01ac2d 100644
--- a/site/js/ponymail-coffee.js
+++ b/site/js/ponymail-coffee.js
@@ -1,5 +1,5 @@
 // Generated by CoffeeScript 1.9.3
-var BasicListView, Calendar, HTML, HTTPRequest, calendar_months, cog, dbRead, dbWrite, e, genColors, get, hsl2rgb, isArray, isHash, listView, listviewScaffolding, parseURL, pendingURLStatus, pending_spinner_at, pending_url_operations, pm_snap, pm_storage_available, pm_storage_globvar, ponymail_list, ponymail_lists, ponymail_month, ponymail_query, ponymail_version, renderListView, set, setupAccount, spinCheck, testCoffee, testToggle, toggleMonth, toggleYear, txt;
+var BasicListView, Calendar, HTML, HTTPRequest, calendar_months, cog, dbRead, dbWrite, e, genColors, get, hasRead, hsl2rgb, isArray, isHash, listView, listviewScaffolding, markRead, parseURL, pendingURLStatus, pending_spinner_at, pending_url_operations, pm_snap, pm_storage_available, pm_storage_globvar, ponymail_list, ponymail_lists, ponymail_month, ponymail_query, ponymail_version, readEmail, renderListView, set, setupAccount, spinCheck, testCoffee, testToggle, toggleMonth, toggleYear, txt;
 
 calendar_months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
 
@@ -119,7 +119,7 @@ toggleMonth = function(div) {
 
   /* Update the list view using the new month */
   return listView({
-    month: m
+    month: year + "-" + parseInt(month).pad(2)
   });
 };
 
@@ -509,10 +509,10 @@ pending_url_operations = {};
 pending_spinner_at = 0;
 
 spinCheck = function(div) {
-  var ndiv, now;
-  now = new Date().getTime();
-  if ((now - pending_spinner_at) >= 4000) {
-    pending_spinner_at = now;
+  var ndiv, spnow;
+  spnow = new Date().getTime();
+  if ((spnow - pending_spinner_at) >= 4000) {
+    pending_spinner_at = spnow;
     ndiv = div.cloneNode(true);
     ndiv.addEventListener('animationend', function(e) {
       return spinCheck(ndiv);
@@ -522,15 +522,15 @@ spinCheck = function(div) {
 };
 
 pendingURLStatus = function() {
-  var div, now, pending, time, url;
+  var div, pending, spnow, time, url;
   pending = 0;
-  now = new Date().getTime();
+  spnow = new Date().getTime();
   div = get('loading');
   for (url in pending_url_operations) {
     time = pending_url_operations[url];
 
     /* Is something taking too long?? */
-    if ((now - time) > 1500) {
+    if ((spnow - time) > 1500) {
       pending++;
       if (!div) {
         div = new HTML('div', {
@@ -546,7 +546,7 @@ pendingURLStatus = function() {
           }))), new HTML('br'), "Loading, please wait..."
         ]);
         document.body.inject(div);
-        pending_spinner_at = now;
+        pending_spinner_at = spnow;
         div.addEventListener('animationend', function(e) {
           return spinCheck(div);
         });
@@ -795,7 +795,7 @@ 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;
+    var avatar, date, date_style, diff, item, j, len, noeml, now, original, people, readStyle, ref, sender, stats, subject, uid;
     this.lastScroll = new Date().getTime();
     now = new Date().getTime() / 1000;
 
@@ -814,18 +814,45 @@ BasicListView = (function() {
         noeml = this.countEmail(item);
 
         /* Render the email in the LV */
+
+        /* First set some data points for later */
+        uid = parseInt(Math.random() * 999999999999).toString(16);
+
+        /* Gravatar */
         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*<.+>/, ""));
+
+        /* Sender, without the <fo...@bar> part - just the name */
+        sender = new HTML('div', {
+          style: {
+            fontWeight: "bold"
+          }
+        }, original.from.replace(/\s*<.+>/, "").replace(/"/g, ''));
+
+        /* readStyle: bold if new email, normal if read before */
+        readStyle = "bold";
+        if (hasRead(item.tid)) {
+          readStyle = "normal";
+        }
+
+        /* Subject, PLUS a bit of the body with a break before */
         subject = new HTML('div', {}, [
-          original.subject, new HTML('br'), new HTML('span', {
+          new HTML('a', {
+            style: {
+              fontWeight: readStyle
+            },
+            href: "thread.html/" + item.tid,
+            onclick: "readEmail(this.parentNode.parentNode); return false;"
+          }, original.subject), new HTML('br'), new HTML('span', {
             style: {
               color: "#999",
               fontSize: "0.7rem"
             }
           }, item.body)
         ]);
+
+        /* replies and authors */
         stats = new HTML('div', {
           "class": "listview_right"
         }, " " + people + " people, " + noeml + " replies");
@@ -839,6 +866,8 @@ BasicListView = (function() {
           "class": "listview_right " + date_style
         }, new Date(item.epoch * 1000).ISOBare());
         item = new HTML('div', {
+          id: uid,
+          data: item.tid,
           "class": "listview_item"
         }, [avatar, sender, subject, date, stats]);
         this.lv.inject(item);
@@ -846,7 +875,7 @@ BasicListView = (function() {
     }
     now = new Date().getTime();
     diff = now - this.lastScroll;
-    return this.lv.inject("Rendered in " + parseInt(diff) + "ms.");
+    return this.lv.inject("Fetched in " + parseInt(this.json.took / 1000) + "ms, rendered in " + parseInt(diff) + "ms.");
   };
 
 
@@ -1031,7 +1060,7 @@ listView = function(hash, reParse) {
   /* Push a new history state using new args */
   newhref = htmlfile + "?" + args;
   if (location.href !== newhref) {
-    window.history.pushState({}, newhref);
+    window.history.pushState({}, null, newhref);
   }
   ref2 = ponymail_list.split("@", 2), list = ref2[0], domain = ref2[1];
 
@@ -1128,6 +1157,41 @@ dbRead = function(key) {
   }
 };
 
+hasRead = function(mid) {
+  if (dbRead("ponymail_read_" + mid)) {
+    return true;
+  } else {
+    return false;
+  }
+};
+
+markRead = function(mid) {
+  dbWrite("ponymail_read_" + mid, new Date().getTime());
+  return true;
+};
+
+readEmail = function(obj) {
+  var insertPoint, mailDiv, mid;
+  mid = null;
+  insertPoint = null;
+
+  /* Did we get this from a div? if so, find out things */
+  if (typeof obj === 'object') {
+    mid = obj.getAttribute("data");
+    insertPoint = obj;
+  } else if (typeof obj === 'string') {
+    mid = obj;
+    insertPoint = new HTML('div');
+    document.body.inject(insertPoint);
+  }
+  if (mid && insertPoint) {
+    markRead(mid);
+    mailDiv = new HTML('div');
+    insertPoint.inject(mailDiv);
+    return mailDiv.inject("foo bar baz!");
+  }
+};
+
 
 /*
  Licensed to the Apache Software Foundation (ASF) under one or more