From ad42e1c38919d943e8ceee700d9a48d954e63229 Mon Sep 17 00:00:00 2001 From: Marian Oancea Date: Thu, 5 Feb 2015 03:33:58 +0200 Subject: [PATCH] added time filter --- config/nodes.default.js | 7 ++++++- public/js/filters.js | 17 +++++++++++++++++ views/index.jade | 4 ++-- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/config/nodes.default.js b/config/nodes.default.js index 513dc86..a4386c7 100644 --- a/config/nodes.default.js +++ b/config/nodes.default.js @@ -1,5 +1,10 @@ var nodes = [ - // { + // + // Duplicate this file and rename it to "nodes.js". + // It will be loaded as the main config file and + // will be ignored by git. Add nodes like the one below + // + // { // name: 'Readable name of the node', // type: 'C++/Go...', // rpcHost: 'your node IP here', diff --git a/public/js/filters.js b/public/js/filters.js index e42274d..11f0d0f 100644 --- a/public/js/filters.js +++ b/public/js/filters.js @@ -49,4 +49,21 @@ angular.module('netStatsApp.filters', []) return function(current, best) { return (best - current <= 1 ? '' : (best - current > 1 && best - current < 4 ? 'text-warning' : 'text-danger')); }; +}) +.filter('timeClass', function() { + return function(timestamp) { + var time = Math.floor((new Date()).getTime() / 1000); + var diff = time - timestamp; + + if(diff <= 12) + return 'text-success'; + + if(diff <= 20) + return 'text-info'; + + if(diff <= 30) + return 'text-warning'; + + return 'text-danger'; + }; }); \ No newline at end of file diff --git a/views/index.jade b/views/index.jade index 3d8707c..8faa743 100644 --- a/views/index.jade +++ b/views/index.jade @@ -27,7 +27,7 @@ block content span.big-details {{"#" + bestBlock}} div.clearfix div.col-xs-6.stat-holder - div.row.big-info.blocktime.text-success + div.row.big-info.blocktime(class="{{ lastBlock | timeClass }}") div.pull-left.icon-full-width i.icon-time div.pull-left @@ -82,5 +82,5 @@ block content td(class="{{ node.stats.block.height | blockClass : bestBlock }}") {{'#' + node.stats.block.height}} td(class="{{ node.stats.block.height | blockClass : bestBlock }}").hidden-sm.hidden-xs span.small {{node.stats.block.hash}} - td(am-time-ago="node.stats.block.timestamp", am-preprocess="unix") + td(am-time-ago="node.stats.block.timestamp", am-preprocess="unix", class="{{ node.stats.block.timestamp | timeClass }}") td {{ node.stats.active ? '100%' : '0%' }}