[FIX] Better number formatting for est block time
This commit is contained in:
parent
a3cbd7dc8b
commit
3c29be6bc9
18
include/smarty/libs/plugins/modifier.seconds_to_hhmmss.php
Normal file
18
include/smarty/libs/plugins/modifier.seconds_to_hhmmss.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright 2010 MAPIX Technologies Ltd, UK, http://mapix.com/
|
||||
* @license http://en.wikipedia.org/wiki/BSD_licenses BSD License
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
function smarty_modifier_seconds_to_hhmmss($sec, $padHours = false) {
|
||||
$hms = "";
|
||||
$hours = intval(intval($sec) / 3600);
|
||||
$hms .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT). ':' : $hours. ':';
|
||||
$minutes = intval(($sec / 60) % 60);
|
||||
$hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';
|
||||
$seconds = intval($sec % 60);
|
||||
$hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
|
||||
return $hms;
|
||||
}
|
||||
@ -68,3 +68,16 @@ function number_format (number, decimals, dec_point, thousands_sep) {
|
||||
}
|
||||
return s.join(dec);
|
||||
}
|
||||
|
||||
Number.prototype.toHHMMSS = function () {
|
||||
var sec_num = parseInt(this, 10); // don't forget the second param
|
||||
var hours = Math.floor(sec_num / 3600);
|
||||
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
|
||||
var seconds = sec_num - (hours * 3600) - (minutes * 60);
|
||||
|
||||
if (hours < 10) {hours = "0"+hours;}
|
||||
if (minutes < 10) {minutes = "0"+minutes;}
|
||||
if (seconds < 10) {seconds = "0"+seconds;}
|
||||
var time = hours+':'+minutes+':'+seconds;
|
||||
return time;
|
||||
}
|
||||
|
||||
@ -117,9 +117,7 @@ $(document).ready(function(){
|
||||
$('#b-nextdiff').html('n/a');
|
||||
$('#b-nextdiffc').html(' No Estimates');
|
||||
}
|
||||
var minutes = Math.floor(data.getdashboarddata.data.pool.esttimeperblock / 60);
|
||||
var seconds = Math.floor(data.getdashboarddata.data.pool.esttimeperblock - minutes * 60);
|
||||
$('#b-esttimeperblock').html(minutes + " minutes " + seconds + " seconds"); // <- this needs some nicer format
|
||||
$('#b-esttimeperblock').html(data.getdashboarddata.data.pool.esttimeperblock.toString().toHHMMSS());
|
||||
$('#b-nblock').html(data.getdashboarddata.data.network.block);
|
||||
$('#b-roundprogress').html(number_format(parseFloat(data.getdashboarddata.data.pool.shares.progress).toFixed(2), 2) + "%");
|
||||
{/literal}{if $GLOBAL.config.payout_system != 'pps'}{literal }
|
||||
|
||||
@ -83,7 +83,7 @@
|
||||
</div>
|
||||
<div class="circle-tile-content lightblue">
|
||||
<div class="circle-tile-description text-faded">
|
||||
<p class="h5 up-more" id="b-esttimeperblock">{$NETWORK.EstTimePerBlock|seconds_to_words}</p>
|
||||
<p class="h5 up-more" id="b-esttimeperblock">{$NETWORK.EstTimePerBlock|seconds_to_hhmmss}</p>
|
||||
</div>
|
||||
<div class="circle-tile-number text-faded">
|
||||
<p class="h6">Est. Avg. Time per Block</p>
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
</div>
|
||||
<div class="col-md-spark">
|
||||
<i class="fa fa-clock-o fa-2x"></i>
|
||||
<p id="b-esttimeperblock" class="h5 font-bold m-t">{$NETWORK.EstTimePerBlock|seconds_to_words}</p>
|
||||
<p id="b-esttimeperblock" class="h5 font-bold m-t">{$NETWORK.EstTimePerBlock|seconds_to_hhmmss}</p>
|
||||
<p class="h6 text-muted">Est. Avg. Time per Block</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -83,7 +83,7 @@
|
||||
</div>
|
||||
<div class="circle-tile-content lightblue">
|
||||
<div class="circle-tile-description text-faded">
|
||||
<p class="h5" id="b-esttimeperblock">{$NETWORK.EstTimePerBlock|seconds_to_words}</p>
|
||||
<p class="h5" id="b-esttimeperblock">{$NETWORK.EstTimePerBlock|seconds_to_hhmmss}</p>
|
||||
</div>
|
||||
<div class="circle-tile-number text-faded">
|
||||
<p class="h6">Est. Avg. Time per Block</p>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user