oda-framework
Version:
118 lines (117 loc) • 4.19 kB
HTML
<meta charset="utf-8">
<script type="module" src="../../../oda.js"></script>
<script type="module" src="./calculator.js"></script>
<oda-tester>
<oda-calculator id="calc" style="width: 500px;"></oda-calculator>
</oda-tester>
<script type="module">
calc.data = {
cols: {
science: {
rows: {
1: {
buttons: {
"x!": {command: "calcFactorial"},
"sin": {name: "sin(", expr: "Math.sin(", hint: ')'},
"ln": {name: "ln(", expr: "Math.log(", hint: ')'},
},
},
2: {
buttons: {
"π": {expr: "Math.PI"},
"cos": {name: "cos(", expr: "Math.cos(", hint: ')'},
"log": {name: "log(", expr: "Math.log10(", hint: ')'},
},
},
3: {
buttons: {
"e": {expr: "Math.E"},
"tan": {name: "tan(", expr: "Math.tan(", hint: ')'},
"√": {name: "√(", expr: "Math.sqrt(", hint: ')'},
},
},
4: {
buttons: {
"Ans": {command: 'getAnswer'},
"EXP": {name: "E", expr: "*10**"},
"XY": {key:"<div>X<sup>y</sup></div>", name: "^", expr: "**"},
},
},
},
props: {
class: "layout",
style: 'flex-shrink: 10000000',
},
},
numpad: {
rows: {
1: {
buttons: {
"(": {hint: ')', expr: '('},
")": {},
},
},
2: {
buttons: {
7: {},
8: {},
9: {},
},
},
3: {
buttons: {
4: {},
5: {},
6: {},
},
},
4: {
buttons:{
1: {},
2: {},
3: {},
},
},
5: {
buttons: {
0: {},
"00": {},
".": {},
},
}
},
},
sign:{
rows:{
1: {
buttons:{
"AC": {command: 'clear'},
"⟵": {command: 'back'},
},
},
2: {
buttons: {
"÷": {name: ' ÷ ', expr: '/'},
"%": {expr: "*0.01"},
},
},
3:{
buttons: {
"X": {name: ' × ', expr: '*'},
"-": {name: ' - ', expr: '-'},
},
},
4: {
props:{
style: 'flex-grow: 1000000',
},
buttons:{
"+": {name: ' + ', expr: '+'},
"=": {command: 'calc'},
},
}
},
},
},
};
</script>