new file: Files/flashplayer_32_sa.exe new file: favicon.ico new file: globe.gif new file: imgs/download.png new file: imgs/zuck.jpg new file: index.html new file: other.ico new file: script.js new file: site.webmanifest new file: sitemap.html new file: styles/backround.css new file: styles/border.css new file: styles/fonts/Titillium_Web/OFL.txt new file: styles/fonts/Titillium_Web/TitilliumWeb-Black.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Bold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-BoldItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLight.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-ExtraLightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Italic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Light.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-LightItalic.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-Regular.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBold.ttf new file: styles/fonts/Titillium_Web/TitilliumWeb-SemiBoldItalic.ttf new file: styles/fonts/webfontkit-20221027-163353/generator_config.txt new file: styles/fonts/webfontkit-20221027-163353/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-163353/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/stylesheet.css new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-demo.html new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff new file: styles/fonts/webfontkit-20221027-163353/titilliumweb-extralight-webfont.woff2 new file: styles/fonts/webfontkit-20221027-165950/generator_config.txt new file: styles/fonts/webfontkit-20221027-165950/specimen_files/grid_12-825-55-15.css new file: styles/fonts/webfontkit-20221027-165950/specimen_files/specimen_stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/stylesheet.css new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-demo.html new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff new file: styles/fonts/webfontkit-20221027-165950/titilliumweb-bold-webfont.woff2 new file: styles/style.css new file: tools/2048/.gitignore new file: tools/2048/.jshintrc new file: tools/2048/CONTRIBUTING.md new file: tools/2048/LICENSE.txt new file: tools/2048/README.md new file: tools/2048/Rakefile new file: tools/2048/favicon.ico new file: tools/2048/index.html new file: tools/2048/js/animframe_polyfill.js new file: tools/2048/js/application.js new file: tools/2048/js/bind_polyfill.js new file: tools/2048/js/classlist_polyfill.js new file: tools/2048/js/game_manager.js new file: tools/2048/js/grid.js new file: tools/2048/js/html_actuator.js new file: tools/2048/js/keyboard_input_manager.js new file: tools/2048/js/local_storage_manager.js new file: tools/2048/js/tile.js new file: tools/2048/meta/apple-touch-icon.png new file: tools/webretro/cores/neocd_libretro.js new file: tools/webretro/cores/neocd_libretro.wasm new file: tools/webretro/cores/nestopia_libretro.js new file: tools/webretro/cores/nestopia_libretro.wasm new file: tools/webretro/cores/o2em_libretro.js new file: tools/webretro/cores/o2em_libretro.wasm new file: tools/webretro/cores/opera_libretro.js new file: tools/webretro/cores/opera_libretro.wasm
483 lines
24 KiB
HTML
483 lines
24 KiB
HTML
<!doctype html>
|
|
<html lang="en"><!-- #BeginTemplate "/Templates/Main.dwt" --><!-- DW6 -->
|
|
|
|
<!-- Mirrored from www.mathsisfun.com/unit-conversion-tool-old.php by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 29 Oct 2022 00:36:33 GMT -->
|
|
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
|
|
<head>
|
|
<!-- #BeginEditable "doctitle" -->
|
|
<title>Unit Conversion Tool</title>
|
|
|
|
<script>
|
|
<!--- Hide script from old browsers
|
|
|
|
// JavaScript based Scientific Calculator and demonstration of Math.* objects
|
|
// (C) 1996-7 Mohamed Ishan. 6-11-96 Completion time = 3 hours and 25 mins.
|
|
// anon4c9c@nyx.net
|
|
|
|
var been_there = 0;
|
|
var decimal_pt = 6; // global variable to hold the decimal point of numbers.
|
|
|
|
|
|
// This function makes sure a floating number has the correct
|
|
// decimal points as that defined by the user. Decimal point is
|
|
// initially, initlized to 6 points after the "."
|
|
|
|
function dec_pt(Value){
|
|
var temp, dec_pts = decimal_pt;
|
|
|
|
Value += "";
|
|
temp = Value.indexOf(".");
|
|
Value1 = Value.substring(0,temp) ;
|
|
Value2 = Value.substring(temp+1,temp+dec_pts+1) + "." + Value.charAt(temp+dec_pts+2);
|
|
Value2 = Math.round(Value2);
|
|
return(Value1 + "." + Value2);
|
|
|
|
}
|
|
|
|
|
|
|
|
// compute(f) takes a form as an input, evaulates the result.value
|
|
// from the from.. and displays the output of the mathematical functions
|
|
// defined. This function also makes sure a number has a decimal point or
|
|
// not, if a number is a float or not..if so then it's sent off to dec_pt
|
|
// to be rounded off to the correct decimal point.
|
|
|
|
function compute(f) {
|
|
f.result.value = eval(f.result.value);
|
|
temp = f.result.value.indexOf(".");
|
|
|
|
if(temp != -1) {
|
|
f.result.value = dec_pt(f.result.value);
|
|
}
|
|
|
|
been_there=1; // tell jS that a value exists
|
|
} // inside result
|
|
|
|
|
|
|
|
function calcx(f, nums_oper) {
|
|
|
|
if (been_there==1) {
|
|
f.result.value = "";
|
|
been_there = 0 ;
|
|
}
|
|
f.result.value += nums_oper;
|
|
}
|
|
|
|
|
|
function ext_calc(f,oper) {
|
|
f.result.value = oper; been_there=1;
|
|
}
|
|
|
|
function Clear(f) {
|
|
f.result.value = "";
|
|
}
|
|
|
|
function changeDecimalPT(f) {
|
|
decimal_pt= parseInt(f.dec.value,10);
|
|
PI = dec_pt(Math.PI);
|
|
}
|
|
|
|
// end hiding from old browsers -->
|
|
</script>
|
|
|
|
|
|
|
|
<!-- #EndEditable -->
|
|
<meta name="keywords" content="math, maths, mathematics, school, homework, education">
|
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
|
<meta name="HandheldFriendly" content="true">
|
|
<meta http-equiv="pics-label" content='(PICS-1.1 "http://www.classify.org/safesurf/" L gen true for "http://www.mathsisfun.com" r (SS~~000 1))'>
|
|
<link rel="stylesheet" type="text/css" href="style3.css" />
|
|
<script src="main3.js" type="text/javascript"></script>
|
|
</head>
|
|
|
|
<body id="bodybg">
|
|
<div class="bg">
|
|
<div id="stt"></div>
|
|
<div id="hdr"></div>
|
|
<div id="logo"><a href="index.html"><img src="images/style/logo.svg" alt="Math is Fun" /></a></div>
|
|
<div id="gtran"><script type="text/javascript">document.write(getTrans());</script></div>
|
|
<div id="gplus"><script type="text/javascript">document.write(getGPlus());</script></div>
|
|
<div id="adTopOuter" class="centerfull noprint">
|
|
<div id="adTop">
|
|
<script type="text/javascript">document.write(getAdTop());</script>
|
|
</div>
|
|
</div>
|
|
<div id="adHide">
|
|
<div id="showAds1"><a href="javascript:showAds()">Show Ads</a></div>
|
|
<div id="hideAds1"><a href="javascript:hideAds()">Hide Ads</a><br>
|
|
<a href="about-ads.html">About Ads</a></div>
|
|
</div>
|
|
<div id="menuWide" class="menu">
|
|
<script type="text/javascript">document.write(getMenu(0));</script>
|
|
</div>
|
|
<div id="linkto">
|
|
<div id="linktort"><script type="text/javascript">document.write(getLinks());</script></div>
|
|
</div>
|
|
<div id="search" role="search"><script type="text/javascript">document.write(getSearch());</script></div>
|
|
<div id="menuSlim" class="menu">
|
|
<script type="text/javascript">document.write(getMenu(1));</script>
|
|
</div>
|
|
<div id="menuTiny" class="menu">
|
|
<script type="text/javascript">document.write(getMenu(2));</script>
|
|
</div>
|
|
<div id="extra"></div>
|
|
</div>
|
|
<div id="content" role="main"><!-- #BeginEditable "Body" -->
|
|
<h1 align="center">Unit Conversion Tool</h1>
|
|
<p align="center"><i>Here is a handy little tool you can use to do all types of conversion.<br/>
|
|
It is small but powerful!
|
|
</i></p>
|
|
<script LANGUAGE="JavaScript">
|
|
<!-- ;
|
|
// from:
|
|
// Costas Malamas
|
|
// Thessaloniki, Greece
|
|
// http://www.nyx.net/~cmalamas
|
|
//
|
|
// ---------------------------------------------------- version: 28 Sept. 1998
|
|
|
|
// *** Global Variable & Data Definitions **************************************
|
|
initprop = 7;
|
|
|
|
var property = new Array();
|
|
var unit = new Array();
|
|
var factor = new Array();
|
|
var select = new Array();
|
|
|
|
property[0] = "Acceleration"; select[0] = new Array(0,2);
|
|
unit[0] = new Array("Meter/sq.sec (m/sec^2)", "Foot/sq.sec (ft/sec^2)", "G Force (g)", "Galileo (gal)", "Inch/sq.sec (in/sec^2)");
|
|
factor[0] = new Array(1, .3048, 9.806650, .01, 2.54E-02);
|
|
|
|
property[1] = "Area"; select[1] = new Array(0,9);
|
|
unit[1] = new Array("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] = new Array(1, 4046.856, 100, 1E-28, 10000, 1011.71413184285, .0001, 1000000, 5.067075E-10, 9.290304E-02, 6.4516E-04, 2589988, .8361274);
|
|
|
|
property[2] = "Torque"; select[2] = new Array(0,3);
|
|
unit[2] = new Array("Newton-meter (N m)", "Dyne-centimeter(dy cm)", "Kgrf-meter (kgf m)", "lbf-inch (lbf in)", "lbf-foot (lbf ft)");
|
|
factor[2] = new Array(1, .0000001, 9.806650, .1129848, 1.355818);
|
|
|
|
property[3] = "Electricity"; select[3] = new Array(2,3);
|
|
unit[3] = new Array("Coulomb (Cb)", "Abcoulomb", "Ampere hour (A hr)", "Faraday (F)", "Statcoulomb", "Millifaraday (mF)", "Microfaraday (mu-F)", "Picofaraday (pF)");
|
|
factor[3] = new Array(1, 10, 3600, 96521.8999999997, .000000000333564, 96.5219, 9.65219E-02, 9.65219E-05);
|
|
|
|
property[4] = "Energy"; select[4] = new Array(1,2);
|
|
unit[4] = new Array("Joule (J)", "kiloJoule (kJ)", "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] = new Array(1, 1000, 1055.87, 1054.35, 4.1868, 4.19002, 4.184, 1.6021E-19, .0000001, 1.355818, 4.214011E-02, 2684077.3, 4186.8, 4190.02, 3600000, 4.2E9, 1, 3600, 1);
|
|
|
|
property[5] = "Force"; select[5] = new Array(0,2);
|
|
unit[5] = new Array("Newton (N)", "Dyne (dy)", "Kilogram force (kgf)", "Kilopond force (kpf)", "Kip (k)", "Ounce force (ozf)", "Pound force (lbf)", "Poundal");
|
|
factor[5] = new Array(1, .00001, 9.806650, 9.806650, 4448.222, .2780139, .4535924, .138255);
|
|
|
|
property[6] = "Force / Length"; select[6] = new Array(0,1);
|
|
unit[6] = new Array("Newton/meter (N/m)", "Pound force/inch (lbf/in)", "Pound force/foot (lbf/ft)");
|
|
factor[6] = new Array(1, 175.1268, 14.5939);
|
|
|
|
property[7] = "Length"; select[7] = new Array(0,11);
|
|
unit[7] = new Array("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] = new Array(1, 1E-10, 1.49598E11, .000254, .01, 1000, 1.143, 4.2323E-03, 1.8288, 201.168, 1E-15, .3048, .0254, 5556, 5556, 9.46055E+15, .000001, .0000254, .001, 1E-9, 1852, 1853.184, 1852, 1609.344, 3.08374E+16, 4.217518E-03, 1E-12, .0003514598, 5.0292, .9144);
|
|
|
|
property[8] = "Light"; select[8] = new Array(3,7);
|
|
unit[8] = new Array("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] = new Array(1, 10000, 10.76391, 10.76391, 10.76391, 3.14159250538575, 31415.9250538576, 1, 10000);
|
|
|
|
property[9] = "Mass"; select[9] = new Array(0,7);
|
|
unit[9] = new Array("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] = new Array(1, .001, 1e-6, .000000001, .0002, 50.80235, 45.35924, .4535924, .3732417, .02834952, .03110348, 14.5939, .02916667, 1016.047, 907.1847, 1000, 1000);
|
|
|
|
property[10] = "Mass Flow"; select[10] = new Array(0,1);
|
|
unit[10] = new Array("Kilogram/second (kgr/sec)", "Pound mass/sec (lbm/sec)", "Pound mass/min (lbm/min)");
|
|
factor[10] = new Array(1, .4535924, .007559873);
|
|
|
|
property[11] = "Density & Mass capacity"; select[11] = new Array(0,4);
|
|
unit[11] = new Array("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] = new Array(1, .01711806, 1000, 16.01846, 27679.91, 6.236027, 7.489152, 1729.994, 99.77644, 119.8264, 515.379, 1328.939);
|
|
|
|
property[12] = "Power"; select[12] = new Array(1,5);
|
|
unit[12] = new Array("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] = new Array(1, 1000, 1000000, .001, .2930667, 1054.35, 17.5725, .2928751, 4.184, 6.973333E-02, .0000001, .0003766161, .02259697, 1.355818, 745.7, 746, 9809.5, 735.499, 745.7, 69.7333, 4184);
|
|
|
|
property[13] = "Pressure & Stress"; select[13] = new Array(0,1);
|
|
unit[13] = new Array("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] = new Array(1, 101325, 98066.5, 100000, 1333.22, 98.0638, 10000, 98066.5, 9.80665, 6894757, 100, 133.3224, 1, 1000, 1000000, 47.88026, 47.88026, 6894.757, 133.322);
|
|
|
|
// !!! Caution: Temperature requires an increment as well as a multiplying factor
|
|
// !!! and that's why it's handled differently
|
|
// !!! Be VERY careful in how you change this behavior
|
|
property[14] = "Temperature"; select[14] = new Array(0,1);
|
|
unit[14] = new Array("Degrees Celsius ('C)", "Degrees Fahrenheit ('F)", "Degrees Kelvin ('K)", "Degrees Rankine ('R)");
|
|
factor[14] = new Array(1, 0.555555555555, 1, 0.555555555555);
|
|
tempIncrement = new Array(0, -32, -273.15, -491.67);
|
|
|
|
property[15] = "Time"; select[15] = new Array(1,0);
|
|
unit[15] = new Array("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] = new Array(1, 8.640E4, 86164.09, 3600, 3590.17, 60, 60, 2628000, .9972696, 31536000, 31556930, 31558150);
|
|
|
|
property[16] = "Velocity & Speed"; select[16] = new Array(3,5);
|
|
unit[16] = new Array("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] = new Array(1, 5.08E-03, .3048, .2777778, .5144444, .44707, .514444, 26.8224, 1609.344, 299792458, 340.0068750);
|
|
|
|
property[17] = "Viscosity"; select[17] = new Array(0,6);
|
|
unit[17] = new Array("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] = new Array(1, .001, .000001, 9.290304E-02, .1, 1.488164, 1.488164, 47.88026, 10, 47.88026, .0001);
|
|
|
|
property[18] = "Volume & Capacity"; select[18] = new Array(16,12);
|
|
unit[18] = new Array("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] = new Array(1, .000001, .000000001, 1233.482, .1589873, .002359737, .03523907, .0002365882, .00002957353, .02831685, .004546087, .004404884, .003785412, .0001420652, .0001182941, .00001638706, .001, .001000028, .00002841305, .00002957353, 8.8097680E-03, .0005506105, 4.7317650E-04, .001101221, 9.46353E-04, 1, .00001478676, .000004928922, 2.831685, .7645549);
|
|
|
|
property[19] = "Volume Flow"; select[19] = new Array(2,5);
|
|
unit[19] = new Array("Cubic meter/second", "Cubic foot/second", "Cubic foot/minute", "Cubic inches/minute", "Gallons (US,liq)/minute)", "Liters/second");
|
|
factor[19] = new Array(1, .02831685, .0004719474, 2.731177E-7, 6.309020E-05, 0.001);
|
|
|
|
|
|
// *** Functions *************************************************************
|
|
|
|
function UpdateUnitMenu(propMenu, unitMenu, preselect){
|
|
// Updates the units displayed in the unitMenu according to the selection of
|
|
// property in the propMenu.
|
|
var i;
|
|
|
|
i = propMenu.selectedIndex;
|
|
//if (preselect>0) {
|
|
selectarray = select[i];
|
|
selectindex=selectarray[preselect];
|
|
//} else {
|
|
// selectindex=0;
|
|
//}
|
|
FillMenuWithArray(unitMenu, unit[i], selectindex);
|
|
}
|
|
|
|
function FillMenuWithArray(myMenu, myArray, selectindex){
|
|
// Fills the options of myMenu with the elements of myArray.
|
|
// !CAUTION!: It replaces the elements, so old ones will be deleted.
|
|
var i;
|
|
|
|
myMenu.length = myArray.length;
|
|
for(i = 0; i < myArray.length; i++) {
|
|
myMenu.options[i].text = myArray[i];
|
|
if (i==selectindex) { myMenu.options[i].selected = true; }
|
|
}
|
|
}
|
|
|
|
function CalculateUnit(sourceForm, targetForm){
|
|
// A simple wrapper function to validate input before making the conversion
|
|
var sourceValue = sourceForm.unit_input.value;
|
|
|
|
// First check if the user has given numbers or anything that can be made to
|
|
// one...
|
|
sourceValue = parseFloat(sourceValue);
|
|
if ( !isNaN(sourceValue) || sourceValue == 0){
|
|
// If we can make a valid floating-point number, put it in the
|
|
// text box and convert!
|
|
sourceForm.unit_input.value = sourceValue;
|
|
ConvertFromTo(sourceForm, targetForm);
|
|
} else {
|
|
alert("What you gave me cannot be converted or is zero!");
|
|
}
|
|
}
|
|
|
|
function ConvertFromTo(sourceForm, targetForm){
|
|
// Converts the contents of the sourceForm input box to the units specified in
|
|
// the targetForm unit menu and puts the result in the targetForm input box.
|
|
// In other words, this is the heart of the whole script...
|
|
var propIndex;
|
|
var sourceIndex;
|
|
var sourceFactor;
|
|
var targetIndex;
|
|
var targetFactor;
|
|
var result;
|
|
|
|
// Start by checking which property we are working in...
|
|
propIndex = document.property_form.the_menu.selectedIndex;
|
|
|
|
// Let's determine what unit are we converting FROM (i.e. source) and the
|
|
// factor needed to convert that unit to the base unit.
|
|
sourceIndex = sourceForm.unit_menu.selectedIndex;
|
|
sourceFactor = factor[propIndex][sourceIndex];
|
|
|
|
// Cool! Let's do the same thing for the target unit --the units we are
|
|
// converting TO:
|
|
targetIndex = targetForm.unit_menu.selectedIndex;
|
|
targetFactor = factor[propIndex][targetIndex];
|
|
|
|
// Simple, huh? let's do the math: a) convert the source TO the base unit:
|
|
// (The input has been checked by the CalculateUnit function).
|
|
result = sourceForm.unit_input.value;
|
|
// Handle Temperature increments!
|
|
if (property[propIndex] == "Temperature"){
|
|
result = parseFloat(result) + tempIncrement[sourceIndex];
|
|
}
|
|
result = result * sourceFactor;
|
|
|
|
// not done yet... now, b) use the targetFactor to convert FROM the base unit
|
|
// to the target unit...
|
|
result = result / targetFactor;
|
|
// Again, handle Temperature increments!
|
|
if (property[propIndex] == "Temperature"){
|
|
result = parseFloat(result) - tempIncrement[targetIndex];
|
|
}
|
|
|
|
// Ta-da! All that's left is to update the target input box:
|
|
targetForm.unit_input.value = result;
|
|
}
|
|
|
|
function ClearForm(){
|
|
// Clears the input boxes...
|
|
document.form_A.unit_input.value = "";
|
|
document.form_B.unit_input.value = "";
|
|
}
|
|
|
|
// *** End of Main Script ****************************************************
|
|
// end hide -->
|
|
</script>
|
|
|
|
<div align="center">
|
|
<center>
|
|
|
|
<table border="1" cellpadding="0" cellspacing="0">
|
|
<tr>
|
|
<td valign="top" align="center">
|
|
<table border="0" cellpadding="10" cellspacing="0">
|
|
<tr>
|
|
<td colspan="2" bgcolor="#FFCCFF">
|
|
<form name="property_form">
|
|
<p><font face="Arial, Helvetica"><b class="large">Property:</b></font>
|
|
<select NAME="the_menu"
|
|
size="1"
|
|
onChange="UpdateUnitMenu(this, document.form_A.unit_menu, 0); UpdateUnitMenu(this, document.form_B.unit_menu, 1)">
|
|
<option>_____________________________
|
|
<!-- The underscore line above pre-stretches the drop-down menu to a sufficient length -->
|
|
</option>
|
|
<option> </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
</select>
|
|
</p>
|
|
</form>
|
|
<script LANGUAGE="JavaScript">
|
|
<!-- ;
|
|
// This fragment initializes the property dropdown menu using the data defined
|
|
// above in the 'Data Definitions' section
|
|
FillMenuWithArray(document.property_form.the_menu, property, initprop);
|
|
|
|
// end hide -->
|
|
</script>
|
|
<p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td valign="middle" align="center">
|
|
<form name="form_A" onSubmit="return false">
|
|
<p><font face="arial, helvetica"><b><span class="large">A</span></b></font>
|
|
<select
|
|
NAME="unit_menu" size="1">
|
|
<option>------- Select a Property ------- </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
</select>
|
|
<input TYPE="text" NAME="unit_input" SIZE="20" MAXLENGTH="20" VALUE>
|
|
<input
|
|
TYPE="button" name="unit_submit" VALUE="Convert to B"
|
|
onClick="CalculateUnit(this.form, document.form_B)">
|
|
</p>
|
|
</form>
|
|
<form name="form_B" onSubmit="return false">
|
|
<p><font face="arial, helvetica"><b><span class="large">B</span></b></font>
|
|
<select
|
|
NAME="unit_menu" size="1">
|
|
<option>------- Select a Property ------- </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
<option> </option>
|
|
</select>
|
|
<input TYPE="text" NAME="unit_input" SIZE="20" MAXLENGTH="20" VALUE>
|
|
<input
|
|
TYPE="button" name="unit_submit" VALUE="Convert to A"
|
|
onClick="CalculateUnit(this.form, document.form_A)">
|
|
</p>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td valign="middle" align="right">
|
|
<form name="util_form">
|
|
<div align="center">
|
|
<center>
|
|
<p>
|
|
<input TYPE="button" name="clear_form" VALUE=" Clear Form "
|
|
onClick="ClearForm()">
|
|
</p>
|
|
</center>
|
|
</div>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
</center>
|
|
</div>
|
|
<script LANGUAGE="JavaScript">
|
|
<!-- ;
|
|
// *** Start-up and refresh/reload Commands **********************************
|
|
//
|
|
// Since the first property is automatically selected, initialize the unit
|
|
// menus with its units too...
|
|
// .. But, only initialize unit menus when the Property menu hasn't been used
|
|
//if (document.property_form.the_menu.selectedIndex == 0){
|
|
if (document.images){
|
|
// Also, define the window name for correct targeting
|
|
window.name="JSUC_main";
|
|
selectarray = select[initprop];
|
|
FillMenuWithArray(document.form_A.unit_menu, unit[initprop],selectarray[0]);
|
|
FillMenuWithArray(document.form_B.unit_menu, unit[initprop],selectarray[1]);
|
|
} else {
|
|
// Check to see if the browser will let you resize the drop-down
|
|
// menus. The user will already have seen errors, but at least
|
|
// give him/her a clue...
|
|
alert("The browser you are using won't let you run the conversion tool correctly. Maybe you should upgrade...");
|
|
}
|
|
//}
|
|
// end hide -->
|
|
</script>
|
|
|
|
<div class="related">
|
|
<a href="temperature-conversion.html">Converting Temperatures (Celsius and Fahrenheit)</a>
|
|
<a href="metric-imperial-conversion-charts.html">Metric - Imperial Conversion Charts</a>
|
|
<a href="imperial-metric-conversion.html">How to Convert Imperial to Metric</a>
|
|
<a href="metric-imperial-conversion.html">How to Convert Metric to Imperial</a>
|
|
<a href="length-conversion.html">How to Convert Lengths</a>
|
|
<a href="area-conversion.html">How to Convert Areas</a>
|
|
<a href="volume-conversion.html">How to Convert Volumes</a>
|
|
<a href="accuracy-precision.html">Accuracy and Precision</a>
|
|
</div>
|
|
<!-- #EndEditable --></div>
|
|
<div id="adend" class="centerfull noprint">
|
|
<script type="text/javascript">document.write(getAdEnd());</script>
|
|
</div>
|
|
<div id="footer" class="centerfull noprint">
|
|
<script type="text/javascript">document.write(getFooter());</script>
|
|
</div>
|
|
<div id="copyrt">
|
|
Copyright © 2016 MathsIsFun.com
|
|
</div>
|
|
|
|
<script type="text/javascript">document.write(getBodyEnd());</script>
|
|
</body>
|
|
<!-- #EndTemplate -->
|
|
<!-- Mirrored from www.mathsisfun.com/unit-conversion-tool-old.php by HTTrack Website Copier/3.x [XR&CO'2014], Sat, 29 Oct 2022 00:36:33 GMT -->
|
|
</html>
|