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/05 15:47:27 UTC

incubator-ponymail git commit: make sure we don't get the same color twice in a row

Repository: incubator-ponymail
Updated Branches:
  refs/heads/coffee-and-cake d41125a14 -> 3861a6b80


make sure we don't get the same color twice in a row


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

Branch: refs/heads/coffee-and-cake
Commit: 3861a6b80ec57af90d2fb17c185f9c38a76ddd8a
Parents: d41125a
Author: Daniel Gruno <hu...@apache.org>
Authored: Mon Sep 5 17:47:15 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Mon Sep 5 17:47:15 2016 +0200

----------------------------------------------------------------------
 site/js/coffee/email_display_threaded.coffee | 6 ++++++
 site/js/ponymail-coffee.js                   | 7 +++++++
 2 files changed, 13 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/3861a6b8/site/js/coffee/email_display_threaded.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/email_display_threaded.coffee b/site/js/coffee/email_display_threaded.coffee
index 015e77b..233e599 100644
--- a/site/js/coffee/email_display_threaded.coffee
+++ b/site/js/coffee/email_display_threaded.coffee
@@ -43,8 +43,14 @@ class ThreadedEmailDisplay extends BasicEmailDisplay
         bodyplace = new HTML('div', {id: "placeholder_#{@mid}_#{thread.tid}", class:"email_boxed"})
         
         ### Assign a random color to the left ###
+        @prevColor = @prevColor || ""
         bcolors = ['#C93F20', '#20C94A', '#2063C9', '#C9AA20', '#AD20C9', '#99C920', '#20C9C3']
         bcolor = bcolors[Math.round(Math.random()*bcolors.length)]
+        ### ensure we don't get the same color twice in a row ###
+        while bcolor == @prevColor
+            bcolor = bcolors[Math.round(Math.random()*bcolors.length)]
+        @prevColor = bcolor
+        
         bodyplace.style.borderLeft = "4px solid " + bcolor
         
         replyplace = new HTML('div', {

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/3861a6b8/site/js/ponymail-coffee.js
----------------------------------------------------------------------
diff --git a/site/js/ponymail-coffee.js b/site/js/ponymail-coffee.js
index 7d0dce4..427fea1 100644
--- a/site/js/ponymail-coffee.js
+++ b/site/js/ponymail-coffee.js
@@ -883,8 +883,15 @@ ThreadedEmailDisplay = (function(superClass) {
     });
 
     /* Assign a random color to the left */
+    this.prevColor = this.prevColor || "";
     bcolors = ['#C93F20', '#20C94A', '#2063C9', '#C9AA20', '#AD20C9', '#99C920', '#20C9C3'];
     bcolor = bcolors[Math.round(Math.random() * bcolors.length)];
+
+    /* ensure we don't get the same color twice in a row */
+    while (bcolor === this.prevColor) {
+      bcolor = bcolors[Math.round(Math.random() * bcolors.length)];
+    }
+    this.prevColor = bcolor;
     bodyplace.style.borderLeft = "4px solid " + bcolor;
     replyplace = new HTML('div', {
       id: "thread_replies_" + this.mid + "_" + thread.tid,