SidePanel: basic weather display
This commit is contained in:
parent
8cb519e5f4
commit
ce66b99cee
2 changed files with 75 additions and 7 deletions
|
|
@ -145,4 +145,53 @@ Singleton {
|
|||
function errorCallback(message) {
|
||||
console.error(message)
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
function weatherSymbolFromCode(code) {
|
||||
if (code === 0)
|
||||
return "sunny"
|
||||
if (code === 1 || code === 2)
|
||||
return "partly_cloudy_day"
|
||||
if (code === 3)
|
||||
return "cloud"
|
||||
if (code >= 45 && code <= 48)
|
||||
return "foggy"
|
||||
if (code >= 51 && code <= 67)
|
||||
return "rainy"
|
||||
if (code >= 71 && code <= 77)
|
||||
return "weather_snowy"
|
||||
if (code >= 80 && code <= 82)
|
||||
return "rainy"
|
||||
if (code >= 95 && code <= 99)
|
||||
return "thunderstorm"
|
||||
return "cloud"
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
function weatherDescriptionFromCode(code) {
|
||||
if (code === 0)
|
||||
return "Clear sky"
|
||||
if (code === 1)
|
||||
return "Mainly clear"
|
||||
if (code === 2)
|
||||
return "Partly cloudy"
|
||||
if (code === 3)
|
||||
return "Overcast"
|
||||
if (code === 45 || code === 48)
|
||||
return "Fog"
|
||||
if (code >= 51 && code <= 67)
|
||||
return "Drizzle"
|
||||
if (code >= 71 && code <= 77)
|
||||
return "Snow"
|
||||
if (code >= 80 && code <= 82)
|
||||
return "Rain showers"
|
||||
if (code >= 95 && code <= 99)
|
||||
return "Thunderstorm"
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
function celsiusToFahrenheit(celsius) {
|
||||
return 32 + celsius * 1.8
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue