From ae32c8fb9b73eac22f1cc6c4a5418f0df7cde81e Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Tue, 28 Nov 2017 19:17:40 +0100 Subject: [PATCH] Improve calc --- html/js/calc.js | 11 ++++++++--- html/js/scripts.js | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/html/js/calc.js b/html/js/calc.js index dd42d0785..5460a7bfb 100644 --- a/html/js/calc.js +++ b/html/js/calc.js @@ -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(/ /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+'
'+p_variable; - p_history+="="+result.toString(); - var str_sub="

Total :"+p_variable+" = "+result.toString()+"

"; + p_history=p_variable+"="+result.toString()+'
'+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=""; diff --git a/html/js/scripts.js b/html/js/scripts.js index 47e26a07f..ae6fd7afb 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1064,7 +1064,7 @@ function show_calc() shtml += '
X
'; shtml += '

Calculatrice

'; shtml += '
Calculatrice simplifiée: écrivez simplement les opérations que vous voulez puis la touche retour. exemple : 1+2+3*(1/5) '; - shtml += '

Taper une formule (ex 20*5.1) puis enter
'; + shtml += ' Taper une formule (ex 20*5.1) puis enter '; var obj = {id: sid, html: shtml, drag: true, style: ''