Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export and import #29

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ data:text/html,<body contenteditable style=line-height:1.5;font-size:20px>

[Try it!](https://htmlpreview.github.io/?https://github.com/zserge/awfice/blob/main/edit.html)

## Spreadsheet - 679 bytes!
## Spreadsheet - 787 bytes!

A very basic spreadsheet with math formulas. It has 100 rows and 26 columns (A..Z). If the value in the cell starts with an "=" = it is evaluated as a formula. You may refer to other cell values, i.e. "=(A10+A11)/A12". Under the hood it uses eval(), so be careful.
A very basic spreadsheet with math formulas. It has 100 rows and 26 columns (A..Z). If the value in the cell starts with an "=" = it is evaluated as a formula. You may refer to other cell values, i.e. "=(A10+A11)/A12". Under the hood it uses eval(), so be careful. Click on the `@`-header to import and export data in JSON-format.

Copy and add to bookmarks or open in the URL bar:

```html
data:text/html,<table id=t><script>z=Object.defineProperty,p=parseFloat;for(I=[],D={},C={},q=_=>I.forEach(e=>{try{e.value=D[e.id]}catch(e){}}),i=0;i<101;i++)for(r=t.insertRow(-1),j=0;j<27;j++)c=String.fromCharCode(65+j-1),d=r.insertCell(-1),d.innerHTML=i?j?"":i:c,i*j&&I.push(d.appendChild((f=>(f.id=c+i,f.onfocus=e=>f.value=C[f.id]||"",f.onblur=e=>{C[f.id]=f.value,q()},get=_=>{v=C[f.id]||"";if("="!=v.charAt(0))return isNaN(p(v))?v:p(v);with(D)return eval(v.slice(1))},a={get},z(D,f.id,a),z(D,f.id.toLowerCase(),a),f))(document.createElement`input`)))</script><style>#t{border-collapse:collapse}td{border:1px solid gray;text-align:right}input{border:none;width:4rem;text-align:center}</style>
data:text/html,<table id=t><script>z=Object.defineProperty,p=parseFloat,o=(a,b)=>{try{b=JSON.parse(a)}catch(e){};return b};for(I=[],D={},C={},q=_=>I.forEach(e=>{try{e.value=D[e.id]}catch(e){}}),i=0;i<101;i++)for(r=t.insertRow(-1),j=0;j<27;j++)c=String.fromCharCode(64+j),d=r.insertCell(-1),'@'==(d.innerHTML=i?j?"":i:c)&&(d.onclick=e=>(k=prompt('Ex/import',JSON.stringify(C)),k&&(C=o(k,C),q()))),i*j&&I.push(d.appendChild(((x,f)=>(f.id=x,f.onfocus=e=>f.value=C[x]||"",f.onblur=e=>{C[x]=f.value,q()},get=_=>{v=C[x]||"";if("="!=v[0])return isNaN(p(v))?v:p(v);with(D)return eval(v.slice(1))},a={get},z(D,x,a),z(D,x.toLowerCase(),a),f))(c+i,document.createElement`input`)))</script><style>#t{border-collapse:collapse}td{border:1px solid gray;text-align:right}input{border:none;width:4rem;text-align:center}
```

[Try it!](https://htmlpreview.github.io/?https://github.com/zserge/awfice/blob/main/calc.html)
Expand Down
4 changes: 2 additions & 2 deletions README.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ data:text/html,$(cat edit.html)

## Spreadsheet - $(wc -c < calc.html | tr -d ' ') bytes!

A very basic spreadsheet with math formulas. It has 100 rows and 26 columns (A..Z). If the value in the cell starts with an "=" = it is evaluated as a formula. You may refer to other cell values, i.e. "=(A10+A11)/A12". Under the hood it uses eval(), so be careful.
A very basic spreadsheet with math formulas. It has 100 rows and 26 columns (A..Z). If the value in the cell starts with an "=" = it is evaluated as a formula. You may refer to other cell values, i.e. "=(A10+A11)/A12". Under the hood it uses eval(), so be careful. Click on the \`@\`-header to import and export data in JSON-format.

Copy and add to bookmarks or open in the URL bar:

Expand Down Expand Up @@ -71,7 +71,7 @@ data:text/html,$(cat beam.html)

[Try it!](https://htmlpreview.github.io/?https://github.com/zserge/awfice/blob/main/beam.html)

## Code editor - $(wc -c < code.html) bytes!
## Code editor - $(wc -c < code.html | tr -d ' ') bytes!

A simple code editor. You can type in HTML, CSS & Javascript.

Expand Down
2 changes: 1 addition & 1 deletion calc.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<table id=t><script>z=Object.defineProperty,p=parseFloat;for(I=[],D={},C={},q=_=>I.forEach(e=>{try{e.value=D[e.id]}catch(e){}}),i=0;i<101;i++)for(r=t.insertRow(-1),j=0;j<27;j++)c=String.fromCharCode(65+j-1),d=r.insertCell(-1),d.innerHTML=i?j?"":i:c,i*j&&I.push(d.appendChild((f=>(f.id=c+i,f.onfocus=e=>f.value=C[f.id]||"",f.onblur=e=>{C[f.id]=f.value,q()},get=_=>{v=C[f.id]||"";if("="!=v.charAt(0))return isNaN(p(v))?v:p(v);with(D)return eval(v.slice(1))},a={get},z(D,f.id,a),z(D,f.id.toLowerCase(),a),f))(document.createElement`input`)))</script><style>#t{border-collapse:collapse}td{border:1px solid gray;text-align:right}input{border:none;width:4rem;text-align:center}</style>
<table id=t><script>z=Object.defineProperty,p=parseFloat,o=(a,b)=>{try{b=JSON.parse(a)}catch(e){};return b};for(I=[],D={},C={},q=_=>I.forEach(e=>{try{e.value=D[e.id]}catch(e){}}),i=0;i<101;i++)for(r=t.insertRow(-1),j=0;j<27;j++)c=String.fromCharCode(64+j),d=r.insertCell(-1),'@'==(d.innerHTML=i?j?"":i:c)&&(d.onclick=e=>(k=prompt('Ex/import',JSON.stringify(C)),k&&(C=o(k,C),q()))),i*j&&I.push(d.appendChild(((x,f)=>(f.id=x,f.onfocus=e=>f.value=C[x]||"",f.onblur=e=>{C[x]=f.value,q()},get=_=>{v=C[x]||"";if("="!=v[0])return isNaN(p(v))?v:p(v);with(D)return eval(v.slice(1))},a={get},z(D,x,a),z(D,x.toLowerCase(),a),f))(c+i,document.createElement`input`)))</script><style>#t{border-collapse:collapse}td{border:1px solid gray;text-align:right}input{border:none;width:4rem;text-align:center}