noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 173/219: Improve calc


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 173/219: Improve calc
Date: Mon, 18 Dec 2017 13:22:58 -0500 (EST)

sparkyx pushed a commit to branch master
in repository noalyss.

commit ae32c8fb9b73eac22f1cc6c4a5418f0df7cde81e
Author: Dany De Bontridder <address@hidden>
Date:   Tue Nov 28 19:17:40 2017 +0100

    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 dd42d07..5460a7b 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(/%/,'');
+        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="";
diff --git a/html/js/scripts.js b/html/js/scripts.js
index 47e26a0..ae6fd7a 100644
--- a/html/js/scripts.js
+++ b/html/js/scripts.js
@@ -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">&#10057;</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: ''



reply via email to

[Prev in Thread] Current Thread [Next in Thread]