|
|
@ -71,6 +71,7 @@ const WEATHER_REFRESH_INTERVAL_CURRENT = 'refresh-interval-current'; |
|
|
|
const WEATHER_REFRESH_INTERVAL_FORECAST = 'refresh-interval-forecast'; |
|
|
|
const WEATHER_REFRESH_INTERVAL_FORECAST = 'refresh-interval-forecast'; |
|
|
|
const WEATHER_CENTER_FORECAST_KEY = 'center-forecast'; |
|
|
|
const WEATHER_CENTER_FORECAST_KEY = 'center-forecast'; |
|
|
|
const WEATHER_DAYS_FORECAST = 'days-forecast'; |
|
|
|
const WEATHER_DAYS_FORECAST = 'days-forecast'; |
|
|
|
|
|
|
|
const WEATHER_DECIMAL_PLACES = 'decimal-places'; |
|
|
|
const WEATHER_OWM_API_KEY = 'appid'; |
|
|
|
const WEATHER_OWM_API_KEY = 'appid'; |
|
|
|
|
|
|
|
|
|
|
|
//URL
|
|
|
|
//URL
|
|
|
@ -621,6 +622,18 @@ const WeatherMenuButton = new Lang.Class({ |
|
|
|
this._settings.set_int(WEATHER_DAYS_FORECAST, v); |
|
|
|
this._settings.set_int(WEATHER_DAYS_FORECAST, v); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get _decimal_places() { |
|
|
|
|
|
|
|
if (!this._settings) |
|
|
|
|
|
|
|
this.loadConfig(); |
|
|
|
|
|
|
|
return this._settings.get_int(WEATHER_DECIMAL_PLACES); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set _decimal_places(v) { |
|
|
|
|
|
|
|
if (!this._settings) |
|
|
|
|
|
|
|
this.loadConfig(); |
|
|
|
|
|
|
|
this._settings.set_int(WEATHER_DECIMAL_PLACES, v); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
get _appid() { |
|
|
|
get _appid() { |
|
|
|
if (!this._settings) |
|
|
|
if (!this._settings) |
|
|
|
this.loadConfig(); |
|
|
|
this.loadConfig(); |
|
|
@ -1020,35 +1033,35 @@ weather-storm.png = weather-storm-symbolic.svg |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
toFahrenheit: function(t) { |
|
|
|
toFahrenheit: function(t) { |
|
|
|
return String(Math.round(((Number(t) * 1.8) + 32) * 10) / 10); |
|
|
|
return ((Number(t) * 1.8) + 32).toFixed(this._decimal_places); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
toKelvin: function(t) { |
|
|
|
toKelvin: function(t) { |
|
|
|
return String(Math.round((Number(t) + 273.15) * 10) / 10); |
|
|
|
return (Number(t) + 273.15).toFixed(this._decimal_places); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
toRankine: function(t) { |
|
|
|
toRankine: function(t) { |
|
|
|
return String(Math.round(((Number(t) * 1.8) + 491.67) * 10) / 10); |
|
|
|
return ((Number(t) * 1.8) + 491.67).toFixed(this._decimal_places); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
toReaumur: function(t) { |
|
|
|
toReaumur: function(t) { |
|
|
|
return String(Math.round((Number(t) * 0.8) * 10) / 10); |
|
|
|
return (Number(t) * 0.8).toFixed(this._decimal_places); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
toRoemer: function(t) { |
|
|
|
toRoemer: function(t) { |
|
|
|
return String(Math.round(((Number(t) * 21 / 40) + 7.5) * 10) / 10); |
|
|
|
return ((Number(t) * 21 / 40) + 7.5).toFixed(this._decimal_places); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
toDelisle: function(t) { |
|
|
|
toDelisle: function(t) { |
|
|
|
return String(Math.round(((100 - Number(t)) * 1.5) * 10) / 10); |
|
|
|
return ((100 - Number(t)) * 1.5).toFixed(this._decimal_places); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
toNewton: function(t) { |
|
|
|
toNewton: function(t) { |
|
|
|
return String(Math.round((Number(t) - 0.33) * 10) / 10); |
|
|
|
return (Number(t) - 0.33).toFixed(this._decimal_places); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
toInHg: function(p /*, t*/ ) { |
|
|
|
toInHg: function(p /*, t*/ ) { |
|
|
|
return Math.round((p / 33.86530749) * 10) / 10; |
|
|
|
return (p / 33.86530749).toFixed(this._decimal_places); |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
toBeaufort: function(w, t) { |
|
|
|
toBeaufort: function(w, t) { |
|
|
@ -1231,42 +1244,42 @@ weather-storm.png = weather-storm-symbolic.svg |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherPressureUnits.hPa: |
|
|
|
case WeatherPressureUnits.hPa: |
|
|
|
pressure = Math.round(pressure * 10) / 10; |
|
|
|
pressure = pressure.toFixed(this._decimal_places);; |
|
|
|
pressure_unit = "hPa"; |
|
|
|
pressure_unit = "hPa"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherPressureUnits.bar: |
|
|
|
case WeatherPressureUnits.bar: |
|
|
|
pressure = Math.round((pressure / 1000) * 10) / 10; |
|
|
|
pressure = (pressure / 1000).toFixed(this._decimal_places); |
|
|
|
pressure_unit = "bar"; |
|
|
|
pressure_unit = "bar"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherPressureUnits.Pa: |
|
|
|
case WeatherPressureUnits.Pa: |
|
|
|
pressure = Math.round((pressure * 100) * 10) / 10; |
|
|
|
pressure = (pressure * 100).toFixed(this._decimal_places); |
|
|
|
pressure_unit = "Pa"; |
|
|
|
pressure_unit = "Pa"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherPressureUnits.kPa: |
|
|
|
case WeatherPressureUnits.kPa: |
|
|
|
pressure = Math.round((pressure / 10) * 10) / 10; |
|
|
|
pressure = (pressure / 10).toFixed(this._decimal_places); |
|
|
|
pressure_unit = "kPa"; |
|
|
|
pressure_unit = "kPa"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherPressureUnits.atm: |
|
|
|
case WeatherPressureUnits.atm: |
|
|
|
pressure = Math.round((pressure * 0.000986923267) * 10) / 10; |
|
|
|
pressure = (pressure * 0.000986923267).toFixed(this._decimal_places); |
|
|
|
pressure_unit = "atm"; |
|
|
|
pressure_unit = "atm"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherPressureUnits.at: |
|
|
|
case WeatherPressureUnits.at: |
|
|
|
pressure = Math.round((pressure * 0.00101971621298) * 10) / 10; |
|
|
|
pressure = (pressure * 0.00101971621298).toFixed(this._decimal_places); |
|
|
|
pressure_unit = "at"; |
|
|
|
pressure_unit = "at"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherPressureUnits.Torr: |
|
|
|
case WeatherPressureUnits.Torr: |
|
|
|
pressure = Math.round((pressure * 0.750061683) * 10) / 10; |
|
|
|
pressure = (pressure * 0.750061683).toFixed(this._decimal_places); |
|
|
|
pressure_unit = "Torr"; |
|
|
|
pressure_unit = "Torr"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherPressureUnits.psi: |
|
|
|
case WeatherPressureUnits.psi: |
|
|
|
pressure = Math.round((pressure * 0.0145037738) * 10) / 10; |
|
|
|
pressure = (pressure * 0.0145037738).toFixed(this._decimal_places); |
|
|
|
pressure_unit = "psi"; |
|
|
|
pressure_unit = "psi"; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -1277,7 +1290,7 @@ weather-storm.png = weather-storm-symbolic.svg |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherUnits.CELSIUS: |
|
|
|
case WeatherUnits.CELSIUS: |
|
|
|
temperature = Math.round(temperature * 10) / 10; |
|
|
|
temperature = temperature.toFixed(this._decimal_places); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherUnits.KELVIN: |
|
|
|
case WeatherUnits.KELVIN: |
|
|
@ -1350,26 +1363,26 @@ weather-storm.png = weather-storm-symbolic.svg |
|
|
|
// Override wind units with our preference
|
|
|
|
// Override wind units with our preference
|
|
|
|
switch (this._wind_speed_units) { |
|
|
|
switch (this._wind_speed_units) { |
|
|
|
case WeatherWindSpeedUnits.MPH: |
|
|
|
case WeatherWindSpeedUnits.MPH: |
|
|
|
wind = Math.round((wind * WEATHER_CONV_MPS_IN_MPH) * 10) / 10; |
|
|
|
wind = (wind * WEATHER_CONV_MPS_IN_MPH).toFixed(this._decimal_places); |
|
|
|
wind_unit = 'mph'; |
|
|
|
wind_unit = 'mph'; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherWindSpeedUnits.KPH: |
|
|
|
case WeatherWindSpeedUnits.KPH: |
|
|
|
wind = Math.round((wind * WEATHER_CONV_MPS_IN_KPH) * 10) / 10; |
|
|
|
wind = (wind * WEATHER_CONV_MPS_IN_KPH).toFixed(this._decimal_places); |
|
|
|
wind_unit = 'km/h'; |
|
|
|
wind_unit = 'km/h'; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherWindSpeedUnits.MPS: |
|
|
|
case WeatherWindSpeedUnits.MPS: |
|
|
|
wind = Math.round(wind * 10) / 10; |
|
|
|
wind = wind.toFixed(this._decimal_places); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherWindSpeedUnits.KNOTS: |
|
|
|
case WeatherWindSpeedUnits.KNOTS: |
|
|
|
wind = Math.round((wind * WEATHER_CONV_MPS_IN_KNOTS) * 10) / 10; |
|
|
|
wind = (wind * WEATHER_CONV_MPS_IN_KNOTS).toFixed(this._decimal_places); |
|
|
|
wind_unit = 'kn'; |
|
|
|
wind_unit = 'kn'; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherWindSpeedUnits.FPS: |
|
|
|
case WeatherWindSpeedUnits.FPS: |
|
|
|
wind = Math.round((wind * WEATHER_CONV_MPS_IN_FPS) * 10) / 10; |
|
|
|
wind = (wind * WEATHER_CONV_MPS_IN_FPS).toFixed(this._decimal_places); |
|
|
|
wind_unit = 'ft/s'; |
|
|
|
wind_unit = 'ft/s'; |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
@ -1461,8 +1474,8 @@ weather-storm.png = weather-storm-symbolic.svg |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherUnits.CELSIUS: |
|
|
|
case WeatherUnits.CELSIUS: |
|
|
|
t_low = Math.round(t_low * 10) / 10; |
|
|
|
t_low = t_low.toFixed(this._decimal_places); |
|
|
|
t_high = Math.round(t_high * 10) / 10; |
|
|
|
t_high = t_high.toFixed(this._decimal_places); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case WeatherUnits.KELVIN: |
|
|
|
case WeatherUnits.KELVIN: |
|
|
|