|
<script language="JavaScript"> <!-- up=op=perval=''; dollar=10.11; resetblock=1; function calc (oper) { with (document.calc) { eval('up='+up+op+info.value); if (op!='') info.value=up; if (isNaN(up)) { info.value='Error'; op='';up='' } resetblock=1; } } function clno(value) { with (document.calc) if (value=='sign') { if (!resetblock) { temp=info.value.substr(0,1); if (temp=='-') info.value=info.value.substr(1); else if (temp=='+') info.value='-'+info.value.substr(1); else info.value='-'+info.value; } } else if (value=='rd') { info.value=info.value/dollar; if (isNaN(info.value)) {info.value='Error'; op='';up=''} } else if (value=='dr') { info.value=dollar*info.value; if (isNaN(info.value)) {info.value='Error'; op='';up=''} } else if (value=='clear') { up=op=''; resetblock=1; info.value='0'; } else if (value=='ce') { resetblock=1; info.value='0'; } else if (value=='+' || value=='-' || value=='*' || value=='/') { if (op!='') calc(1); else up=info.value; op=value; resetblock=1; } else if (value=='calc') { calc(0); up=op=''; } else if ((value>='0' && value<='9') || (value=='.')) { if (resetblock) info.value=value,resetblock=0; else info.value=info.value+value; } } function area(pos,value) { document.write('<area shape="rect" coords="'+pos+'" alt="'+value+'" href="javascript:clno('+"'"+value+"'"+')">'); } document.write('<form name="calc">'); document.write('<input name="info" type="text" size="15" maxlen="20" value="0" onfocus="preval=document.calc.info.value">'); document.write('<br>'); document.write('<img src="calc.gif" width="170" height="135" border="0" hspace="0" usemap="#calcpad" vspace="5">'); document.write('</form>'); document.write('<map name="calcpad">'); area("0,0,30,30","1"); area("35,0,65,30","2"); area("70,0,100,30","3"); area("105,0,135,30","/"); area("140,0,170,30","clear");
area("0,35,30,65","4"); area("35,35,65,65","5"); area("70,35,100,65","6"); area("105,35,135,65","*"); area("140,35,170,65","ce");
area("0,70,30,100","7"); area("35,70,65,100","8"); area("70,70,100,100","9"); area("105,70,135,100","-"); area("140,70,170,135","calc");
area("0,105,30,135","0"); area("35,105,65,135","sign"); area("70,105,100,135","."); area("105,105,135,135","+");
document.write(''); //--> </script>
|