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="Torr" value="7" />
<value nick="psi" value="8" />
<value nick="mmHg" value="9" />
</enum>
<enum id="org.gnome.shell.extensions.openweather.wind-speed-unit">
<value nick="kph" value="0" />

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

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

Loading…
Cancel
Save