diff options
author | Matthew Hodgson <matthew@matrix.org> | 2014-08-16 01:07:23 +0100 |
---|---|---|
committer | Matthew Hodgson <matthew@matrix.org> | 2014-08-16 01:07:23 +0100 |
commit | 207ef144c5e5d7db16d42c6f15b8efc33a354e92 (patch) | |
tree | 861fab2f8f8d08fe3afb3c85caaf199814fd3877 /webclient/app.js | |
parent | slightly hacky but more functional infinite scrolling (diff) | |
download | synapse-207ef144c5e5d7db16d42c6f15b8efc33a354e92.tar.xz |
display mtime_age in webclient
Diffstat (limited to '')
-rw-r--r-- | webclient/app.js | 20 |
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); |