ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject [4/5] incubator-ponymail git commit: start work on what happens when you click a subject
Date Sat, 03 Sep 2016 09:18:53 GMT
start work on what happens when you click a subject

begin basic email display


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

Branch: refs/heads/coffee-and-cake
Commit: dad276908377ee8d4b51e65d3cd589a8a30c25da
Parents: 7df7aa5
Author: Daniel Gruno <humbedooh@apache.org>
Authored: Sat Sep 3 11:18:27 2016 +0200
Committer: Daniel Gruno <humbedooh@apache.org>
Committed: Sat Sep 3 11:18:27 2016 +0200

----------------------------------------------------------------------
 site/js/coffee/listview_basic.coffee | 26 ++++++++++++++++++++++----
 site/js/coffee/localstorage.coffee   | 10 ++++++++++
 site/js/coffee/mailview_basic.coffee | 17 +++++++++++++++++
 3 files changed, 49 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/dad27690/site/js/coffee/listview_basic.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/listview_basic.coffee b/site/js/coffee/listview_basic.coffee
index b0088fe..dd45bcf 100644
--- a/site/js/coffee/listview_basic.coffee
+++ b/site/js/coffee/listview_basic.coffee
@@ -57,13 +57,30 @@ class BasicListView
                 noeml = @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 <foo@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('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")
                 
                 ### Add date; yellow if <= 1day, grey otherwise ###
@@ -72,12 +89,13 @@ class BasicListView
                     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"}, [avatar, sender, subject,
date, stats])
+                item = new HTML('div', {id: uid, data: item.tid, class: "listview_item"},
[avatar, sender, subject, date, stats])
+                
                 @lv.inject(item)
         
         now = new Date().getTime()
         diff = now - @lastScroll
-        @lv.inject("Rendered in " + parseInt(diff) + "ms.")
+        @lv.inject("Fetched in " + parseInt(@json.took/1000) + "ms, rendered in " + parseInt(diff)
+ "ms.")
     ### findEmail: find an email given an ID ###
     findEmail: (id) ->
         for email in @json.emails

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/dad27690/site/js/coffee/localstorage.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/localstorage.coffee b/site/js/coffee/localstorage.coffee
index d4339ab..0fcf25e 100644
--- a/site/js/coffee/localstorage.coffee
+++ b/site/js/coffee/localstorage.coffee
@@ -51,3 +51,13 @@ dbRead = (key) ->
         ### Nope, try global var ###
         return pm_storage_globvar[key]
     
+
+hasRead = (mid) ->
+    if dbRead("ponymail_read_" + mid)
+        return true
+    else
+        return false
+
+markRead = (mid) ->
+    dbWrite("ponymail_read_" + mid, new Date().getTime())
+    return true
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/dad27690/site/js/coffee/mailview_basic.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/mailview_basic.coffee b/site/js/coffee/mailview_basic.coffee
new file mode 100644
index 0000000..42fe98a
--- /dev/null
+++ b/site/js/coffee/mailview_basic.coffee
@@ -0,0 +1,17 @@
+readEmail = (obj) ->
+    mid = null
+    insertPoint = null
+    ### Did we get this from a div? if so, find out things ###
+    if typeof obj is 'object'
+        mid = obj.getAttribute("data")
+        insertPoint = obj
+    else if typeof obj is 'string'
+        mid = obj
+        insertPoint = new HTML('div')
+        document.body.inject(insertPoint)
+    if mid and insertPoint
+        markRead(mid)
+        mailDiv = new HTML('div')
+        insertPoint.inject(mailDiv)
+        mailDiv.inject("foo bar baz!")
+        
\ No newline at end of file


Mime
View raw message