display mtime_age in webclient

This commit is contained in:
Matthew Hodgson 2014-08-16 01:07:23 +01:00
parent 4068339770
commit 207ef144c5
3 changed files with 33 additions and 10 deletions

View file

@ -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);