// ThisScript.js -----------
var m;
m = 0;
var i;
var mm;
function num (i)
{
var u = new String();
u = text3.value;
if (u == "=")
{
text1.value = text2.value = "";
text1.value = text1.value + i ;
text3.value = "";
return;
}
var s;
var l;
s = text1.value;
l = s.length;
if (l<10)
{
text1.value = text1.value + i;
}
}
function point()
{
var i;
var s = new String();
s = text1.value;
i = s.indexOf(".");
var u = new String();
u = text3.value;
if (u == "=")
{
text1.value = text2.value = "";
text1.value = text1.value + "." ;
text3.value = "";
return;
}
if (i > -1)
{
return;
}
else
{
if (s.length<9)
{
s = s + ".";
text1.value = s;
}
}
}
var cho;
function act(cho)
{
var u = new String();
u = text3.value;
if (u == "")
{
text2.value = text1.value;
text1.value = "";
}
else
{
switch (u)
{
case "+" :
text2.value = (text2.value*1) + (text1.value*1);
text1.value = "";
break;
case "-" :
text2.value = (text2.value*1) - (text1.value*1);
text1.value = "";
break;
case "*" :
text2.value = (text2.value*1) * (text1.value*1);
text1.value = "";
break;
case "/" :
text2.value = (text2.value*1)/(text1.value*1);
text1.value = "";
break;
case "=" :
text2.value = text1.value;
text1.value = "";
break;
}
}
switch (cho)
{
case 1 :
text3.value = "+";
break;
case 2 :
text3.value = "-";
break;
case 3 :
text3.value = "*";
break;
case 4 :
text3.value = "/";
break;
}
}
function eq()
{
switch (text3.value)
{
case "+":
text2.value = (text2.value*1) + (text1.value*1);
text1.value = text2.value;
text2.value = "";
break;
case "-":
text2.value = (text2.value*1) - (text1.value*1);
text1.value = text2.value;
text2.value = "";
break;
case "*":
text2.value = (text2.value*1) * (text1.value*1);
text1.value = text2.value;
text2.value = "";
break;
case "/":
text2.value = (text2.value*1) / (text1.value*1);
text1.value = text2.value;
text2.value = "";
break;}
text3.value = "=";
}
function clss()
{
text1.value = text2.value = text3.value = "";
m =0;
clear1.blur();
}
function initial()
{
text1.blur();
text2.blur();
}
function clearall()
{
text1.value = "";
}
function madd()
{
m = m + ((text1.value)*1);
text1.value = "";
text3.value = "";
}
function msub()
{
m = m - ((text1.value)*1);
text1.value = "";
text3.value = "";
}
function mrem()
{
if (m != 0)
{
text1.value = m;
text3.value = "";
}
}
function free()
{
if (mm != 1)
{
alert ('Action non disponible');
}
}
function frees()
{
mm = 1;
}
function freed()
{
mm = 0;
}
function neg () {
text1.value = text1.value * -1;
text3.value = "";
}
function percent () {
text1.value = text1.value /100;
text3.value = "";
}
function inverse() {
text1.value = 1/ text1.value;
text3.value = "";
}
function SymError()
{
return true;
}
window.onerror = SymError;
var SymRealWinOpen = window.open;
function SymWinOpen(url, name, attributes)
{
return (new Object());
}
window.open = SymWinOpen;
// Calculateur.html
<HTML>
<HEAD>
<TITLE>Simple calculateur en JavaScript</TITLE>
<link href="ThisStyle.css" rel="stylesheet" type="text/css" >
<script src="ThisScript.js" type="text/javascript"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
</HEAD>
<BODY BGCOLOR="#Ffffff" TEXT="#000000" LINK="#993300" VLINK="#cc3300"
ALINK="#ff3300">
<FORM NAME="Calculette">
<table bgcolor=silver border=1 width="300" height = "300">
<TR>
<TD align = center>
<INPUT TYPE="text" style="background-color:black;color:lime;
width:240;height:30" NAME="Input" > <br>
</TD>
</TR>
<TR>
<TD align = center>
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="one" VALUE=" 1 " OnClick="Calculette.Input.value += '1'" >
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="two" VALUE=" 2 " OnCLick="Calculette.Input.value += '2'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="three" VALUE=" 3 " OnClick="Calculette.Input.value += '3'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="plus" VALUE=" + " OnClick="Calculette.Input.value += ' + '">
<br>
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="four" VALUE=" 4 " OnClick="Calculette.Input.value += '4'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="five" VALUE=" 5 " OnCLick="Calculette.Input.value += '5'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="six" VALUE=" 6 " OnClick="Calculette.Input.value += '6'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="minus" VALUE=" - " OnClick="Calculette.Input.value += ' - '">
<br>
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="seven" VALUE=" 7 " OnClick="Calculette.Input.value += '7'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="eight" VALUE=" 8 " OnCLick="Calculette.Input.value += '8'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="nine" VALUE=" 9 " OnClick="Calculette.Input.value += '9'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="times" VALUE=" x " OnClick="Calculette.Input.value += ' * '">
<br>
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="zero" VALUE=" 0 " OnClick="Calculette.Input.value += '0'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="div" VALUE=" / " OnClick="Calculette.Input.value += ' / '">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="DoIt" VALUE=" = " OnClick="Calculette.Input.value = eval(Calculette.Input.value)">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="clear" VALUE=" E " OnClick="Calculette.Input.value = ''">
<br>
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="IG" VALUE=" R " OnClick="Calculette.Input.value += '8.3143'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="Hydrogen" VALUE=" H " OnClick="Calculette.Input.value += '1.008'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="Oxygen" VALUE=" O " OnClick="Calculette.Input.value += '15.999'">
<INPUT TYPE="button" style="background-color:black;color:lime; width:60;height:40"
NAME="Air" VALUE=" AIR " OnClick="Calculette.Input.value += '28.969'">
<br>
</TD>
</TR>
</TABLE>
</FORM>
<table border=0><tr align = center><td>
<a href="calculator_source.html" target = "file2">code source</a>
</td></tr></table>
</body>
</html>