-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathindex.html
98 lines (93 loc) · 3.24 KB
/
index.html
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<meta charset=utf-8>
<center style=font-family:arial>
<mark style="background:#fe5;padding: 3px;">Hello <b>Hacker News</b> and <b>r/Javascript!</b> Discover 100+ more golfed apps & games <a href="https://gist.github.com/xem/206db44adbdd09bac424">here!</a></mark>
<a href=//github.com/xem/sheet><img style="position:absolute;top:0;right:0;border:0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
<br>
<h1>Sheet</h1>
<h3>A 188b/253b spreadsheet app in HTML/JS</h3>
<br>
Inspired by <a href="http://aem1k.com/sheet/">aem1k.com/sheet</a> and <a href="http://jsfiddle.net/ondras/hYfN3/">this 30-line app</a>
<br>
Golfed by <a href=//xem.github.io>xem</a>, subzey, <a href=//p01.org>p01</a>, rlauck, <a href=//aem1k.com>aemkei</a>, odensc, mmastrac, <a href=//blog.jay.vg>corruptio</a>
<br>
More <a href="https://github.com/xem/ama/issues/14">backstory</a> (2015)
<br>
<br>
<hr>
<h2>Full (253b)</h2>
<b>Features:</b>
<br>
<br>
supports any value: texts, numbers, floats, and formulae. Ex: "=A1+8"
<br>
cells update in cascade, circular reference protection
<br>
implicit Math object. Ex: "=sqrt(A1)"
<br>
localStorage persistence
<br>
<br>
<b>Source code:</b>
<br>
(<a href="https://github.com/xem/sheet/blob/gh-pages/full-commented.html">commented source code</a>)
<br>
<br>
<pre style=text-align:left;font-family:courier;width:780px;margin:auto;background:#def;padding:15px;border-radius:10px>
o=b=>{for(i in{}+o)with(M=Math)M[y='ABCD'[i%5]+-~(i/5%6)]=b?document.write(y&&
i<30?`<input placeholder=${y} id=`+y:'<br',` onfocus=value=[l[id]] onblur=l[id
]=value,o()>`):(top[y].value=[/^=/.test(z=l[y])?eval('x'+z):x=z],x-~x?+x:x)};o
(o(l=localStorage))
</pre>
<br>
<b>Demo:</b>
<br>
<br>
<iframe style=transform:translateX(100px) src=full.html frameborder=0 width=800 height=200></iframe>
<br>
<br>
<hr>
<br>
<h2>Minimal (188b)</h2>
Supports numbers and formulae.
<br>
updates in cascade and prevents circular references.
<br>
<br>
<b>Source code:</b>
<br>
(<a href="https://github.com/xem/sheet/blob/gh-pages/mini-commented.html">commented source code</a>)
<br>
<br>
<pre style=text-align:left;font-family:courier;width:650px;margin:auto;background:#def;padding:15px;border-radius:10px>
(o=v=>{for(i in z='<input onblur=o[id]=value;o`.value` id=')y="
ABCD"[i%5]+-~(i/5),v?eval(y+(v+o[y]).replace(/[A-Z]\d/g," +$&"+
v)):document.write(y||'<p ',z,y,' onfocus=value=[o[id]]>')})()
</pre>
<br>
<b>Demo:</b>
<br>
<br>
<iframe style=transform:translateX(50px) src=mini.html frameborder=0 width=800 height=350></iframe>
<br>
<br>
<hr>
<br>
<h2>Full with headers (277b)</h2>
<br>
<pre style=text-align:left;font-family:courier;width:720px;margin:auto;background:#def;padding:15px;border-radius:10px>
with(M=Math)o=b=>{for(i in{}+o)(top[y=(C='-ABCD'[r=i%6])+(R=~~(i%35/6))]||
o).value=[x=/^=/.test(z=i<35?b&&document.write(y?'<input id='+y:'<p',R&&r?
` onfocus=value=[l[id]] onblur=l[id]=value,o()>`:' disabled>'):l[y])?eval(
'x'+z):R?r?z:R:C],M[y]=x-~x?+x:x};o(o(l=localStorage))
</pre>
<br>
<iframe style=transform:translateX(0px) src=headers.html frameborder=0 width=800 height=350></iframe>
<br>
<br>
© 2014-2017 <a href=//register.jsgolf.club>The Codegolf Team</a>
<br>
<br>
<style>
a { color: #000; }
hr { width: 500px }
</style>