From 1c551e4a998578ed61d86dd99515b77c1190adfe Mon Sep 17 00:00:00 2001 From: hackyminer Date: Thu, 5 Apr 2018 18:41:32 +0900 Subject: [PATCH] src-lite: totalDifficultyFilter filter added --- src-lite/js/filters.js | 15 +++++++++++++++ src-lite/views/index.jade | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src-lite/js/filters.js b/src-lite/js/filters.js index 6ab886e..f1d8ced 100644 --- a/src-lite/js/filters.js +++ b/src-lite/js/filters.js @@ -54,6 +54,21 @@ angular.module('netStatsApp.filters', []) return $sce.trustAsHtml('' + filter('number')(result.toFixed(1)) + ' ' + unit + 'H/s'); }; }]) +.filter('totalDifficultyFilter', function() { + return function(hashes) { + var result = hashes; + var units = ['', 'K', 'M', 'G', 'T', 'P']; + var unit = ''; + + for(var i = 1; result > 1000; i++) + { + result /= 1000; + unit = units[i]; + } + + return result.toFixed(2) + ' ' + unit + 'H'; + }; +}) .filter('nodeVersion', function($sce) { return function(version) { if(typeof version !== 'undefined') diff --git a/src-lite/views/index.jade b/src-lite/views/index.jade index 37276d4..50e7c2f 100644 --- a/src-lite/views/index.jade +++ b/src-lite/views/index.jade @@ -52,7 +52,7 @@ block content div.big-details-holder span.small-title difficulty span.big-details - span.small-hash {{ lastDifficulty | number }} + span.small-hash {{ lastDifficulty | totalDifficultyFilter }} div.clearfix div.clearfix