noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
Functions | Variables
calc.js File Reference

This file show a little online calculator, in the caller the span id result, listing, the id form calc_line and the. More...

Go to the source code of this file.

Functions

function cal ()
function Clean ()
function Compute ()

Variables

var p_history = ""
var p_variable = ""

Detailed Description

This file show a little online calculator, in the caller the span id result, listing, the id form calc_line and the.

Definition in file calc.js.


Function Documentation

function cal ( )

Definition at line 31 of file calc.js.

References alert(), Compute(), g(), p_history, and p_variable.

{
    p_variable=this.document.getElementById('inp').value;
    if (p_variable.search(/^\s*$/) !=-1)
    {
        return;
    }
    try
    {
        Compute();
        p_variable=p_variable.replace(/ /g,"");
        p_variable=p_variable.replace(/\+/g,"+ ");
        p_variable=p_variable.replace(/-/g,"- ");
        p_variable=p_variable.replace(/\//g,"/ ");

        sub=eval(p_variable);
        var result=parseFloat(sub);
        result=Math.round(result*100)/100;
    }
    catch(exception)
    {
        alert("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>";
    this.document.getElementById("sub_total").innerHTML=str_sub;
    this.document.getElementById("listing").innerHTML=p_history;
    this.document.getElementById('inp').value="";
}
function Clean ( )

Definition at line 64 of file calc.js.

{
    this.document.getElementById('listing').innerHTML="";
    this.document.getElementById('result').innerHTML="";
    this.document.getElementById('sub_total').innerHTML="";
    this.document.getElementById('inp').value="";
    this.document.getElementById('inp').focus();

}
function Compute ( )

Definition at line 74 of file calc.js.

Referenced by cal().

{
    var tot=0;
    var ret="";

    this.document.getElementById('inp').value="";
    this.document.getElementById('inp').focus();
}

Variable Documentation

var p_history = ""

Definition at line 28 of file calc.js.

Referenced by cal().

var p_variable = ""

Definition at line 29 of file calc.js.

Referenced by cal().

 All Data Structures Namespaces Files Functions Variables Enumerations