PageSourceSearch

https://www.digitaldutch.com/unitconverter/unitconverter.js?v=18

js digitaldutch.com collected 2026-10-02 06:16:15 UTC 38,678 bytes, 862 lines download raw bytes

1// This code has a public domain license.
2// Everyone is free to copy and use it for any purpose.
3// Have a nice day! digitaldutch.com
4
5let inputFrom;
6let inputTo;
7let listQuantities;
8let selectQuantity;
9let selectFrom;
10let selectTo;
11let precision;
12let quantity;
13let metaTagDescription;
14let currencies;
15
16let defaultQuantityID = 'length';
17let quantities = [
18  { name:             'Angle',
19    description:      'Convert angle measurements like degrees, radians, circles, turns.',
20    id:               'angle',
21    defaultUnitIndex: 3,
22    units: [
23      ["arcminute",          "",  'value/(360*60)',   'value * (360*60)'],
24      ["arcsecond",          "",  'value/(360*3600)', 'value * (360*3600)'],
25      ["circle",             "",  1],
26      ["degree",             "°", 'value/360',  'value*360'],
27      ["gon",                "",  'value/400',  'value*400'],
28      ["grad",               "",  'value/400',  'value*400'],
29      ["mil (Nato)",         "",  'value/6400', 'value*6400'],
30      ["mil (Soviet Union)", "",  'value/6000', 'value*6000'],
31      ["mil (Sweden)",       "",  'value/6300', 'value*6300'],
32      ["octant",             "",  0.125],
33      ["quadrant",           "",  0.25],
34      ["radian",             "",  'value / (2 * Math.PI)', 'value * 2 * Math.PI'],
35      ["revolution",         "",  1],
36      ["sextant",            "",  'value/6', 'value * 6'],
37      ["sign",               "",  'value/12', 'value * 12'],
38      ["turn",               "",  1]
39    ]},
40  { name:             'Area',
41    description:      'Convert area measurements like square meters, square feet, acres.',
42    id:               'area',
43    defaultUnitIndex: 11,
44    units: [
45      ["acres",                      "",    4046.8564224],
46      ["ares",                       "",    100],
47      ["circular inches",            "",    0.000506707479],
48      ["hectares",                   "",    1e4],
49      ["hides",                      "",    485000],
50      ["roods",                      "",    1011.7141056],
51      ["square centimeters",         "cm²", 1e-4],
52      ["square feet (US & UK)",      "",    0.09290304],
53      ["square feet (US survey)",    "",    0.092903411613],
54      ["square inches",              "",    0.00064516],
55      ["square kilometers",          "km²", 1e6],
56      ["square meters",              "m²",  1],
57      ["square miles",               "",    2589988.110336],
58      ["square millimeters",         "mm²", 1e-6],
59      ["squares (of timber)",        "",    9.290304],
60      ["square rods (or poles)",     "",    25.29285264],
61      ["square yards",               "",    0.83612736],
62      ["townships",                  "",    93239571.972]
63    ]},
64  { name:             'Bits & Bytes',
65    description:      'Convert bits, bytes, kilobytes, gigabytes.',
66    id:               'bits',
67    defaultUnitIndex: 5,
68    units: [
69      ["bits",           "",   0.125],
70      ["bytes",          "",   1],
71      ["kilobits",       "Kb", 128],
72      ["kilobytes",      "KB", 1024],
73      ["megabits",       "Mb", 131072],
74      ["megabytes",      "MB", 1048576],
75      ["gigabits",       "Gb", 134217728],
76      ["gigabytes",      "GB", 1073741824],
77      ["terabits",       "Tb", 137438953472],
78      ["terabytes",      "TB", 1099511627776],
79      ["petabits",       "Pb", 140737488355328],
80      ["petabytes",      "PB", 1125899906842624],
81      ["exabits",        "Eb", 144115188075855872],
82      ["exabytes",       "EB", 1152921504606846976]
83    ]},
84  { name:             'Currency',
85    description:      'Convert currency and calculate live foreign exchange rates with this free currency converter.',
86    id:               'currency',
87    defaultUnitIndex: 30,
88    units: [
89      ["Australian Dollar",      "A$",  "AUD"],
90      ["British Pound Sterling", "£",   "GBP"],
91      ["Bulgarian lev",          "лв",  "BGN"],
92      ["Canadian Dollar",        "CA$", "CAD"],
93      ["Chinese yuan renminbi",  "CNÂ¥", "CNY"],
94      ["Croatian kuna",          "kn",  "HRK"],
95      ["Czech koruna",           "Kč",  "CZK"],
96      ["Danish Krone",           "kr",  "DKK"],
97      ["Euro",                   "€",   "EUR"],
98      ["Hong Kong Dollar",       "HK$", "HKD"],
99      ["Hungarian forint",       "Ft",  "HUF"],
100      ["Icelandic krona",        "Íkr", "ISK"],
101      ["Indian Rupee",           "Rs.", "INR"],
102      ["Indonesian rupiah",      "Rp",  "IDR"],
103      ["Israeli shekel",         "₪",   "ILS"],
104      ["Japanese Yen",           "Â¥",   "JPY"],
105      ["Malaysian Ringgit",      "MYR", "MYR"],
106      ["Mexican Peso",           "MX$", "MXN"],
107      ["New Zealand Dollar",     "NZ$", "NZD"],
108      ["Norwegian Krone",        "NOK", "NOK"],
109      ["Philippine Peso",        "₱",   "PHP"],
110      ["Polish Zloty",           "PLN", "PLN"],
111      ["Romanian leu",           "RON", "RON"],
112      ["Russian Ruble",          "RUB", "RUB"],
113      ["Singapore Dollar",       "$",   "SGD"],
114      ["South African Rand",     "ZAR", "ZAR"],
115      ["South Korean Won",       "₩",   "KRW"],
116      ["Swedish Krona",          "kr",  "SEK"],
117      ["Swiss Franc",            "CHF", "CHF"],
118      ["Thai Baht",              "฿",   "THB"],
119      ["Turkish Lira",           "TRY", "TRY"],
120      ["United States Dollar",   "$",   "USD"]
121    ]},
122  { name:             'Density',
123    description:      'Convert density measurements like kilogram / cubic meter, milligram / liter, pounds / cubic inch.',
124    id:               'density',
125    defaultUnitIndex: 6,
126    units: [
127      ["grains/gallon (UK)",       "gr/gal", 0.000014253948343691203],
128      ["grains/gallon (US)",       "gr/gal", 0.000017118011571775823],
129      ["grams/cubic centimeters",  "g/cm³",  1],
130      ["grams/liter",              "g/l",    1e-3],
131      ["grams/milliliters",        "g/ml",   1],
132      ["kilograms/cubic meters",   "kg/m³",  1e-3],
133      ["kilograms/liter",          "kg/l",   1],
134      ["megagrams/cubic meter",    "Mg/m³",  1],
135      ["milligrams/milliliter",    "mg/ml",  1e-3],
136      ["milligrams/liter",         "mg/l",   1e-6],
137      ["ounces/cubic inch",        "oz/in³", 1.729994044],
138      ["ounces/gallon (UK)",       "oz/gal", 0.006236023],
139      ["ounces/gallon (US)",       "oz/gal", 0.007489152],
140      ["pounds/cubic inch",        "lb/in³", 27.679904],
141      ["pounds/cubic foot",        "lb/ft³", 0.016018463],
142      ["pounds/gallon (UK)",       "lb/gal", 0.099776373],
143      ["pounds/gallon (US)",       "lb/gal", 0.119826427],
144      ["slugs/cubic foot",         "",       0.51531788206],
145      ["tonnes/cubic meter",       "",       1],
146      ["tons (UK)/cubic yard",     "",       1.328939184],
147      ["tons (US)/cubic yard",     "",       1.186552843]
148    ]},
149  { name:             'Electric Current',
150    description:      'Convert electric current measurements like ampere, watt / volt',
151    id:               'electric_current',
152    defaultUnitIndex: 1,
153    units: [
154      ["abampere",                        "abA", 10],
155      ["ampere",                          "A", 1],
156      ["biot",                            "Bi", 10],
157      ["centiampere",                     "", 0.01],
158      ["coulomb/second",                  "", 1],
159      ["EMU of current",                  "", 10],
160      ["ESU of current",                  "", 3.335641e-10],
161      ["franklin/second",                 "", 3.335641e-10],
162      ["gaussian electric current",       "", 3.335641e-10],
163      ["gigaampere",                      "", 1e+9],
164      ["gilbert",                         "Gi", 0.79577472],
165      ["kiloampere",                      "kA", 1e3],
166      ["megaampere",                      "", 1e6],
167      ["microampere",                     "", 1e-6],
168      ["milliampere",                     "mA", 1e-3],
169      ["milliamp",                        "", 1e-3],
170      ["nanoampere",                      "", 1e-9],
171      ["picoampere",                      "", 1e-12],
172      ["siemens volt",                    "", 1],
173      ["statampere",                      "stA", 3.335641e-10],
174      ["teraampere",                      "", 1e+12],
175      ["volt/ohm",                        "", 1],
176      ["watt/volt",                       "", 1],
177      ["weber/henry",                     "", 1]
178    ]},
179  { name:             'Energy',
180    description:      'Convert energy measurements like calories, joules, megajoules, watt hour.',
181    id:               'energy',
182    defaultUnitIndex: 20,
183    units: [
184      ["Btu (th)",                    "",       1054.350],
185      ["Btu (mean)",                  "",       1055.87],
186      ["calories (IT)",               "",       4.1868],
187      ["calories (th)",               "",       4.184],
188      ["calories (mean)",             "",       4.19002],
189      ["calories (15C)",              "",       4.18580],
190      ["calories (20C)",              "",       4.18190],
191      ["calories (food)",             "",       4186],
192      ["centigrade heat units",       "",       1900.4],
193      ["Dutch natural gas (m³, LHV)", "",       31650000],
194      ["electron volts",              "eV",     1.60219e-19],
195      ["ergs",                        "",       1e-7],
196      ["exajoules",                   "EJ",     1e18],
197      ["foot-pound force",            "ft lbs", 1.3558179483314004],
198      ["foot poundals",               "",       0.042140],
199      ["gasoline (L)",                "",       34200000],
200      ["gigajoules",                  "GJ",     1e9],
201      ["gigawatt hours",              "GWh",    3.6e12],
202      ["horsepower hours",            "",       2684520],
203      ["inch-pound force",         "  in lbf",  0.11298482902761668],
204      ["joules",                      "J",      1],
205      ["kilocalories (IT)",           "",       4186.8],
206      ["kilocalories (th)",           "",       4184],
207      ["kilogram-force meters",       "",       9.80665],
208      ["kilojoules",                  "kJ",     1e3],
209      ["kilowatt hours",              "kWh",    3.6e6],
210      ["megajoules",                  "MJ",     1e6],
211      ["megawatt hours",              "MWh",    3.6e9],
212      ["newton meters",               "Nm",     1],
213      ["petajoules",                  "PJ",     1e15],
214      ["terajoules",                  "TJ",     1e12],
215      ["terawatt hours",              "TWh",    3.6e15],
216      ["therms",                      "",       105505585.257348],
217      ["watt seconds",                "Ws",     1],
218      ["watt hours",                  "Wh",     3600]
219    ]},
220  { name:             'Force',
221    description:      'Convert force measurements like newtons, pound force, tons force.',
222    id:               'force',
223    defaultUnitIndex: 5,
224    units: [
225      ["dynes",            "dyn", 1e-5],
226      ["kilograms force",  "kgf", 9.80665],
227      ["kilonewtons",      "kN",  1000],
228      ["kips",             "",    4448.222],
229      ["meganewtons",      "MN",  1e6],
230      ["newtons",          "N",   1],
231      ["pounds force",     "lbf", 4.4482216152605],
232      ["poundals",         "pdl", 0.138255],
233      ["sthène",           "sn",  1000],
234      ["tonnes force",     "",    9806.65],
235      ["tons force (UK)",  "",    9964.01641818352],
236      ["tons force (US)",  "",    8896.443230521]
237    ]},
238  { name:             'Fuel Consumption',
239    description:      'Convert fuel consumption measurements like kilometers/liter, liters/100km, miles/gallon.',
240    id:               'fuel_consumption',
241    defaultUnitIndex: 13,
242    units: [
243      ["bicycle (electric)",               "",           0.00000061779717543, '18km/h 100W'],
244      ["car (2020 Hyundai Kona Electric)", "",           0.000019601215278],
245      ["car (2021 Tesla Model 3 LR)",      "",           0.000017553327114],
246      ["car (2020 Tesla Model S LR+)",     "",           0.000020103810541],
247      ["car (2021 Honda Accord)",          "",           0.000049003038194],
248      ["car (2020 Ford F150)",             "",           0.000098006076389],
249      ["gallons (UK)/100 miles",           "",           2.8248093633182215859381213711925e-5],
250      ["gallons (US)/100 miles",           "",           2.3521458333333333333333333333333e-5],
251      ["kilowatt hours/100 miles",         "kWh/100mi",  6.979661226508e-7],
252      ["kilowatt hours/100 kilometer",     "kWh/100km",  0.0000011232675916913290752],
253      ["kilowatt hours/kilometer",         "kWh/km",     0.00011232675916913290752],
254      ["kilometer/kWh",                    "km/kWh",     '0.00011232675916913290752 / value', '0.00011232675916913290752 / value'],
255      ["kilometer/liter",                  "km/l",       '0.001 / value', '0.001 / value'],
256      ["liters/100 kilometer",             "",           0.00001],
257      ["liters/meter",                     "l/m",        1],
258      ["miles/gallon (UK)",                "mpg",        '2.8248093633182215859381213711925e-3 / value', '2.8248093633182215859381213711925e-3 / value'],
259      ["miles/gallon (US)",                "mpg",        '2.3521458333333333333333333333333e-3 / value', '2.3521458333333333333333333333333e-3 / value'],
260      ["miles/kWh",                        "mi/kWh",     '6.979661226508e-5 / value', '6.979661226508e-5 / value'],
261      ["miles/liter",                      "mi/l",       '6.213711922373339
2616961743418436332e-4 / value', '6.2137119223733396961743418436332e-4 / value'],
262      ["motorcycle (electric Zero SR)",    "",           0.00000653329109384],
263      ["watt hours/kilometer",             "Wh/km",      0.00000011232675916913290752],
264      ["watt hours/mile",                  "Wh/mi",      6.979661226508e-8]
265    ]},
266{ name:             'Length',
267  description:      'Convert length measurements like meter, inches, feet or light years.',
268  id:               'length',
269  defaultUnitIndex: 18,
270  units: [
271    ["ångströms",                       "Å",        1e-10],
272    ["astronomical units",              "au",       149598550000],
273    ["barleycorns",                     "",         0.008467],
274    ["cables",                          "",         182.88],
275    ["centimeters",                     "cm",       0.01],
276    ["chains (surveyors')",             "",         20.116840233680467360934721869444],
277    ["decimeters",                      "dm",       0.1],
278    ["ells (UK)",                       "",         0.875],
279    ["ems (pica)",                      "",         0.0042333],
280    ["fathoms",                         "",         1.8288],
281    ["feet (UK & US)",                  "",         0.3048],
282    ["feet (US survey)",                "",         0.30480060960121920243840487680975],
283    ["furlongs",                        "",         201.168],
284    ["hands",                           "",         0.1016],
285    ["hectometers",                     "hm",       100],
286    ["inches",                          "in",       0.0254],
287    ["kilometers",                      "km",       1000],
288    ["light years",                     "",         9.460528405e15],
289    ["meters",                          "m",        1],
290    ["micrometers",                     "µm",       1e-6],
291    ["mil",                             "",         0.0000254],
292    ["miles (UK & US)",                 "",         1609.344],
293    ["miles (nautical, international)", "",         1852],
294    ["miles (nautical, UK)",            "",         1853.184],
295    ["millimeters",                     "mm",       0.001],
296    ["nanometers",                      "nm",       1e-9],
297    ["parsecs",                         "",         3.0856776e16],
298    ["picometers",                      "pm",       1e-12],
299    ["Scandinavian mile",               "",         10000],
300    ["thou",                            "",         0.0000254],
301    ["yards",                           "yd",       0.9144]
302  ]},
303{ name:             'Mass',
304  description:      'Convert mass measurements like kilograms, pounds, stones.',
305  id:               'mass',
306  defaultUnitIndex: 9,
307  units: [
308    ["carats (metric)",                "CD",   0.0002],
309    ["cental",                         "",     45.359237],
310    ["decagrams",                      "dag",  0.01],
311    ["Earth masses",                   "M⊕",   5.980e24],
312    ["femtograms",                     "fg",   1e-18],
313    ["grains",                         "gr",   0.00006479891],
314    ["grams",                          "g",    1e-3],
315    ["hectograms",                     "hg",   0.1],
316    ["hundredweights",                 "cwt",  50.80234544],
317    ["kilograms",                      "kg",   1],
318    ["kilotonnes",                     "kt",   1e6],
319    ["megatonnes",                     "Mt",   1e9],
320    ["micrograms",                     "µg",   1e-9],
321    ["milligrams",                     "mg",   1e-6],
322    ["nanograms",                      "ng",   1e-12],
323    ["ounces (US & UK)",               "oz",   0.028349523125],
324    ["ounces (troy, precious metals)", "oz t", 0.0311034768],
325    ["picograms",                      "pg",   1e-15],
326    ["pounds (US & UK)",               "lbs",  0.45359237],
327    ["pounds (troy, precious metals)", "lb t", 0.3732417216],
328    ["Solar masses",                   "M☉",  1.989e30],
329    ["slugs (g-pounds)",               "",     14.593903],
330    ["stones",                         "st",   6.35029318],
331    ["tons (UK or long)",              "LT",   1016.0469088],
332    ["tons (US or short)",             "ST",   907.18474],
333    ["tonnes (metric)",                "t",    1000]
334  ]},
335  { name:             'Power',
336    description:      'Convert power measurements like watts, horsepower, joules/second.',
337    id:               'power',
338    defaultUnitIndex: 13,
339    units: [
340      ["Btu/hour",                     "",   0.2930711],
341      ["Btu/minute",                   "",   17.584267],
342      ["Btu/second",                   "",   1055.056],
343      ["calories(th)/hour",            "",   0.001162222222222222],
344      ["calories(th)/minute",          "",   0.069733333333333333],
345      ["calories(th)/second",          "",   4.184],
346      ["foot pounds-force/minute",     "",   0.022597],
347      ["foot pounds-force/second",     "",   1.35582],
348      ["gigawatts",                    "GW", 1e9],
349      ["horsepowers (electric)",       "",   746],
350      ["horsepowers (international)",  "",   745.69987158227022],
351      ["horsepowers (water)",          "",   746.043],
352      ["horsepowers (metric)",         "",   735.4988],
353      ["watts",                        "W",  1],
354      ["joules/hour",                  "",   0.0002777777777777778],
355      ["joules/minute",                "",   0.016666666666666666],
356      ["joules/second",                "",   1],
357      ["kilocalories(th)/hour",        "",   1.162222222222222222],
358      ["kilocalories(th)/minute",      "",   69.73333333333333333],
359      ["kilogram-force meters/hour",   "",   0.002724],
360      ["kilogram-force meters/minute", "",   0.163444],
361      ["kilowatts",                    "kW", 1e3],
362      ["megawatts",                    "MW", 1e6],
363      ["terawatts",                    "TW", 1e12],
364      ["ton of refrigeration",         "TR", 3516.853],
365      ["petawatts",                    "PW", 1e15]
366    ]},
367  { name:             'Pressure',
368    description:      'Convert pressure measurements like pascals, psi, bars, atmospheres, newton/sq. meter',
369    id:               'pressure',
370    defaultUnitIndex: 24,
371    units: [
372      ["atmospheres",                   "atm",   101325],
373      ["bars",                          "",      1e5],
374      ["centimeters mercury",           "",      1333.22],
375      ["centimeters water",             "",      98.0665],
376      ["feet of water",                 "",      2989.06692],
377      ["hectopascals",                  "hPa",   100],
378      ["inches of water",               "",      249.08891],
379      ["inches of mercury",             "",      3386.388],
380      ["kilogram-forces/sq.centimeter", "",      98066.5],
381      ["kilogram-forces/sq.meter",      "",      9.80665],
382      ["kilonewtons/sq.meter",          "",      1e3],
383      ["kilonewtons/sq.millimeter",     "",      1e9],
384      ["kilopascals [kPa]",             "",      1000],
385      ["kips/sq.inch",                  "",      6894760],
386      ["meganewtons/sq.meter",          "",      1e6],
387      ["meganewtons/sq.millimeter",     "",      1e12],
388      ["megapascals [MPa]",             "",      1e6],
389      ["meters of water",               "",      9806.65],
390      ["millibars",                     "",      100],
391      ["millimeters of mercury",        "mmHg",  133.322],
392      ["millimeters of water",          "",      9.80665],
393      ["newtons/sq.centimeter",         "N/cm²", 1e4],
394      ["newtons/sq.meter",              "N/m²",  1],
395      ["newtons/sq.millimeter",         "N/mm²", 1e6],
396      ["pascals",                       "Pa",    1],
397      ["pounds-force/sq.foot",          "psf",   47.88025898033584261613],
398      ["pounds-force/sq.inch",          "psi",   6894.757293168361336723],
399      ["poundals/sq.foot",              "",      1.44816],
400      ["tons (UK)-force/sq.foot",       "",      107251],
401      ["tons (UK)-force/sq.inch",       "",      15444300],
402      ["tons (US)-force/sq.foot",       "",      95760],
403      ["tons (US)-force/sq.inch",       "",      13789500],
404      ["tonnes-force/sq.cm",            "",      98066500],
405      ["tonnes-force/sq.meter",         "",      9806.65],
406      ["torr (mm Hg 0°C)",              "",      133.322]
407    ]},
408  { name:             'Speed',
409    description:      'Convert speed measurements like kilometers/hour, miles/hour, knots.',
410    id:               'speed',
411    defaultUnitIndex: 13,
412    units: [
413      ["centimeters/minute",          "",     0.00016666666666666666],
414      ["centimeters/second",          "",     0.01],
415      ["feet/hour",                   "",     0.00008466683600033866],
416      ["feet/minute",                 "",     0.00508],
417      ["feet/second",                 "ft/s", 0.3048],
418      ["inches/minute",               "",     0.0004233341800016934],
419      ["inches/second",               "",     0.0254],
420      ["kilometers/hour",             "km/h", 0.2777777777777778],
421      ["kilometers/second",           "",     1000],
422      ["knots",                       "kn",   0.5144444444444444444],
423      ["Mach number (ISA/Sea level)", "",     340.2933],
424      ["meters/hour",                 "m/h",  0.0002777777777777778],
425      ["meters/minute",               "",     0.016666666666666666],
426      ["meters/second",               "m/s",  1],
427      ["miles/hour",                  "mph",  0.44704],
428      ["miles/minute",                "",     26.8224],
429      ["miles/second",                "",     1609.344],
430      ["nautical miles/hour",         "",     0.5144444444444444444],
431      ["Nm/24hr",                     "",     0.0214351851851851851],
432      ["speed of light",              "",     2.9979e8],
433      ["speed of sound",              "",     343],
434      ["yards/hour",                  "",     0.000254000508001016],
435      ["yards/minute",                "",     0.01524],
436      ["yards/second",                "",     0.9144]
437    ]},
438  { name:             'Temperature',
439    description:      'Convert temperature measurements like Celsius, Fahrenheit, Kelvin.',
440    id:               'temperature',
441    defaultUnitIndex: 0,
442    units: [
443      ["Celsius",    "°C",  'value + 273.15',         'value - 273.15'],
444      ["Fahrenheit", "°F",  '5/9 * (value + 459.67)', '9/5 * value - 459.67'],
445      ["Kelvin",     "K",   1],
446      ["Rankine",    "°R",  '5/9 * value',            '9/5 * value'],
447      ["Réaumure",   "°Ré", '5/4 * value + 273.15',   '4/5 * (value - 273.15)']
448    ]},
449  { name:             'Time',
450    description:      'Convert time measurements like seconds, minutes, hours, days, weeks, years.',
451    id:               'time',
452    defaultUnitIndex: 15,
453    units: [
454      ["centuries",                    "",    3153600000],
455      ["days",                         "d",   86400],
456      ["decades",                      "",    315360000],
457      ["femtoseconds",                 "fs",  1e-15],
458      ["fortnights",                   "",    1209600],
459      ["hours",                        "h",   3600],
460      ["microseconds",                 "μs",  1e-6],
461      ["millenia",                     "",    31536000000],
462      ["milliseconds",                 "ms",  1e-3],
463      ["minutes",                      "min", 60],
464      ["months (Common)",              "",    2628000],
465      ["months (Synodic)",             "",    2551442.8896],
466      ["nanoseconds",                  "ns",  1e-9],
467      ["picoseconds",                  "ps",  1e-12],
468      ["quarters (Common)",            "",    7884000],
469      ["seconds",                      "s",   1],
470      ["shakes",                       "",    1e-8],
471      ["weeks",                        "",    604800],
472      ["years (Common)",               "y",   31536000],
473      ["years (Average Gregorian)",    "",    31556952],
474      ["years (Julian)",               "",    31557600],
475      ["years (Leap)",                 "",    31622400],
476      ["years (Tropical)",             "",    31556925.216]
477    ]},
478  { name:             'Volume',
479    description:      'Convert volume measurements like cubic meters, liters, gallons, pints.',
480    id:               'volume',
481    defaultUnitIndex: 27,
482    units: [
483      ["acre foot",               "",       1233481.83754752],
484      ["barrels (oil)",           "bbl",    158.987294928],
485      ["bushels (UK)",            "",       36.36872],
486      ["bushels (US)",            "",       35.23907016688],
487      ["centiliters",             "",       0.01],
488      ["cubic centimeters",       "cm³",    1e-3],
489      ["cubic decimeters",        "dm³",    1],
490      ["cubic decameters",        "",       1e6],
491      ["cubic feet",              "ft³",    28.316846592],
492      ["cubic inches",            "",       0.016387064],
493      ["cubic kilometers",        "",       1e12],
494      ["cubic meters",            "m³",     1e3],
495      ["cubic mile",              "",       4.168181825e12],
496      ["cubic millimeters",       "",       1e-6],
497      ["cubic yards",             "",       764.554857984],
498      ["cups",                    "",       0.2365882365],
499      ["deciliters",              "",       0.1],
500      ["dram (imperial)",         "",       0.0035516328125000],
501      ["dram (US)",               "",       0.0036966911953125],
502      ["fluid ounces (imperial)", "fl oz",  0.0284130625],
503      ["fluid ounces (US)",       "fl oz",  0.0295735295625],
504      ["gallons (imperial)",      "gal",    4.54609],
505      ["gallons, dry (US)",       "",       4.40488377086],
506      ["gallons, liquid (US)",    "gal",    3.785411784],
507      ["gill (imperial)",         "gi",     0.1420653125],
508      ["gill (US)",               "gi",     0.11829411825],
509      ["kiloliters",              "kl",     1e3],
510      ["liters",                  "l or L", 1],
511      ["liters (1901-1964)",      "",       1.000028],
512      ["milliliters",             "ml",     1e-3],
513      ["microliters",             "µl",     1e-6],
514      ["nanoliters",              "nl",     1e-9],
515      ["picoliters",              "pl",     1e-12],
516      ["pints (imperial)",        "pt",     0.56826125],
517      ["pints, dry (US)",         "",       0.5506104713575],
518      ["pints, liquid (US)",      "pt",     0.473176473],
519      ["quarts (imperial)",       "qt",     1.1365225],
520      ["quarts, dry (US)",        "",       1.101220942715],
521      ["quarts, liquid (US)",     "qt",     0.946352946],
522      ["table spoons",            "",       0.01478676478125],
523      ["tea spoons",              "",       0.00492892159375]
524    ]}
525];
526
527function getQuantityByID(id) {
528  for (let i=0; i<quantities.length; i++){
529    if (id === quantities[i].id) return quantities[i];
530  }
531}
532
533function getQuantityFromURL() {
534  let pathParts = window.location.pathname.substr(1).split("/");
535  let lastURLPart = pathParts[1];
536  if (! lastURLPart) return null;
537
538  for (let i=0; i<quantities.length; i++) {
539    let quantity = quantities[i];
540    // .htm is for backward compatibility
541    if ((lastURLPart === quantity.id) || (lastURLPart === quantity.id + '.htm')) return quantity;
542  }
543  return null;
544}
545
546function onInitPage() {
547  inputFrom          = document.getElementById('inputFrom');
548  inputTo            = document.getElementById('inputTo');
549  selectQuantity     = document.getElementById('selectQuantity');
550  listQuantities     = document.getElementById('listQuantities');
551  selectFrom         = document.getElementById('selectFrom');
552  selectTo           = document.getElementById('selectTo');
553  precision          = localStorageGetDefault('precision', 6);
554  metaTagDescription = document.getElementsByName('description');
555
556  let listItems = '';
557  for (let i=0; i<quantities.length; i++) {
558    selectQuantity.innerHTML += '<option value="' + quantities[i].id + '">' + quantities[i].name + '</option>';
559    listItems += '<li id="list-item' + i + '"><a class="list-a" href="' + quantities[i].id + '" onclick="loadQuantity(\'' + quantities[i].id + '\'); return false;">' + quantities[i].name + '</a></li>';
560    // listItems += '<li id="list-item' + i + '"><a class="list-a" href="' + quantities[i].id + '">' + quantities[i].name + '</a></li>';
561  }
562  listQuantities.innerHTML = listItems;
563
564  // Check if url contains a quantity
565  let startQuantity = getQuantityFromURL();
566  if (! startQuantity) {
567    let id = localStorageGetDefault('lastQuantityID', defaultQuantityID);
568    startQuantity = getQuantityByID(id);
569  }
570  if (! startQuantity) startQuantity = getQuantityByID(defaultQuantityID);
571  loadQuantity(startQuantity.id);
572}
573
574document.onclick = function() {
575  closeSettings();
576};
577
578window.addEventListener('keydown', function (event) {
579  if (event.code === 'Escape')
580    closeSettings();
581});
582
583window.onpopstate = function() {
584  let urlQuantity = getQuantityFromURL();
585  selectQuantity.value = urlQuantity? urlQuantity.id : localStorageGetDefault('lastQuantityID', defaultQuantityID);
586  loadQuantity(selectQuantity.value, false);
587};
588
589function getURL(){
590  return quantity.id + '.htm';
591}
592
593function loadQuantity(quantityID, pushState=true) {
594  quantity = getQuantityByID(quantityID);
595  localStorage.setItem('lastQuantityID', quantityID);
596
597  document.title = "Convert " + quantity.name + ' - Unit Converter';
598
599  // Save in history if quantity is different from one in url
600  let urlQuantity = getQuantityFromURL();
601  if (pushState && ((! urlQuantity) || (quantity.id !== urlQuantity.id))) {
602    let url = getURL();
603    history.pushState(null, document.title, url);
604  }
605
606  selectFrom.innerHTML = '';
607  selectTo.innerHTML   = '';
608  let htmlOptions      = '';
609  for (let i=0; i<quantity.units.length; i++) {
610    let symbol       = quantity.units[i][1];
611    symbol           = (symbol.length > 0)? ' [' + symbol + ']' : '';
612    let title        = quantity.units[i][0] + symbol;
613    htmlOptions     += '<option>' + title + '</option>';
614  }
615  selectTo.innerHTML   = htmlOptions;
616  selectFrom.innerHTML = htmlOptions;
617
618  document.getElementById('quantity-title').innerHTML = 'Convert ' + quantity.name;
619  metaTagDescription.content                          = quantity.description;
620  inputFrom.value                                     = localStorageGetDefault('input' + quantity.name, 1);
621  loadUnits();
622  selectQuantity.value = quantityID;
623  let itemID='';
624  for (let i=0; i<quantities.length; i++) {
625    itemID = 'list-item' + i;
626    if (quantities[i].id === quantityID) document.getElementById(itemID).className = 'selectedItem';
627    else document.getElementById(itemID).className = '';
628  }
629
630  convert();
631}
632
633document.addEventListener("DOMContentLoaded", onInitPage, false);
634
635let lTempDiv = document.createElement("div");
636lTempDiv.innerHTML = "<!--[if lt IE 10]><i></i><![endif]-->";
637let isIE9AndLower = (lTempDiv.getElementsByTagName("i").length === 1);
638
639function isNumber(n) {
640  return !isNaN(parseFloat(n)) && isFinite(n);
641}
642
643function callServer(url, callback) {
644  let lXMLHttp = new XMLHttpRequest();
645  lXMLHttp.onreadystatechange=function(){
646    if (lXMLHttp.readyState === 4 && lXMLHttp.status === 200)
647      callback(lXMLHttp.responseText);
648  };
649
650  // Note: Use POST to prevent IE from caching the AJAX request
651  lXMLHttp.open("GET", url);
652  lXMLHttp.send();
653}
654
655function getCurrencyRates(callback, forceReload=false) {
656  if (forceReload || (!currencies) || (Date.now() - getCurrencyRates.cache_timestamp > 1000 * 60)){
657    let url = '/unitconverter/currencies.php';
658    callServer(url,
659      function(responseJSON) {
660        currencies = JSON.parse(responseJSON);
661        getCurrencyRates.cache_timestamp = Date.now();
662        callback(currencies);
663      }
664    );
665  } else callback(currencies);
666}
667
668function setConversionInfo(text){
669  let div     = document.getElementById('conversionInfo');
670  let divText = document.getElementById('conversionInfoText');
671  if (text === '') {
672    divText.innerHTML = '';
673    div.style.display = 'none';
674  } else {
675    divText.innerHTML = text;
676    div.style.display = 'flex';
677  }
678}
679
680function refreshCurrency(){
681  let imgRefresh = document.getElementById('imageRefresh');
682  imgRefresh.classList.add('animateRotate');
683  setTimeout(stopCurrencyRefreshAnimation, 5000);
684  convert(true);
685}
686
687function stopCurrencyRefreshAnimation(){
688  let imgRefresh = document.getElementById('imageRefresh');
689  if (imgRefresh) imgRefresh.classList.remove('animateRotate');
690}
691
692function convertInternal(fromUnitIndex, value, toUnitIndex, inputResult, forceReload=false) {
693  setConversionInfo('');
694  let quantity       = getQuantityByID(selectQuantity.value);
695  let unitFromFactor = quantity.units[fromUnitIndex][2];
696  let unitToFactor   = quantity.units[toUnitIndex][2];
697
698  if (quantity.name === 'Currency') {
699    getCurrencyRates(
700      function (currencies) {
701        let fromRate = (unitFromFactor === 'EUR')? 1 : currencies.rates[unitFromFactor];
702        let toRate   = (unitToFactor   === 'EUR')? 1 : currencies.rates[unitToFactor];
703        let rate     = toRate / fromRate;
704
705        value = value * rate;
706        let date = new Date(currencies.utctime);
707        setConversionInfo(
708          '<div style="font-size: 8px;">' + unitFromFactor + '/' + unitToFactor + ' exchange rate: ' + rate.toFixed(4) + ' at ' + date.toLocaleDateString() + ' 16:00 CET' +
709          '<br>The <a href="https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html" target="bank">ECB</a>' +  ' exchange rates are updated on work days around 16:00 CET</div>');
710        setTimeout(stopCurrencyRefreshAnimation, 1000);
711        inputResult.value = value.toFixed(precision);
712      }, forceReload);
713  }
714  else {
715    if (isNumber(unitFromFactor)) {
716      value = value * unitFromFactor;
717    }
718    else {
719      value = eval(unitFromFactor);
720    }
721
722    if (isNumber(unitToFactor)) {
723      value = value / unitToFactor;
724    }
725    else {
726      value = eval(quantity.units[toUnitIndex][3]);
727    }
728  }
729  inputResult.value = value.toFixed(precision);
730}
731
732function ie9minusConvert() {
733  // oninput does not work in IE8- and is buggy in IE9. So we use the onkeyup even for ie9- not ideal 
733(eg paste does not work),
734  // but that is how the old converter worked.
735  if (isIE9AndLower) convert();
736}
737
738function ie9minusConvertBack(){
739  if (isIE9AndLower) convertBack();
740}
741
742function swapUnits() {
743  let tempUnitIndex        = selectFrom.selectedIndex;
744  selectFrom.selectedIndex = selectTo.selectedIndex;
745  selectTo.selectedIndex   = tempUnitIndex;
746  saveUnits();
747  convert();
748}
749
750function findUnitIndexByName(name) {
751  for (let i=0; i<quantity.units.length; i++) {
752    if (quantity.units[i][0] === name) return i;
753  }
754  return -1;
755}
756
757function loadUnits(){
758  selectFrom.selectedIndex = findUnitIndexByName(localStorageGetDefault('from' + quantity.name, ''));
759  if (selectFrom.selectedIndex === -1) selectFrom.selectedIndex = quantity.defaultUnitIndex;
760  selectTo.selectedIndex   = findUnitIndexByName(localStorageGetDefault('to'   + quantity.name, ''));
761  if (selectTo.selectedIndex === -1) selectTo.selectedIndex = quantity.defaultUnitIndex;
762}
763
764function saveUnits(){
765  localStorage.setItem('from' + quantity.name, quantity.units[selectFrom.selectedIndex][0]);
766  localStorage.setItem('to'   + quantity.name, quantity.units[selectTo.selectedIndex][0]);
767}
768
769function onChangeUnit() {
770  saveUnits();
771  convert();
772}
773
774function convert(forceReload=false){
775  let fromValue = parseFloat(inputFrom.value);
776  if (isNaN(fromValue)) {
777    inputTo.value = '';
778  } else {
779    convertInternal(selectFrom.selectedIndex, fromValue, selectTo.selectedIndex, inputTo, forceReload);
780    localStorage.setItem('input' + quantity.name, fromValue.toString());
781  }
782}
783
784function convertBack() {
785  let fromValue = parseFloat(inputTo.value);
786
787  if (isNaN(fromValue)) {
788    inputFrom.value = '';
789  }
790  else {
791    let unitFromIndex = selectTo.selectedIndex;
792    let unitToIndex   = selectFrom.selectedIndex;
793
794    convertInternal(unitFromIndex, fromValue, unitToIndex, inputFrom);
795  }
796}
797
798function localStorageGetDefault(name, defaultValue) {
799  let value = localStorage.getItem(name);
800  return (value !== null)? value : defaultValue;
801}
802
803function stopEventPropagation(aEvent) {
804  if (aEvent.stopPropagation) {
805    aEvent.stopPropagation();
806  }
807  else if (window.event) {
808    window.event.cancelBubble = true;
809  }
810}
811
812function toggleSettings(event){
813  let divSettings = document.getElementById('settings');
814  divSettings.style.display = (divSettings.style.display !== 'block')? 'block' : 'none';
815  document.getElementById('inputOptionsDigits').value = precision;
816  stopEventPropagation(event);
817}
818
819function toggleInfoForm(event, div) {
820  if (div.clientHeight < 10) {
821    div.style.maxHeight = '0';
822    setTimeout(function(){div.style.display = 'block';setTimeout(function(){div.style.maxHeight = '450px';}, 10);}, 10);
823  } else {
824    div.style.maxHeight = '0';
825    setTimeout(function(){div.style.display = 'none';}, 500);
826  }
827  stopEventPropagation(event);
828}
829
830function toggleWhatsNew(event){
831  let divWhatsNew = document.getElementById('whatsNew');
832  toggleInfoForm(event, divWhatsNew);
833}
834
835function toggleTips(event){
836  let divTips = document.getElementById('tips');
837  toggleInfoForm(event, divTips);
838}
839
840function toggleDisclaimer(event){
841  let divDisclaimer  = document.getElementById('disclaimer');
842  toggleInfoForm(event, divDisclaimer);
843}
844
845function closeSettings(){
846  let divSettings = document.getElementById('settings');
847  divSettings.style.display = 'none';
848}
849
850function ie9minusSavePrecision(){
851  if (isIE9AndLower) savePrecision();
852}
853
854function savePrecision() {
855  precision = parseInt(document.getElementById('inputOptionsDigits').value);
856  if (isNumber(precision)) {
857    precision = (precision <= 17)? precision : 17;
858    precision = (precision >= 2)?  precision : 2;
859    localStorage.setItem('precision', precision);
860    convert();
861  }
862}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.