-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
44 lines (35 loc) · 1.24 KB
/
index.js
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
$(function(){
let problem = '';
$('#h2-solution').text('_');
$('.btn-number').on('click', (ele) => {
problem += ele.currentTarget.innerText;
$('#h2-problem').text(problem);
//console.log(problem);
});
$('.btn-operator').on('click', (ele) => {
problem += ' ' + ele.currentTarget.innerText + ' ';
$('#h2-problem').text(problem);
//console.log(problem);
});
$('#btn-equals').on('click', (ele) => {
expression = problem.replace('×', '*').replace('÷', '/');
$('#h2-solution').text(math.evaluate(expression));
//console.log(problem);
});
$('#btn-clear').on('click', (ele) => {
problem = '';
$('#h2-problem').text('|');
$('#h2-solution').text('_');
//console.log(problem);
});
$('#btn-delete').on('click', (ele) => {
problem = problem.slice(0, -1);
$('#h2-problem').text(problem);
$('#h2-solution').text('_');
//console.log(problem);
});
$('#btn-copy').on('click', (ele) => {
navigator.clipboard.writeText(math.evaluate(problem));
M.toast({html: 'copied to clipboard', classes: 'rounded', displayLength: 1000});
});
});