From 177b8165352d32dd18ae2f3620b49be1338fbddd Mon Sep 17 00:00:00 2001 From: kanoi Date: Fri, 28 Oct 2016 08:41:56 +1100 Subject: [PATCH] php - colour the monthly block count using luck limits: 0.9 to 1.1 --- pool/page_blocks.php | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/pool/page_blocks.php b/pool/page_blocks.php index cff64aa6..f6b59547 100644 --- a/pool/page_blocks.php +++ b/pool/page_blocks.php @@ -69,6 +69,41 @@ function pctcolour($pct) return array($fg, $bg); } # +function mthcolour($luck) +{ + if ($luck == 1.0) + { + $fg = 'white'; + $bg = 'black'; + } + else if ($luck > 1.0) + { + // 1.0 .. 1.1 (> 1.1 = max) + $grn = ($luck - 1.0) * 2550.0; + if ($grn > 255) + $grn = 255; + if ($grn < 0) + $grn = 0; + if ($grn > 190) + $fg = 'blue'; + else + $fg = 'white'; + $bg = sprintf("#00%02x00", $grn); + } + else + { + // 0.9 .. 1.0 (< 0.9 = max) + $red = (1.0 - $luck) * 2550.0; + if ($red > 255) + $red = 255; + if ($red < 0) + $red = 0; + $fg = 'white'; + $bg = sprintf("#%02x0000", $red); + } + return array($fg, $bg); +} +# function statstable($poolfee, $ans, $data) { if ($ans['STATUS'] != 'ok' or !isset($ans['s_rows']) or $ans['s_rows'] < 1) @@ -203,18 +238,20 @@ function monthtable($poolfee, $ans, $limit) $bcol = 'darkgreen'; $md = number_format(100 * $bdiffratio / $bcount, 2); $mr = number_format(100 * $btxn / $bcount, 2); - $ml = number_format(100 * $bcount / $bdiffratio, 2); + $ml = $bcount / $bdiffratio; + $mldsp = number_format(100 * $ml, 2); $oa = (100 - $poolfee) * ($bcount / $bdiffratio) * ($btxn / $bcount); $odsp = number_format($oa, 2); + list($fg, $bg) = mthcolour($ml); $pg .= ""; $pg .= "$name$dots"; $pg .= "${phrdsp}Hs"; - $pg .= "$bcount"; + $pg .= "$bcount"; $pg .= "$exc"; $pg .= "$md%"; $pg .= "$mr%"; - $pg .= "$ml%"; + $pg .= "$mldsp%"; $pg .= "$odsp%"; $pg .= "\n";