You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.9 KiB
74 lines
1.9 KiB
13 years ago
|
/*
|
||
|
* This program 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 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
14 years ago
|
function addChar(input, character) {
|
||
|
if(input.value == null || input.value == "0")
|
||
|
input.value = character
|
||
|
else
|
||
|
input.value += character
|
||
|
}
|
||
|
|
||
|
function cos(form) {
|
||
|
form.display.value = Math.cos(form.display.value);
|
||
|
}
|
||
|
|
||
|
function sin(form) {
|
||
|
form.display.value = Math.sin(form.display.value);
|
||
|
}
|
||
|
|
||
|
function tan(form) {
|
||
|
form.display.value = Math.tan(form.display.value);
|
||
|
}
|
||
|
|
||
|
function sqrt(form) {
|
||
|
form.display.value = Math.sqrt(form.display.value);
|
||
|
}
|
||
|
|
||
|
function ln(form) {
|
||
|
form.display.value = Math.log(form.display.value);
|
||
|
}
|
||
|
|
||
|
function exp(form) {
|
||
|
form.display.value = Math.exp(form.display.value);
|
||
|
}
|
||
|
|
||
|
function deleteChar(input) {
|
||
|
input.value = input.value.substring(0, input.value.length - 1)
|
||
|
}
|
||
|
|
||
|
function changeSign(input) {
|
||
|
if(input.value.substring(0, 1) == "-")
|
||
|
input.value = input.value.substring(1, input.value.length)
|
||
|
else
|
||
|
input.value = "-" + input.value
|
||
|
}
|
||
|
|
||
|
function square(form) {
|
||
|
form.display.value = eval(form.display.value) * eval(form.display.value)
|
||
|
}
|
||
|
|
||
|
function checkNum(str) {
|
||
|
for (var i = 0; i < str.length; i++) {
|
||
|
var ch = str.substring(i, i+1)
|
||
|
if (ch < "0" || ch > "9") {
|
||
|
if (ch != "/" && ch != "*" && ch != "+" && ch != "-" && ch != "."
|
||
|
&& ch != "(" && ch!= ")") {
|
||
|
$("#display").text("ERROR");
|
||
|
return false
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return true
|
||
|
}
|