Code clean up. Some quick wins.

master
PJ Hampton 2017-05-01 21:02:08 +00:00
parent dbbfaba034
commit 5271eae25b
2 changed files with 66 additions and 16 deletions

View File

@ -109,6 +109,15 @@ DDH.conversions = DDH.conversions || {};
} // Converter
var Utils = {
setUpCustomUnits: function() {
// custom unit support
// support for custom energy conversions
math.createUnit('kilojoule', '1000 joules');
math.createUnit('gramcalorie', '4.184 joules');
math.createUnit('kilocalorie', '4184 joules');
// math.createUnit('killowatt/hr', '3.6e+6 joules');
},
// caches the local DOM vars
setUpLocalDOM: function() {
@ -292,7 +301,8 @@ DDH.conversions = DDH.conversions || {};
'torr',
'mmHg',
'mmH2O',
'cmH2O'
'cmH2O',
'bar',
],
defaults: ['Pa', 'psi']
},
@ -336,19 +346,11 @@ DDH.conversions = DDH.conversions || {};
return {
signal: "high",
onShow: function() {
DDG.require('math.js', function() {
// custom unit support
// support for custom energy conversions
math.createUnit('kilojoule', '1000 joules');
math.createUnit('gramcalorie', '4.184 joules');
math.createUnit('kilocalorie', '4184 joules');
// math.createUnit('killowatt/hr', '3.6e+6 joules');
DDG.require('math.js', function() {
if(!localDOMInitialized) {
Utils.setUpLocalDOM();
Utils.setUpCustomUnits();
}
if(!initialized) {

View File

@ -1,5 +1,6 @@
---
aliases:
- oz
- ozs
- ounce
- ounces
@ -10,6 +11,7 @@ symbols: [oz]
aliases:
- lbm
- pound mass
- lb
- lbs
- lbms
- pounds mass
@ -50,10 +52,12 @@ unit: gram
symbols: [g]
---
aliases:
- mgs
- mg
- mgs
- milligram
- milligrams
- milli-gram
- milli-grams
type: mass
unit: milligram
symbols: [mg]
@ -70,25 +74,43 @@ symbols: [µg]
aliases:
- gs
- g
- gram
- grams
type: mass
unit: gram
symbols: [g]
---
aliases:
- short ton
- short tons
- stick
- sticks
type: mass
unit: stick
---
aliases:
- ton
- tons
- tonnes
- tonne
type: mass
unit: ton
---
aliases:
- grain
- grains
- gr
- troy grain
- troy grains
type: mass
unit: grain
---
aliases:
- hundredweight
- hundredweights
- hundred weight
- hundred weights
type: mass
unit: hundredweight
---
aliases:
- dram
- drams
@ -122,6 +144,8 @@ aliases:
- kilometres
- kilometer
- kilometers
- kilo meter
- kilo meters
- km
- kms
- klick
@ -178,6 +202,8 @@ aliases:
- millimetres
- millimeter
- millimeters
- milli meter
- milli meters
- mm
- mms
type: length
@ -189,6 +215,8 @@ aliases:
- micrometres
- micrometer
- micrometers
- micro meter
- micro meters
- µms
type: length
unit: micrometer
@ -199,6 +227,10 @@ aliases:
- nanometres
- nanometer
- nanometers
- nano meter
- nano meters
- nano metre
- nano metres
- nm
- nms
type: length
@ -237,6 +269,13 @@ type: length
unit: yard
symbols: [yd]
---
aliases:
- angstrom
- ångström
- Å
type: length
unit: angstrom
---
aliases:
- ft
- international foot
@ -634,10 +673,18 @@ type: pressure
unit: mmHg
symbols: [mmHg]
---
aliases: []
aliases:
- tor
- torr
type: pressure
unit: torr
---
aliases:
- bar
- bars
type: pressure
unit: bar
---
aliases:
- js
- joule
@ -727,10 +774,11 @@ aliases:
- ks
- ch
- metric horsepower
- mechanical horsepower
- mechanical horsepowers
- PS
type: power
unit: hp
symbols: [PS]
---
aliases:
- deg