You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spreadsheet/chapter.md
+31-4Lines changed: 31 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,37 @@ How many features can a Web application offer in 99 lines? Let’s see it in act
16
16
17
17
## Overview
18
18
19
-
The [spreadsheet](https://github.com/aosabook/500lines/tree/master/spreadsheet) directory contains our showcase for the latest evolution of the three languages: [HTML5](http://www.w3.org/TR/html5/) for structure, [CSS3](http://www.w3.org/TR/css3-ui/) for presentation, and the JS [ES6 “Harmony”](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts) standard for interaction.
19
+
The [spreadsheet](https://github.com/aosabook/500lines/tree/master/spreadsheet) directory contains our showcase for the latest evolution of the three languages: [HTML5](http://www.w3.org/TR/html5/) for structure, [CSS3](http://www.w3.org/TR/css3-ui/) for presentation, and the JS [ES6 “Harmony”](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts) standard for interaction. We also use [Web Storage](http://www.whatwg.org/specs/web-apps/current-work/multipage/webstorage.html) for data persistence, and [Web Worker](http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html) for running JS code in the background. Since 2012, these web standards are supported by Firefox, Chrome, Internet Explorer 10+, as well as mobile browsers on iOS 5+ and Android 4+.
20
20
21
-
We also use [Web Storage](http://www.whatwg.org/specs/web-apps/current-work/multipage/webstorage.html) for data persistence, and [Web Worker](http://www.whatwg.org/specs/web-apps/current-work/multipage/workers.html) for running JS code in the background. Since 2012, these two web standards are supported by major browsers, such as Firefox, Chrome, Internet Explorer (version 10+), iOS Safari (version 5+) and Android Browser (version 4+).
21
+
Now let’s open http://audreyt.github.io/500lines/spreadsheet/in a browser:
22
22
23
-
Now let’s open <http://audreyt.github.io/500lines/spreadsheet/> in a browser:
The _spreadsheet_ as shown on the screen is a grid that spans in two dimensions, with _columns_ starting from `A`, and _rows_ starting from `1`. Each _cell_ has a unique _coordinate_ (such as `A1`) and its _content_ (`1874`), which belongs to one of four _types_:
28
+
29
+
* Text: `+` in `B1` and `⇒` in `D1`, aligned to the left.
30
+
* Number: `1874` in `A1` and `2046` in `C1`, aligned to the right.
31
+
* Formula: `=A1+C1` in `E1`, which _calculates_ to the _value_`3920`, displayed with a light blue background.
32
+
* Empty: All cells in row `2` are currently empty.
33
+
34
+
Click `3920` to set _focus_ on `E1`, revealing its formula in an _input box_:
35
+
36
+

37
+
38
+
Now let’s set focus on `A1` and _change_ its content to `1`, causing `E1` to _recalculate_ its value to `2047`:
39
+
40
+

41
+
42
+
Press `ENTER` to set focus to `A2` and change its content to `=Date()`, then press `TAB`, change the content of `B2` to `=alert()`, then press `TAB` again to set focus to `C2`:
43
+
44
+

45
+
46
+
This shows that a formula may calculates to a number (`2047` in `E1`), a text (the current time in `A2`, aligned to the left), or an _error_ (red letters in`B2`, aligned to the center).
47
+
48
+
Next, let’s try entering `=for(;;){}`, the JS code for an infinite loop that never terminates. The spreadsheet will prevent us from entering that code, automatically _undo_ the edit after half a second has passed.
49
+
50
+
Now reload the page in the browser with `Ctrl-R` or `Cmd-R` to verify that the spreadsheet content is _persistent_, staying the same across browser sessions.
51
+
52
+
Finally, press the `↻` button on the top-left corner to _reset_ the spreadsheet to its original content.
0 commit comments