diff --git a/js/app.js b/js/app.js index d0384ee8..0b597ba5 100644 --- a/js/app.js +++ b/js/app.js @@ -16,6 +16,13 @@ app = Sammy('#main', function (sam) { Handlebars.registerHelper('humanTime', function(time) { return Math.round(time) + 's'; }); + Handlebars.registerHelper('bitRate', function(bytes, time) { + var sizes = ['b', 'Kb', 'Mb', 'Gb', 'Tb']; + if (time == 0) return 'n/a'; + var bps = bytes / time * 8; + var i = parseInt(Math.floor(Math.log(bps) / Math.log(1024))); + return Math.round(bps / Math.pow(1024, i), 2) + ' ' + sizes[[i]] + '/s'; + }); // Look for supported type of storage to use diff --git a/views/monitor.ms b/views/monitor.ms index 704e32d7..c30e9aee 100644 --- a/views/monitor.ms +++ b/views/monitor.ms @@ -149,17 +149,17 @@
Rx | -{{humanSize rx}} | +{{bitRate rx time_since_update}} | {{humanSize cumulative_rx}} (cumulative) | |
Tx | -{{humanSize tx}} | +{{bitRate tx time_since_update}} | {{humanSize cumulative_tx}} (cumulative) | |
Cx | -{{humanSize cx}} | +Rx + Tx | +{{bitRate cx time_since_update}} | {{humanSize cumulative_cx}} (cumulative) |