Skip to content

Commit ce1ed83

Browse files
jyoo980nickswalker
authored andcommitted
Avoiding use of magic numbers
1 parent 9c06b5a commit ce1ed83

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

pages/routes.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ <h1 class="visually-hidden">{{ page.title }}</h1>
125125

126126
Tabulator.registerModule([EditModule, FormatModule, InteractionModule, MutatorModule, ResizeColumnsModule, ResizeTableModule, SortModule, SelectRowModule, FilterModule]);
127127

128+
const KmPerMi = 1.609
129+
const MPerFeet = 3.28084
128130
let searched = false
129131
document.addEventListener("DOMContentLoaded", () => {
130132
let table = new Tabulator("#routes table", {
@@ -163,7 +165,7 @@ <h1 class="visually-hidden">{{ page.title }}</h1>
163165
const mi = cell.getValue();
164166
if (typeof mi !== 'number') return '';
165167
const unit = (localStorage.getItem('rcr-dist-unit') === 'km') ? 'km' : 'mi';
166-
return (unit === 'km' ? mi * 1.609 : mi).toFixed(1);
168+
return (unit === 'km' ? mi * KmPerMi : mi).toFixed(1);
167169
}},
168170
{title: "Ascent",
169171
titleFormatter: () => {
@@ -175,7 +177,7 @@ <h1 class="visually-hidden">{{ page.title }}</h1>
175177
const m = cell.getValue();
176178
if (typeof m !== 'number') return '';
177179
const unit = (localStorage.getItem('rcr-elev-unit') === 'm') ? 'm' : 'ft';
178-
return Math.round(unit === 'm' ? m : m * 3.28084);
180+
return Math.round(unit === 'm' ? m : m * MPerFeet);
179181
}},
180182
{title: "Descent",
181183
titleFormatter: () => {
@@ -187,7 +189,7 @@ <h1 class="visually-hidden">{{ page.title }}</h1>
187189
const m = cell.getValue();
188190
if (typeof m !== 'number') return '';
189191
const unit = (localStorage.getItem('rcr-elev-unit') === 'm') ? 'm' : 'ft';
190-
return Math.round(unit === 'm' ? m : m * 3.28084);
192+
return Math.round(unit === 'm' ? m : m * MPerFeet);
191193
}},
192194
{title: "Surface", field: "surface_type",
193195
mutator: function(value, data) {

0 commit comments

Comments
 (0)