currentweather, weatherforecast, changed option of decimal comma to any decimal symbol

This commit is contained in:
Torben Tigges
2017-12-31 01:15:59 +01:00
parent 46c0e14d67
commit df0515cebf
5 changed files with 45 additions and 29 deletions

View File

@@ -37,7 +37,7 @@ The following properties can be configured:
| `updateInterval` | How often does the content needs to be fetched? (Milliseconds) <br><br> **Possible values:** `1000` - `86400000` <br> **Default value:** `600000` (10 minutes)
| `animationSpeed` | Speed of the update animation. (Milliseconds) <br><br> **Possible values:**`0` - `5000` <br> **Default value:** `1000` (1 second)
| `lang` | The language of the days. <br><br> **Possible values:** `en`, `nl`, `ru`, etc ... <br> **Default value:** uses value of _config.language_
| `decimalComma` | Whether or not to show a decimal comma instead of a decimal point for temperature values.<br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
| `decimalSymbol` | The decimal symbol to use.<br><br> **Possible values:** `.`, `,` or any other symbol.<br> **Default value:** `.`
| `fade` | Fade the future events to black. (Gradient) <br><br> **Possible values:** `true` or `false` <br> **Default value:** `true`
| `fadePoint` | Where to start fade? <br><br> **Possible values:** `0` (top of the list) - `1` (bottom of list) <br> **Default value:** `0.25`
| `initialLoadDelay` | The initial delay before loading. If you have multiple modules that use the same API key, you might want to delay one of the requests. (Milliseconds) <br><br> **Possible values:** `1000` - `5000` <br> **Default value:** `2500` (2.5 seconds delay. This delay is used to keep the OpenWeather API happy.)

View File

@@ -21,7 +21,7 @@ Module.register("weatherforecast",{
animationSpeed: 1000,
timeFormat: config.timeFormat,
lang: config.language,
decimalComma: false,
decimalSymbol: ".",
fade: true,
fadePoint: 0.25, // Start on 1/4th of the list.
colored: false,
@@ -156,23 +156,17 @@ Module.register("weatherforecast",{
}
}
if (this.config.decimalSymbol === "" || this.config.decimalSymbol === " ") {
this.config.decimalSymbol = ".";
}
var maxTempCell = document.createElement("td");
if (this.config.decimalComma) {
maxTempCell.innerHTML = forecast.maxTemp.replace(".",",") + degreeLabel;
}
else {
maxTempCell.innerHTML = forecast.maxTemp + degreeLabel;
}
maxTempCell.innerHTML = forecast.maxTemp.replace(".", this.config.decimalSymbol) + degreeLabel;
maxTempCell.className = "align-right bright max-temp";
row.appendChild(maxTempCell);
var minTempCell = document.createElement("td");
if (this.config.decimalComma) {
minTempCell.innerHTML = forecast.minTemp.replace(".",",") + degreeLabel;
}
else {
minTempCell.innerHTML = forecast.minTemp + degreeLabel;
}
minTempCell.innerHTML = forecast.minTemp.replace(".", this.config.decimalSymbol) + degreeLabel;
minTempCell.className = "align-right min-temp";
row.appendChild(minTempCell);