Merge pull request #200 from rkflx/rkflx/polish-statistics-bar
Polish formatting and behaviour of track statistics bar
This commit is contained in:
commit
8edf0f7906
3 changed files with 100 additions and 48 deletions
70
index.html
70
index.html
|
|
@ -927,10 +927,10 @@
|
|||
Distance
|
||||
</div>
|
||||
<p class="stats-label">
|
||||
<span id="distance">0</span>
|
||||
<span id="distance">-</span>
|
||||
<abbr
|
||||
data-i18n="[title]footer.kilometer;footer.kilometer-abbrev"
|
||||
title="kilometer"
|
||||
title="kilometers"
|
||||
>km</abbr
|
||||
>
|
||||
</p>
|
||||
|
|
@ -943,54 +943,72 @@
|
|||
Travel time
|
||||
</div>
|
||||
<p class="stats-label">
|
||||
<span id="totaltime">0</span>
|
||||
<span id="totaltime">-</span>
|
||||
<abbr
|
||||
data-i18n="[title]footer.minutes;footer.minutes-abbrev"
|
||||
title="minutes"
|
||||
>min</abbr
|
||||
data-i18n="[title]footer.hours;footer.hours-abbrev"
|
||||
title="hours"
|
||||
>h</abbr
|
||||
>
|
||||
</p>
|
||||
</li>
|
||||
<li hidden>
|
||||
<div
|
||||
class="text-muted small hidden-sm-down"
|
||||
data-i18n="footer.total-energy"
|
||||
>
|
||||
Total Energy (per 100km)
|
||||
<div class="text-muted small hidden-sm-down">
|
||||
<span data-i18n="footer.total-energy"
|
||||
>Total Energy</span
|
||||
>
|
||||
|
|
||||
<span data-i18n="footer.energy-per-100km"
|
||||
>Energy per 100 km</span
|
||||
>
|
||||
</div>
|
||||
<p class="stats-label">
|
||||
<span id="totalenergy">0 (0)</span>
|
||||
<span id="totalenergy">-</span>
|
||||
<abbr
|
||||
data-i18n="[title]footer.kilowatthour;footer.kilowatthour-abbrev"
|
||||
title="kilowatt hour"
|
||||
title="kilowatt hours"
|
||||
>kWh</abbr
|
||||
>
|
||||
| <span id="meanenergy">-</span>
|
||||
<abbr
|
||||
data-i18n="[title]footer.kilowatthour;footer.kilowatthour-abbrev"
|
||||
title="kilowatt hours"
|
||||
>kWh</abbr
|
||||
>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<div
|
||||
class="text-muted small hidden-sm-down"
|
||||
data-i18n="footer.ascend"
|
||||
>
|
||||
Ascend (Plain ascend)
|
||||
<div class="text-muted small hidden-sm-down">
|
||||
<span data-i18n="footer.ascend">Ascend</span> |
|
||||
<span data-i18n="footer.plain-ascend"
|
||||
>Plain ascend</span
|
||||
>
|
||||
</div>
|
||||
<p class="stats-label">
|
||||
<span id="ascend">0 (0)</span>
|
||||
<span id="ascend">-</span>
|
||||
<abbr
|
||||
data-i18n="[title]footer.meter;footer.meter-abbrev"
|
||||
title="meter"
|
||||
title="meters"
|
||||
>m</abbr
|
||||
>
|
||||
| <span id="plainascend">-</span>
|
||||
<abbr
|
||||
data-i18n="[title]footer.meter;footer.meter-abbrev"
|
||||
title="meters"
|
||||
>m</abbr
|
||||
>
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<div
|
||||
class="text-muted small hidden-sm-down"
|
||||
data-i18n="footer.cost"
|
||||
>
|
||||
Cost (Mean cost factor)
|
||||
<div class="text-muted small hidden-sm-down">
|
||||
<span data-i18n="footer.cost">Cost</span> |
|
||||
<span data-i18n="footer.mean-cost-factor"
|
||||
>Mean cost factor</span
|
||||
>
|
||||
</div>
|
||||
<p class="stats-label"><span id="cost">- (-)</span></p>
|
||||
<p class="stats-label">
|
||||
<span id="cost">-</span> |
|
||||
<span id="meancostfactor">-</span>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +1,61 @@
|
|||
BR.TrackStats = L.Class.extend({
|
||||
update: function(polyline, segments) {
|
||||
if (segments.length == 0) {
|
||||
$('#distance').html('-');
|
||||
$('#distance').attr('title', '');
|
||||
$('#ascend').html('-');
|
||||
$('#plainascend').html('-');
|
||||
$('#cost').html('-');
|
||||
$('#meancostfactor').html('-');
|
||||
$('#totaltime').html('-');
|
||||
$('#totalenergy').html('-');
|
||||
$('#meanenergy').html('-');
|
||||
return;
|
||||
}
|
||||
|
||||
var stats = this.calcStats(polyline, segments),
|
||||
length1 = L.Util.formatNum(stats.trackLength / 1000, 1),
|
||||
length3 = L.Util.formatNum(stats.trackLength / 1000, 3),
|
||||
length1 = L.Util.formatNum(
|
||||
stats.trackLength / 1000,
|
||||
1
|
||||
).toLocaleString(),
|
||||
length3 = L.Util.formatNum(
|
||||
stats.trackLength / 1000,
|
||||
3
|
||||
).toLocaleString(),
|
||||
formattedAscend = stats.filteredAscend.toLocaleString(),
|
||||
formattedPlainAscend = stats.plainAscend.toLocaleString(),
|
||||
formattedCost = stats.cost.toLocaleString(),
|
||||
meanCostFactor = stats.trackLength
|
||||
? L.Util.formatNum(stats.cost / stats.trackLength, 2)
|
||||
: '',
|
||||
formattedTime = L.Util.formatNum(stats.totalTime / 60, 1),
|
||||
formattedEnergy = L.Util.formatNum(stats.totalEnergy / 3600000, 2),
|
||||
? L.Util.formatNum(
|
||||
stats.cost / stats.trackLength,
|
||||
2
|
||||
).toLocaleString()
|
||||
: '0',
|
||||
formattedTime =
|
||||
Math.trunc(stats.totalTime / 3600) +
|
||||
':' +
|
||||
('0' + Math.trunc((stats.totalTime % 3600) / 60)).slice(-2),
|
||||
formattedEnergy = L.Util.formatNum(
|
||||
stats.totalEnergy / 3600000,
|
||||
2
|
||||
).toLocaleString(),
|
||||
meanEnergy = stats.trackLength
|
||||
? L.Util.formatNum(
|
||||
stats.totalEnergy / 36 / stats.trackLength,
|
||||
2
|
||||
)
|
||||
: '';
|
||||
).toLocaleString()
|
||||
: '0';
|
||||
|
||||
$('#distance').html(length1);
|
||||
// alternative 3-digit format down to meters as tooltip
|
||||
$('#distance').attr('title', length3 + ' km');
|
||||
$('#ascend').html(
|
||||
stats.filteredAscend + ' (' + stats.plainAscend + ')'
|
||||
);
|
||||
$('#cost').html(stats.cost + ' (' + meanCostFactor + ')');
|
||||
$('#ascend').html(formattedAscend);
|
||||
$('#plainascend').html(formattedPlainAscend);
|
||||
$('#cost').html(formattedCost);
|
||||
$('#meancostfactor').html(meanCostFactor);
|
||||
$('#totaltime').html(formattedTime);
|
||||
$('#totalenergy').html(formattedEnergy + ' (' + meanEnergy + ')');
|
||||
|
||||
$('#totalenergy').html(formattedEnergy);
|
||||
$('#meanenergy').html(meanEnergy);
|
||||
document.getElementById(
|
||||
'totaltime'
|
||||
).parentElement.parentElement.hidden = !stats.totalTime;
|
||||
|
|
|
|||
|
|
@ -33,18 +33,21 @@
|
|||
"trackname": "Name"
|
||||
},
|
||||
"footer": {
|
||||
"ascend": "Ascend (Plain ascend)",
|
||||
"cost": "Cost (Mean cost factor)",
|
||||
"ascend": "Ascend",
|
||||
"plain-ascend": "Plain ascend",
|
||||
"cost": "Cost",
|
||||
"mean-cost-factor": "Mean cost factor",
|
||||
"distance": "Distance",
|
||||
"kilometer": "kilometer",
|
||||
"kilometer": "kilometers",
|
||||
"kilometer-abbrev": "km",
|
||||
"kilowatthour": "kilowatt hour",
|
||||
"kilowatthour": "kilowatt hours",
|
||||
"kilowatthour-abbrev": "kWh",
|
||||
"meter": "meter",
|
||||
"meter": "meters",
|
||||
"meter-abbrev": "m",
|
||||
"minutes": "minutes",
|
||||
"minutes-abbrev": "min",
|
||||
"total-energy": "Total Energy (per 100km)",
|
||||
"hours": "hours",
|
||||
"hours-abbrev": "h",
|
||||
"total-energy": "Total Energy",
|
||||
"energy-per-100km": "Energy per 100 km",
|
||||
"travel-time": "Travel time"
|
||||
},
|
||||
"layers": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue