2 * This file is part of NOALYSS.
4 * NOALYSS is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * NOALYSS is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with NOALYSS; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
23 * \brief This file show a little online calculator, in the caller
24 * the span id result, listing, the id form calc_line and the
31 * Compute and update the box
38 p_variable=this.document.getElementById('inp').value;
39 if (p_variable.search(/^\s*$/) !=-1)
46 p_variable=p_variable.replace(/[a-z]/,'');
47 p_variable=p_variable.replace(/[A-Z]/,'');
48 p_variable=p_variable.replace(/</,'');
49 p_variable=p_variable.replace(/%/,'');
50 p_variable=p_variable.replace(/;/,'');
51 p_variable=p_variable.replace(/>/,'');
52 p_variable=p_variable.replace(/ /g,"");
53 p_variable=p_variable.replace(/\+/g,"+ ");
54 p_variable=p_variable.replace(/-/g,"- ");
55 p_variable=p_variable.replace(/\//g,"/ ");
56 p_variable=p_variable.replace(/,/g,".");
59 var result=parseFloat(sub);
60 result=Math.round(result*10000)/10000;
64 alert_box(content[48]+p_variable);
67 p_history=p_variable+"="+result.toString()+'<br>'+p_history;
68 var str_sub='<p class="highlight"> '+p_variable+" = "+result.toString()+'</p>';
69 this.document.getElementById("sub_total").innerHTML=str_sub;
70 this.document.getElementById("listing").innerHTML=p_history;
71 this.document.getElementById('inp').value=result;
75function CleanHistory()
77 this.document.getElementById('listing').innerHTML="";
78 this.document.getElementById('sub_total').innerHTML="";
79 this.document.getElementById('inp').value="";
80 this.document.getElementById('inp').focus();
85 this.document.getElementById('inp').value="";
86 this.document.getElementById('inp').focus();
93 this.document.getElementById('inp').value="";
94 this.document.getElementById('inp').focus();