whisper.cat/weboasis/convert/unit/unit.min.js
2023-10-05 23:28:32 +11:00

1 line
8.4 KiB
JavaScript

var property=[],unit=[],factor=[];property[0]="Acceleration",unit[0]=["Meter/sq.sec (m/sec^2)","Foot/sq.sec (ft/sec^2)","G (g)","Galileo (gal)","Inch/sq.sec (in/sec^2)"],factor[0]=[1,.3048,9.80665,.01,.0254],property[1]="Area",unit[1]=["Square meter (m^2)","Acre (acre)","Are","Barn (barn)","Hectare","Rood","Square centimeter","Square kilometer","Circular mil","Square foot (ft^2)","Square inch (in^2)","Square mile (mi^2)","Square yard (yd^2)"],factor[1]=[1,4046.856,100,1e-28,1e4,1011.71413184285,1e-4,1e6,5067075e-16,.09290304,64516e-8,2589988,.8361274],property[2]="Torque",unit[2]=["Newton-meter (N m)","Dyne-centimeter(dy cm)","Kgrf-meter (kgf m)","lbf-inch (lbf in)","lbf-foot (lbf ft)"],factor[2]=[1,1e-7,9.80665,.1129848,1.355818],property[3]="Electricity",unit[3]=["Coulomb (Cb)","Abcoulomb","Ampere hour (A hr)","Faraday (F)","Statcoulomb","Millifaraday (mF)","Microfaraday (mu-F)","Picofaraday (pF)"],factor[3]=[1,10,3600,96521.8999999997,333564e-15,96.5219,.0965219,965219e-10],property[4]="Energy",unit[4]=["Joule (J)","BTU (mean)","BTU (thermochemical)","Calorie (SI) (cal)","Calorie (mean)(cal)","Calorie (thermo)","Electron volt (eV)","Erg (erg)","Foot-pound force","Foot-poundal","Horsepower-hour","Kilocalorie (SI)(kcal)","Kilocalorie (mean)(kcal)","Kilowatt-hour (kW hr)","Ton of TNT","Volt-coulomb (V Cb)","Watt-hour (W hr)","Watt-second (W sec)"],factor[4]=[1,1055.87,1054.35,4.1868,4.19002,4.184,16021e-23,1e-7,1.355818,.04214011,2684077.3,4186.8,4190.02,36e5,42e8,1,3600,1],property[5]="Force",unit[5]=["Newton (N)","Dyne (dy)","Kilogram force (kgf)","Kilopond force (kpf)","Kip (k)","Ounce force (ozf)","Pound force (lbf)","Poundal"],factor[5]=[1,1e-5,9.80665,9.80665,4448.222,.2780139,.4535924,.138255],property[6]="Force / Length",unit[6]=["Newton/meter (N/m)","Pound force/inch (lbf/in)","Pound force/foot (lbf/ft)"],factor[6]=[1,175.1268,14.5939],property[7]="Length",unit[7]=["Meter (m)","Angstrom (A')","Astronomical unit (AU)","Caliber (cal)","Centimeter (cm)","Kilometer (km)","Ell","Em","Fathom","Furlong","Fermi (fm)","Foot (ft)","Inch (in)","League (int'l)","League (UK)","Light year (LY)","Micrometer (mu-m)","Mil","Millimeter (mm)","Nanometer (nm)","Mile (int'l nautical)","Mile (UK nautical)","Mile (US nautical)","Mile (US statute)","Parsec","Pica (printer)","Picometer (pm)","Point (pt)","Rod","Yard (yd)"],factor[7]=[1,1e-10,149598e6,254e-6,.01,1e3,1.143,.0042323,1.8288,201.168,1e-15,.3048,.0254,5556,5556,946055e10,1e-6,254e-7,.001,1e-9,1852,1853.184,1852,1609.344,308374e11,.004217518,1e-12,.0003514598,5.0292,.9144],property[8]="Light",unit[8]=["Lumen/sq.meter (Lu/m^2)","Lumen/sq.centimeter","Lumen/sq.foot","Foot-candle (ft-cdl)","Foot-lambert","Candela/sq.meter","Candela/sq.centimeter","Lux (lux)","Phot"],factor[8]=[1,1e4,10.76391,10.76391,10.76391,3.14159250538575,31415.9250538576,1,1e4],property[9]="Mass",unit[9]=["Kilogram (kgr)","Gram (gr)","Milligram (mgr)","Microgram (mu-gr)","Carat (metric)(ct)","Hundredweight (long)","Hundredweight (short)","Pound mass (lbm)","Pound mass (troy)","Ounce mass (ozm)","Ounce mass (troy)","Slug","Ton (assay)","Ton (long)","Ton (short)","Ton (metric)","Tonne"],factor[9]=[1,.001,1e-6,1e-9,2e-4,50.80235,45.35924,.4535924,.3732417,.02834952,.03110348,14.5939,.02916667,1016.047,907.1847,1e3,1e3],property[10]="Mass Flow",unit[10]=["Kilogram/second (kgr/sec)","Pound mass/sec (lbm/sec)","Pound mass/min (lbm/min)"],factor[10]=[1,.4535924,.007559873],property[11]="Density & Mass capacity",unit[11]=["Kilogram/cub.meter","Grain/galon","Grams/cm^3 (gr/cc)","Pound mass/cubic foot","Pound mass/cubic-inch","Ounces/gallon (UK,liq)","Ounces/gallon (US,liq)","Ounces (mass)/inch","Pound mass/gal (UK,liq)","Pound mass/gal (US,liq)","Slug/cubic foot","Tons (long,mass)/cub.yard"],factor[11]=[1,.01711806,1e3,16.01846,27679.91,6.236027,7.489152,1729.994,99.77644,119.8264,515.379,1328.939],property[12]="Power",unit[12]=["Watt (W)","Kilowatt (kW)","Megawatt (MW)","Milliwatt (mW)","BTU (SI)/hour","BTU (thermo)/second","BTU (thermo)/minute","BTU (thermo)/hour","Calorie (thermo)/second","Calorie (thermo)/minute","Erg/second","Foot-pound force/hour","Foot-pound force/minute","Foot-pound force/second","Horsepower(550 ft lbf/s)","Horsepower (electric)","Horsepower (boiler)","Horsepower (metric)","Horsepower (UK)","Kilocalorie (thermo)/min","Kilocalorie (thermo)/sec"],factor[12]=[1,1e3,1e6,.001,.2930667,1054.35,17.5725,.2928751,4.184,.06973333,1e-7,.0003766161,.02259697,1.355818,745.7,746,9809.5,735.499,745.7,69.7333,4184],property[13]="Pressure & Stress",unit[13]=["Newton/sq.meter","Atmosphere (normal)","Atmosphere (techinical)","Bar","Centimeter mercury(cmHg)","Centimeter water (4'C)","Decibar","Kgr force/sq.centimeter","Kgr force/sq.meter","Kip/square inch","Millibar","Millimeter mercury(mmHg)","Pascal (Pa)","Kilopascal (kPa)","Megapascal (Mpa)","Poundal/sq.foot","Pound-force/sq.foot","Pound-force/sq.inch (psi)","Torr (mmHg,0'C)"],factor[13]=[1,101325,98066.5,1e5,1333.22,98.0638,1e4,98066.5,9.80665,6894757,100,133.3224,1,1e3,1e6,47.88026,47.88026,6894.757,133.322],property[14]="Temperature",unit[14]=["Degrees Celsius ('C)","Degrees Fahrenheit ('F)","Degrees Kelvin ('K)","Degrees Rankine ('R)"],factor[14]=[1,.555555555555,1,.555555555555],tempIncrement=[0,-32,-273.15,-491.67],property[15]="Time",unit[15]=["Second (sec)","Day (mean solar)","Day (sidereal)","Hour (mean solar)","Hour (sidereal)","Minute (mean solar)","Minute (sidereal)","Month (mean calendar)","Second (sidereal)","Year (calendar)","Year (tropical)","Year (sidereal)"],factor[15]=[1,86400,86164.09,3600,3590.17,60,60,2628e3,.9972696,31536e3,31556930,31558150],property[16]="Velocity & Speed",unit[16]=["Meter/second (m/sec)","Foot/minute (ft/min)","Foot/second (ft/sec)","Kilometer/hour (kph)","Knot (int'l)","Mile (US)/hour (mph)","Mile (nautical)/hour","Mile (US)/minute","Mile (US)/second","Speed of light (c)","Mach (STP)(a)"],factor[16]=[1,.00508,.3048,.2777778,.5144444,.44707,.514444,26.8224,1609.344,299792458,340.006875],property[17]="Viscosity",unit[17]=["Newton-second/meter","Centipoise","Centistoke","Sq.foot/second","Poise","Poundal-second/sq.foot","Pound mass/foot-second","Pound force-second/sq.foot","Rhe","Slug/foot-second","Stoke"],factor[17]=[1,.001,1e-6,.09290304,.1,1.488164,1.488164,47.88026,10,47.88026,1e-4],property[18]="Volume & Capacity",unit[18]=["Cubic Meter (m^3)","Cubic centimeter","Cubic millimeter","Acre-foot","Barrel (oil)","Board foot","Bushel (US)","Cup","Fluid ounce (US)","Cubic foot","Gallon (UK)","Gallon (US,dry)","Gallon (US,liq)","Gill (UK)","Gill (US)","Cubic inch (in^3)","Liter (new)","Liter (old)","Ounce (UK,fluid)","Ounce (US,fluid)","Peck (US)","Pint (US,dry)","Pint (US,liq)","Quart (US,dry)","Quart (US,liq)","Stere","Tablespoon","Teaspoon","Ton (register)","Cubic yard"],factor[18]=[1,1e-6,1e-9,1233.482,.1589873,.002359737,.03523907,.0002365882,2957353e-11,.02831685,.004546087,.004404884,.003785412,.0001420652,.0001182941,1638706e-11,.001,.001000028,2841305e-11,2957353e-11,.008809768,.0005506105,.0004731765,.001101221,946353e-9,1,1478676e-11,4928922e-12,2.831685,.7645549],property[19]="Volume Flow",unit[19]=["Cubic meter/second","Cubic foot/second","Cubic foot/minute","Cubic inches/minute","Gallons (US,liq)/minute)"],factor[19]=[1,.02831685,.0004719474,2.731177e-7,630902e-10];function UpdateUnitMenu(a,b){var c;c=a.selectedIndex,FillMenuWithArray(b,unit[c])}function FillMenuWithArray(a,b){var c;for(a.length=b.length,c=0;c<b.length;c++)a.options[c].text=b[c]}function CalculateUnit(a,b){var c=a.unit_input.value;c=parseFloat(c),isNaN(c)&&0!=c||(a.unit_input.value=c,ConvertFromTo(a,b))}function ConvertFromTo(a,b){var c,d,e,f,g,h;c=document.property_form.the_menu.selectedIndex,d=a.unit_menu.selectedIndex,e=factor[c][d],f=b.unit_menu.selectedIndex,g=factor[c][f],h=a.unit_input.value,"Temperature"==property[c]&&(h=parseFloat(h)+tempIncrement[d]),h*=e,h/=g,"Temperature"==property[c]&&(h=parseFloat(h)-tempIncrement[f]),b.unit_input.value=h}window.onload=function(){FillMenuWithArray(document.property_form.the_menu,property),UpdateUnitMenu(document.property_form.the_menu,document.form_A.unit_menu),UpdateUnitMenu(document.property_form.the_menu,document.form_B.unit_menu)},document.getElementByClass("numbersonly").addEventListener("keydown",function(a){var b=a.keyCode?a.keyCode:a.which;-1!==[8,9,13,27,46,110,190].indexOf(b)||65==b&&(a.ctrlKey||a.metaKey)||67==b&&(a.ctrlKey||a.metaKey)||86==b&&(a.ctrlKey||a.metaKey)||35<=b&&40>=b||48<=b&&57>=b&&!(a.shiftKey||a.altKey)||(96<=b&&105>=b)(190==b)||a.preventDefault()});