Add mmHg to the pressure units, fixes #68 ; cosmetic source fix

merge-requests/218/head
Jens Lody 9 years ago
parent 97c21a5596
commit 26a6dbef5b
  1. 1
      data/org.gnome.shell.extensions.openweather.gschema.xml.in
  2. 1
      data/weather-settings.ui
  3. 42
      src/extension.js

@ -23,6 +23,7 @@
<value nick="at" value="6" /> <value nick="at" value="6" />
<value nick="Torr" value="7" /> <value nick="Torr" value="7" />
<value nick="psi" value="8" /> <value nick="psi" value="8" />
<value nick="mmHg" value="9" />
</enum> </enum>
<enum id="org.gnome.shell.extensions.openweather.wind-speed-unit"> <enum id="org.gnome.shell.extensions.openweather.wind-speed-unit">
<value nick="kph" value="0" /> <value nick="kph" value="0" />

@ -639,6 +639,7 @@
<item>at</item> <item>at</item>
<item>Torr</item> <item>Torr</item>
<item>psi</item> <item>psi</item>
<item>mmHg</item>
</items> </items>
</object> </object>
<packing> <packing>

@ -109,15 +109,16 @@ const WeatherWindSpeedUnits = {
}; };
const WeatherPressureUnits = { const WeatherPressureUnits = {
hPa: 0, HPA: 0,
inHg: 1, INHG: 1,
bar: 2, BAR: 2,
Pa: 3, PA: 3,
kPa: 4, KPA: 4,
atm: 5, ATM: 5,
at: 6, AT: 6,
Torr: 7, TORR: 7,
psi: 8 PSI: 8,
MMHG: 9
}; };
const WeatherPosition = { const WeatherPosition = {
@ -980,50 +981,55 @@ const OpenweatherMenuButton = new Lang.Class({
formatPressure: function(pressure) { formatPressure: function(pressure) {
let pressure_unit = 'hPa'; let pressure_unit = 'hPa';
switch (this._pressure_units) { switch (this._pressure_units) {
case WeatherPressureUnits.inHg: case WeatherPressureUnits.INHG:
pressure = this.toInHg(pressure); pressure = this.toInHg(pressure);
pressure_unit = "inHg"; pressure_unit = "inHg";
break; break;
case WeatherPressureUnits.hPa: case WeatherPressureUnits.HPA:
pressure = pressure.toFixed(this._decimal_places); pressure = pressure.toFixed(this._decimal_places);
pressure_unit = "hPa"; pressure_unit = "hPa";
break; break;
case WeatherPressureUnits.bar: case WeatherPressureUnits.BAR:
pressure = (pressure / 1000).toFixed(this._decimal_places); pressure = (pressure / 1000).toFixed(this._decimal_places);
pressure_unit = "bar"; pressure_unit = "bar";
break; break;
case WeatherPressureUnits.Pa: case WeatherPressureUnits.PA:
pressure = (pressure * 100).toFixed(this._decimal_places); pressure = (pressure * 100).toFixed(this._decimal_places);
pressure_unit = "Pa"; pressure_unit = "Pa";
break; break;
case WeatherPressureUnits.kPa: case WeatherPressureUnits.KPA:
pressure = (pressure / 10).toFixed(this._decimal_places); pressure = (pressure / 10).toFixed(this._decimal_places);
pressure_unit = "kPa"; pressure_unit = "kPa";
break; break;
case WeatherPressureUnits.atm: case WeatherPressureUnits.ATM:
pressure = (pressure * 0.000986923267).toFixed(this._decimal_places); pressure = (pressure * 0.000986923267).toFixed(this._decimal_places);
pressure_unit = "atm"; pressure_unit = "atm";
break; break;
case WeatherPressureUnits.at: case WeatherPressureUnits.AT:
pressure = (pressure * 0.00101971621298).toFixed(this._decimal_places); pressure = (pressure * 0.00101971621298).toFixed(this._decimal_places);
pressure_unit = "at"; pressure_unit = "at";
break; break;
case WeatherPressureUnits.Torr: case WeatherPressureUnits.TORR:
pressure = (pressure * 0.750061683).toFixed(this._decimal_places); pressure = (pressure * 0.750061683).toFixed(this._decimal_places);
pressure_unit = "Torr"; pressure_unit = "Torr";
break; break;
case WeatherPressureUnits.psi: case WeatherPressureUnits.PSI:
pressure = (pressure * 0.0145037738).toFixed(this._decimal_places); pressure = (pressure * 0.0145037738).toFixed(this._decimal_places);
pressure_unit = "psi"; pressure_unit = "psi";
break; break;
case WeatherPressureUnits.MMHG:
pressure = (pressure * 0.750061683).toFixed(this._decimal_places);
pressure_unit = "mmHg";
break;
} }
return parseFloat(pressure).toLocaleString() + ' ' + pressure_unit; return parseFloat(pressure).toLocaleString() + ' ' + pressure_unit;
}, },

Loading…
Cancel
Save