Michael Hall has proposed merging lp:~mhall119/loco-directory/fixes-620869 into 
lp:loco-directory.

Requested reviews:
  loco-directory-dev (loco-directory-dev)
Related bugs:
  #620869 Dates of messages not shown
  https://bugs.launchpad.net/bugs/620869


Adds Adnane's addition of relative time to the LD copy of twidenash, also 
styles to be similar to Gwibber.
-- 
https://code.launchpad.net/~mhall119/loco-directory/fixes-620869/+merge/36895
Your team loco-directory-dev is requested to review the proposed merge of 
lp:~mhall119/loco-directory/fixes-620869 into lp:loco-directory.
=== modified file 'loco_directory/media/css/twidenash.css'
--- loco_directory/media/css/twidenash.css	2010-09-24 22:42:09 +0000
+++ loco_directory/media/css/twidenash.css	2010-09-28 17:25:58 +0000
@@ -30,3 +30,8 @@
     font-weight:      bold;
 }
 
+ul.twidenash li .time {
+    font-size: 0.75em;
+    color: #555;
+}
+

=== modified file 'loco_directory/media/js/twidenash.js'
--- loco_directory/media/js/twidenash.js	2010-08-22 19:12:02 +0000
+++ loco_directory/media/js/twidenash.js	2010-09-28 17:25:58 +0000
@@ -76,16 +76,34 @@
                 var img = document.createElement("img");
                 img.src = twidenash.items[i].img;
                 img.width = 48;
+                var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
+                var delta = parseInt((relative_to.getTime() - twidenash.items[i].dt) / 1000);
+                var pluralize = function (singular, n) {
+                    return '' + n + ' ' + singular + (n == 1 ? '' : 's');
+                };
+                if(delta < 60) {
+                     date_msg = 'less than a minute ago ';
+                } else if(delta < (45*60)) {
+                    date_msg = 'about ' + pluralize("minute", parseInt(delta / 60)) + ' ago ';
+                } else if(delta < (24*60*60)) {
+                    date_msg = 'about ' + pluralize("hour", parseInt(delta / 3600)) + ' ago ';
+                } else {
+                    date_msg = 'about ' + pluralize("day", parseInt(delta / 86400)) + ' ago ';
+                }
                 var span = document.createElement("span");
                 span.className = 'comment';
                 var nick = document.createElement("span");
                 nick.className = 'nick';
-                nick.appendChild(document.createTextNode(twidenash.items[i].user + 
-                    ": "));
+                nick.appendChild(document.createTextNode(twidenash.items[i].user));
+                var time = document.createElement("span");
+                time.className = 'time';
+                time.appendChild(document.createTextNode(" ( "+ date_msg +" ) "));
+                
                 var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi;
                 span.innerHTML = twidenash.items[i].text.replace(exp,"<a href='$1' target='_blank'>$1</a>");
                 li.appendChild(img);
                 li.appendChild(nick);
+                li.appendChild(time);
                 li.appendChild(span);
                 ul.appendChild(li);
                 twidenash.printed++;

_______________________________________________
Mailing list: https://launchpad.net/~loco-directory-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~loco-directory-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to