Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 var p_history="";
00029 var p_variable="";
00030
00031 function cal()
00032 {
00033 p_variable=this.document.getElementById('inp').value;
00034 if (p_variable.search(/^\s*$/) !=-1)
00035 {
00036 return;
00037 }
00038 try
00039 {
00040 Compute();
00041 p_variable=p_variable.replace(/ /g,"");
00042 p_variable=p_variable.replace(/\+/g,"+ ");
00043 p_variable=p_variable.replace(/-/g,"- ");
00044 p_variable=p_variable.replace(/\
00045
00046 sub=eval(p_variable);
00047 var result=parseFloat(sub);
00048 result=Math.round(result*100)/100;
00049 }
00050 catch(exception)
00051 {
00052 alert("Mauvaise formule\n"+p_variable);
00053 return false;
00054 }
00055 p_history=p_history+'<hr>'+p_variable;
00056 p_history+="="+result.toString();
00057 var str_sub="<hr><p> Total :"+p_variable+" = "+result.toString()+"</p>";
00058 this.document.getElementById("sub_total").innerHTML=str_sub;
00059 this.document.getElementById("listing").innerHTML=p_history;
00060 this.document.getElementById('inp').value="";
00061 }
00062
00063
00064 function Clean()
00065 {
00066 this.document.getElementById('listing').innerHTML="";
00067 this.document.getElementById('result').innerHTML="";
00068 this.document.getElementById('sub_total').innerHTML="";
00069 this.document.getElementById('inp').value="";
00070 this.document.getElementById('inp').focus();
00071
00072 }
00073
00074 function Compute()
00075 {
00076 var tot=0;
00077 var ret="";
00078
00079 this.document.getElementById('inp').value="";
00080 this.document.getElementById('inp').focus();
00081 }