altocompta/html/js/calc.js
Dany De Bontridder 395865032b Merged revisions 4193-4197 via svnmerge from
file:///home/developper/svn/phpcompta/branches/rel560

........
  r4194 | danydb | 2011-09-02 09:51:23 +0200 (Fri, 02 Sep 2011) | 2 lines
  
  show needed version
........
  r4195 | danydb | 2011-09-12 21:00:00 +0200 (Mon, 12 Sep 2011) | 1 line
  
  fix bug when user has no ledger.
........
  r4196 | danydb | 2011-09-12 22:15:27 +0200 (Mon, 12 Sep 2011) | 1 line
  
  Code cleaning, remove JS_ definition +
........
  r4197 | danydb | 2011-09-12 22:24:14 +0200 (Mon, 12 Sep 2011) | 1 line
  
  update constant.php : ready for prod
........
2011-09-15 08:59:10 +00:00

76 lines
2.2 KiB
JavaScript

/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*! \file
* \brief This file show a little online calculator, in the caller
* the span id result, listing, the id form calc_line and the
*
*
*/
var p_history="";
var p_variable="";
// add input
function cal()
{
p_variable=this.document.getElementById('inp').value;
if (p_variable.search(/^\s*$/) !=-1)
{
return;
}
try
{
Compute();
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><b><i> Total :"+p_variable+" = "+result.toString()+"<I></b>";
this.document.getElementById("sub_total").innerHTML=str_sub;
this.document.getElementById("listing").innerHTML=p_history;
this.document.getElementById('inp').value="";
}
// Clean
//
function Clean()
{
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()
{
var tot=0;
var ret="";
this.document.getElementById('inp').value="";
this.document.getElementById('inp').focus();
}