This repository was archived by the owner on Aug 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
106 lines (103 loc) · 2.7 KB
/
script.js
File metadata and controls
106 lines (103 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//Number insertion
function insert(num){
document.form.textview.value = document.form.textview.value + num;
}
//Equal
function equal(){
var exp = document.form.textview.value;
if (eval(exp)==NaN){
document.form.textview.value = "Syntax error";
}
else if (exp){
document.form.textview.value = eval(exp);
}
}
//Clear
function clean(){
document.form.textview.value = " ";
}
//Backspace
function back(){
var exp = document.form.textview.value;
document.form.textview.value = exp.substring(0,exp.length-1);
}
//Sin,cos,tan
function sin(x){
document.form.textview.value = Math.sin(x * Math.PI / 180);
}
function cos(x){
document.form.textview.value = Math.cos(x * Math.PI / 180);
}
function tan(x){
document.form.textview.value = Math.tan(x * Math.PI / 180);
}
//Square roots
function sqrt(x){
document.form.textview.value = Math.sqrt(x);
}
//Cubic root
function cbrt(x){
document.form.textview.value = Math.cbrt(x);
}
//Factorials
function fact(num) {
if (num === 0 || num === 1)
document.form.textview.value = 1;
for (var i = num - 1; i >= 1; i--) {
num *= i;
}
document.form.textview.value = num;
}
//Negative
function neg(x){
x = x-x*2;
document.form.textview.value = x;
}
//Logs
function ln(x){
document.form.textview.value = Math.log(x);
}
function logten(x){
document.form.textview.value = Math.log10(x);
}
function logtwo(x){
document.form.textview.value = Math.log2(x);
}
//1/x
function over(x){
document.form.textview.value = 1/x;
}
//10 to the power of x
function tenpower(x){
document.form.textview.value = 10**x;
}
//e to the power of x
function epower(x){
document.form.textview.value = Math.E**x;
}
//Complex mode
function complex() {
//Checkbox
var checkBox = document.getElementById("complexcheck");
//Text
var text = document.getElementById("complex");
//If statement
if (checkBox.checked == true){
text.style.display = "block";
} else {
text.style.display = "none";
}
}
function opentab(evt, tab) {
var i, tabcontent, tabs;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tabs = document.getElementsByClassName("tabs");
for (i = 0; i < tabs.length; i++) {
tabs[i].className = tabs[i].className.replace(" active", "");
}
document.getElementById(tab).style.display = "block";
evt.currentTarget.className += " active";
}