mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-17 00:59:29 -07:00
index.ejs cleanup
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// *********************************** unit conversions ***********************
|
||||
|
||||
const round2 = (value, decimals) => Number(`${Math.round(`${value}e${decimals}`)}e-${decimals}`);
|
||||
const round2 = (value, decimals) => Math.trunc(value * 10 ** decimals) / 10 ** decimals;
|
||||
|
||||
const kphToMph = (Kph) => Math.round(Kph / 1.60934);
|
||||
const celsiusToFahrenheit = (Celsius) => Math.round((Celsius * 9) / 5 + 32);
|
||||
@@ -14,4 +14,5 @@ export {
|
||||
kilometersToMiles,
|
||||
metersToFeet,
|
||||
pascalToInHg,
|
||||
round2,
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ class WeatherDisplay {
|
||||
if (this.elemId === 'progress') return false;
|
||||
|
||||
// get the saved status of the checkbox
|
||||
let savedStatus = window.localStorage.getItem(`${this.elemId}Enabled`);
|
||||
let savedStatus = window.localStorage.getItem(`display-enabled: ${this.elemId}`);
|
||||
if (savedStatus === null) savedStatus = defaultEnabled;
|
||||
if (savedStatus === 'true' || savedStatus === true) {
|
||||
this.enabled = true;
|
||||
@@ -61,7 +61,7 @@ class WeatherDisplay {
|
||||
}
|
||||
|
||||
// refresh (or initially store the state of the checkbox)
|
||||
window.localStorage.setItem(`${this.elemId}Enabled`, this.enabled);
|
||||
window.localStorage.setItem(`display-enabled: ${this.elemId}`, this.enabled);
|
||||
|
||||
// create a checkbox in the selected displays area
|
||||
const checkbox = document.createElement('template');
|
||||
@@ -77,7 +77,7 @@ class WeatherDisplay {
|
||||
// update the state
|
||||
this.enabled = e.target.checked;
|
||||
// store the value for the next load
|
||||
window.localStorage.setItem(`${this.elemId}Enabled`, this.enabled);
|
||||
window.localStorage.setItem(`display-enabled: ${this.elemId}`, this.enabled);
|
||||
// calling get data will update the status and actually get the data if we're set to enabled
|
||||
this.getData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user