Changeset 2133

Show
Ignore:
Timestamp:
01/18/07 16:35:27
Author:
miyagawa
Message:

fix doConversion bug

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • misc/unitconverter.cgi

    r2132 r2133  
    133133<script> 
    134134var url = "[% cgi.url %]"; 
    135 function doConvert(input, from, to, unit) { 
     135function doConvert(from, to, unit) { 
    136136  var spinner = unit + "-spinner"; 
    137137  $(to).value = ''; // clear 
    138138  $(spinner).innerHTML = "<img src=\"[% cgi.url %]?spinner=1\" style=\"vertical-align:middle\" />"; 
    139   var query = "value=" + encodeURIComponent(input.value) + "&from=" + from + "&to=" + to; 
     139  var query = "value=" + encodeURIComponent($(from).value) + "&from=" + from + "&to=" + to; 
    140140  new Ajax.Request( 
    141141    url, 
     
    152152<h2>Currency</h2> 
    153153<p> 
    154 <input type="text" size="12" id="usd" onchange="doConvert(this, 'usd', 'jpy', 'currency')" /> USD = 
    155 <input type="text" size="12" id="jpy" onchange="doConvert(this, 'jpy', 'usd', 'currency')" /> JPY 
     154<input type="text" size="12" id="usd" onchange="doConvert('usd', 'jpy', 'currency')" /> USD = 
     155<input type="text" size="12" id="jpy" onchange="doConvert('jpy', 'usd', 'currency')" /> JPY 
    156156<span id="currency-spinner"></span> 
    157157</p> 
     
    159159<h2>Length</h2> 
    160160<p> 
    161 <input type="text" size="12" id="feet" onchange="doConvert(this, 'feet', 'inch', 'length');doConvert(this, 'inch', 'meter', 'length')" /> feet = 
    162 <input type="text" size="12" id="inch" onchange="doConvert(this, 'inch', 'meter', 'length');doConvert(this, 'inch', 'feet', 'length')" /> inches = 
    163 <input type="text" size="12" id="meter" onchange="doConvert(this, 'meter', 'inch', 'length');doConvert(this, 'inch', 'feet', 'length')" /> meters 
     161<input type="text" size="12" id="feet" onchange="doConvert('feet', 'inch', 'length');doConvert('inch', 'meter', 'length')" /> feet = 
     162<input type="text" size="12" id="inch" onchange="doConvert('inch', 'meter', 'length');doConvert('inch', 'feet', 'length')" /> inches = 
     163<input type="text" size="12" id="meter" onchange="doConvert('meter', 'inch', 'length');doConvert('inch', 'feet', 'length')" /> meters 
    164164<span id="length-spinner"></span> 
    165165</p> 
     
    167167<h2>Weight</h2> 
    168168<p> 
    169 <input type="text" size="12" id="pound" onchange="doConvert(this, 'pound', 'oz', 'weight');doConvert(this, 'pound', 'g', 'weight')" /> pounds = 
    170 <input type="text" size="12" id="oz" onchange="doConvert(this, 'oz', 'pound', 'weight');doConvert(this, 'pound', 'g', 'weight')" /> oz = 
    171 <input type="text" size="12" id="g" onchange="doConvert(this, 'g', 'pound', 'weight');doConvert(this, 'pound', 'oz', 'weight')" /> g 
     169<input type="text" size="12" id="pound" onchange="doConvert('pound', 'oz', 'weight');doConvert('pound', 'g', 'weight')" /> pounds = 
     170<input type="text" size="12" id="oz" onchange="doConvert('oz', 'pound', 'weight');doConvert('pound', 'g', 'weight')" /> oz = 
     171<input type="text" size="12" id="g" onchange="doConvert('g', 'pound', 'weight');doConvert('pound', 'oz', 'weight')" /> g 
    172172<span id="weight-spinner"></span> 
    173173</p> 
     
    175175<h2>Dimensions</h2> 
    176176<p> 
    177 <input type="text" size="12" id="sqf" onchange="doConvert(this, 'sqf', 'sqm', 'dimensions')" /> square feet = 
    178 <input type="text" size="12" id="sqm" onchange="doConvert(this, 'sqm', 'sqf', 'dimensions')" /> m<sup>2</sup> 
     177<input type="text" size="12" id="sqf" onchange="doConvert('sqf', 'sqm', 'dimensions')" /> square feet = 
     178<input type="text" size="12" id="sqm" onchange="doConvert('sqm', 'sqf', 'dimensions')" /> m<sup>2</sup> 
    179179<span id="dimensions-spinner"></span> 
    180180</p>