more reasonable waylength digits display

This commit is contained in:
following
2013-05-08 19:49:29 +02:00
parent 71698ef152
commit 5c9c64f984
3 changed files with 17 additions and 2 deletions
+1 -1
View File
@@ -185,7 +185,7 @@
<img src="resource2/{$opt.template.style}/images/viewcache/time.png" class="icon16" alt="" title="" align="middle" />&nbsp;{t}Time required{/t}: {$cache.searchtime|format_hour} h
{/if}
{if $cache.waylength>0}
<img src="resource2/{$opt.template.style}/images/viewcache/arrow_roundtrip.png" class="icon16" alt="" title="" align="middle" />&nbsp;{t}Waylength{/t}: {$cache.waylength|sprintf:'%01.2f'} km
<img src="resource2/{$opt.template.style}/images/viewcache/arrow_roundtrip.png" class="icon16" alt="" title="" align="middle" />&nbsp;{t}Waylength{/t}: {$cache.waylength} km
{/if}
{if $cache.searchtime>0 || $cache.waylength>0}<br />{/if}
<img src="resource2/{$opt.template.style}/images/viewcache/date.png" class="icon16" alt="" title="" align="middle" />&nbsp;{if $cache.type==6}{t}Event date{/t}{else}{t}Hidden at{/t}{/if}: {$cache.datehidden|date_format:$opt.format.datelong}<br />
@@ -84,7 +84,7 @@
<nobr>{t}Time required{/t}: {$cache.searchtime|format_hour} h</nobr>
{/if}
{if $cache.waylength>0}
<nobr>{t}Distance{/t}: {$cache.waylength|sprintf:'%01.2f'} km</nobr>
<nobr>{t}Distance{/t}: {$cache.waylength} km</nobr>
{/if}
{if $cache.searchtime>0 || $cache.waylength>0}<br />{/if}
{if $cache.status!=1}
+15
View File
@@ -146,6 +146,21 @@ function getChildWaypoints($cacheid)
if ($rCache === false)
$tpl->error(ERROR_CACHE_NOT_EXISTS);
// format waylength
if ($rCache['waylength'] < 5)
if (round($rCache['waylength'],2) != round($rCache['waylength'],1))
$digits = 2;
else
$digits = 1;
else if ($rCache['waylength'] < 50)
if (round($rCache['waylength'],1) != round($rCache['waylength'],0))
$digits = 1;
else
$digits = 0;
else
$digits = 0;
$rCache['waylength'] = sprintf('%.'.$digits.'f', $rCache['waylength']);
// not published?
if ($rCache['status'] == 5)
{