aboutsummaryrefslogtreecommitdiff
path: root/calculator
diff options
context:
space:
mode:
Diffstat (limited to 'calculator')
-rw-r--r--calculator/index.html1
1 files changed, 1 insertions, 0 deletions
diff --git a/calculator/index.html b/calculator/index.html
new file mode 100644
index 0000000..2860ee5
--- /dev/null
+++ b/calculator/index.html
@@ -0,0 +1 @@
+<table style="text-align: center;width:80vw;margin: 0 auto;"><tbody><tr><td colspan="4"><textarea></textarea></td></tr></tbody><script>let d=document;let tbl=d.querySelector('tbody');let z=d.querySelector('textarea');let oc=(x)=>z.value+=x;let cl=()=>z.value='';let re=()=>{try{z.value=eval(z.value);}catch(error){cl();}};[[1,2,3,'+'],[4,5,6,'-'],[7,8,9,'*'],['C',0,'=','/']].forEach((a)=>{let r=d.createElement('tr');r.style.lineHeight='64px';tbl.appendChild(r);a.forEach((b)=>{let tb=d.createElement('tb');tb.innerText=b;tb.style.padding='16px';tb.style.border='1px solid';r.appendChild(tb);tb.onclick=b==='='?re:b==='C'?cl:()=>oc(b);})})</script></table>