Improve calc
This commit is contained in:
parent
fbf55761d4
commit
ae32c8fb9b
2 changed files with 9 additions and 4 deletions
|
|
@ -38,6 +38,12 @@ function cal()
|
|||
try
|
||||
{
|
||||
Compute();
|
||||
p_variable=p_variable.replace(/[a-z]/,'');
|
||||
p_variable=p_variable.replace(/[A-Z]/,'');
|
||||
p_variable=p_variable.replace(/</,'');
|
||||
p_variable=p_variable.replace(/%/,'');
|
||||
p_variable=p_variable.replace(/;/,'');
|
||||
p_variable=p_variable.replace(/>/,'');
|
||||
p_variable=p_variable.replace(/ /g,"");
|
||||
p_variable=p_variable.replace(/\+/g,"+ ");
|
||||
p_variable=p_variable.replace(/-/g,"- ");
|
||||
|
|
@ -52,9 +58,8 @@ function cal()
|
|||
alert_box("Mauvaise formule\n"+p_variable);
|
||||
return false;
|
||||
}
|
||||
p_history=p_history+'<hr>'+p_variable;
|
||||
p_history+="="+result.toString();
|
||||
var str_sub="<hr><p> Total :"+p_variable+" = "+result.toString()+"</p>";
|
||||
p_history=p_variable+"="+result.toString()+'<br>'+p_history;
|
||||
var str_sub="Total :"+p_variable+" = "+result.toString();
|
||||
this.document.getElementById("sub_total").innerHTML=str_sub;
|
||||
this.document.getElementById("listing").innerHTML=p_history;
|
||||
this.document.getElementById('inp').value="";
|
||||
|
|
|
|||
|
|
@ -1064,7 +1064,7 @@ function show_calc()
|
|||
shtml += '<div style="float:right;height:10px;display:block;margin-top:2px;margin-right:2px"><span id="pin_calc1"><a class="input_text" onclick="pin(\'calc1\')" id="close_div">❉</a></span> <a onclick="removeDiv(\'calc1\');" href="javascript:void(0)" id="close_div">X</a></div>';
|
||||
shtml += '<div> <h2 class="title">Calculatrice</h2></div>';
|
||||
shtml += '<form name="calc_line" method="GET" onSubmit="cal();return false;" >Calculatrice simplifiée: écrivez simplement les opérations que vous voulez puis la touche retour. exemple : 1+2+3*(1/5) <input class="input_text" type="text" size="30" id="inp" name="calculator"> <input type="button" value="Efface tout" class="button" onClick="Clean();return false;" > <input type="button" class="button" value="Fermer" onClick="removeDiv(\'calc1\')" >';
|
||||
shtml += '</form><span id="result"> </span><br><span id="sub_total"> Taper une formule (ex 20*5.1) puis enter </span><br><span id="listing"> </span>';
|
||||
shtml += '</form><span class="highligth" style="display:block" id="sub_total"> Taper une formule (ex 20*5.1) puis enter </span><span style="display:block" id="listing"> </span>';
|
||||
|
||||
var obj = {id: sid, html: shtml,
|
||||
drag: true, style: ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue