diff --git a/index.html b/index.html
index feef079..2c2a35c 100644
--- a/index.html
+++ b/index.html
@@ -14,8 +14,8 @@
π
√
-
(
-
)
+
(
+
)
sin
cos
tan
@@ -27,24 +27,24 @@
%
×
-
7
-
8
-
9
+
7
+
8
+
9
÷
-
4
-
5
-
6
+
4
+
5
+
6
-
-
1
-
2
-
3
+
1
+
2
+
3
+
-
.
-
0
-
del
+
.
+
0
+
del
=
diff --git a/script.js b/script.js
index 3592552..5bb4273 100644
--- a/script.js
+++ b/script.js
@@ -1,5 +1,6 @@
var rumus = document.getElementById("rumusEl");
+var hasil = document.getElementById("hasilEl");
$('#satuEl').on("click", function() {
$('#rumusEl').append("1");
@@ -98,13 +99,16 @@ $('#clearEl').on("click", function() {
//hitung rumusnya
-$('#jumlahEl').on("click", function() {
- var numbers = [0,1,2,3,4,5,6,7,8,9];
-
+
+function hitungRumus() {
var pi = rumus.textContent.replace(/π/g, "Math.PI");
// Fix perkalian ()
-var fix = pi.replace(/\)\(/g, ")*(");
+var fixSin = pi.replace(/\)s/g, ")*s");
+var fixCos = fixSin.replace(/\)c/g, ")*c");
+var fixTan = fixCos.replace(/\)t/g, ")*t");
+
+var fix = fixTan.replace(/\)\(/g, ")*(");
var fix1 = fix.replace(/1\(/g, "1*(");
var fix2 = fix1.replace(/2\(/g, "2*(");
var fix3 = fix2.replace(/3\(/g, "3*(");
@@ -148,12 +152,24 @@ var convertOperator = defineSqrt.replace(/\b(?:÷|×|\^|sin|cos|tan)\b/gi, func
// console.log(convertOperator + "=" + eval(convertOperator));
-
try {
$('#hasilEl').html(eval(convertOperator));
$('#hasilEl').css("color", "black");
- } catch (e) {
+ } catch (error) {
$('#hasilEl').html("Format Error");
$('#hasilEl').css("color", "red");
}
+}
+
+
+$('.btnNum').on("click", function() {
+ hitungRumus();
+})
+$('.btnTop').on("click", function() {
+ hitungRumus();
+})
+$('#jumlahEl').on("click", function() {
+ hitungRumus();
+ rumus.innerHTML = hasil.textContent;
+ hasil.innerHTML ="";
})
\ No newline at end of file