summary refs log tree commit diff
path: root/webclient/app.js
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2014-08-16 01:07:23 +0100
committerMatthew Hodgson <matthew@matrix.org>2014-08-16 01:07:23 +0100
commit207ef144c5e5d7db16d42c6f15b8efc33a354e92 (patch)
tree861fab2f8f8d08fe3afb3c85caaf199814fd3877 /webclient/app.js
parentslightly hacky but more functional infinite scrolling (diff)
downloadsynapse-207ef144c5e5d7db16d42c6f15b8efc33a354e92.tar.xz
display mtime_age in webclient
Diffstat (limited to 'webclient/app.js')
-rw-r--r--webclient/app.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/webclient/app.js b/webclient/app.js
index 58d3942c65..3f4c5f30f8 100644
--- a/webclient/app.js
+++ b/webclient/app.js
@@ -94,6 +94,26 @@ matrixWebClient
             }
         };
     }])
+    .filter('duration', function() {
+        return function(time) {
+            if (!time) return;
+            var t = parseInt(time / 1000);
+            var s = t % 60;
+            var m = parseInt(t / 60) % 60;
+            var h = parseInt(t / (60 * 60)) % 24;
+            var d = parseInt(t / (60 * 60 * 24));
+            if (t < 60) {
+                return s + "s"
+            }
+            if (t < 60 * 60) {
+                return m + "m " + s + "s";
+            }
+            if (t < 24 * 60 * 60) {
+                return h + "h " + m + "m";
+            }
+            return d + "d " + h + "h";
+        }
+    })
     .filter('to_trusted', ['$sce', function($sce){
         return function(text) {
             return $sce.trustAsHtml(text);