Live data from Hacker News

A spreadsheet in fewer than 30 lines of JavaScript, no library used

jsfiddle.net

31–40 of 274 posts

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#32

Aside from losing input when tabbing out, works a treat in Opera. Can think of a couple of places that a fork of this might come in handy in my work this week. Clever, thanks for sharing

it does a parseFloat() on the input, so input that can't be coerced into a float gets turned into NaN and not displayed.

Makes sense, hadn't even looked that closely at the code before I commented - all 30 lines of it, ha. Shame on me.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#33

I am impressed. Its a neat hack, it actually is a real spreadsheet in 30 lines of code, with references fully working (ie =A3+B4 gives expected output. As does =alert("foo") but then nothing is perfect). I think it says something about the browser as a platform - these thirty lines simply assume an enormous amount that excel and visicalc could not - visicalc had to write their own screen refresh routines. It is usefu…

Personally I was confused as to how the fellow got around the basics of having to parse tokens until I noticed

with (DATA)

now that's just genius. I hate writing token parsing.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#34
Just waiting for the other 20,000 Excel features to be added. :)

This may sound like an inane comment, but trying working along Excel power users for the past two decades. Most people have no idea of the crazy, huge, complicated environment that is Excel.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#35
post #31

How does jquery count as 'no library used'? EDIT: I get it guys - I complained without reading carefully, sorry...

"$" replaced with "elm" to cause less confusion.

I apologise for my confusion and retract my moan.

I'm afraid I suffered from commenting without reading properly. In my defence, seeing $ signs everywhere shuts down the careful part of my brain.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#36

How does jquery count as 'no library used'? EDIT: I get it guys - I complained without reading carefully, sorry...

Where do you see any jQuery? I don't see any $ or jQuery, and if you look at the top left under "Frameworks & Extensions" it is set to "No-Library (pure JS)"

Perhaps the use of the more modern querySelectorAll threw you?

https://developer.mozilla.org/en-US/docs/Web/API/Document.qu...

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#38

Earlier quoted context omitted.

it does a parseFloat() on the input, so input that can't be coerced into a float gets turned into NaN and not displayed.

Makes sense, hadn't even looked that closely at the code before I commented - all 30 lines of it, ha. Shame on me.

Looks like that particular problem has been fixed.

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#39
post #20

First thing I tried was "=alert()". While it worked, its tendency to block, recalculate, and persist with localStorage made it a bad idea, personally.

btw, do not use location.reload or you get a reload loop until manually deleting the entry in local storage

Re: A spreadsheet in fewer than 30 lines of JavaScript, no library used

#40

My text disappears after I type it in and move on. And why do you call a table an "excel-like" app? Can it so =SUM(); can it do search and replace or the over 9000 other features of excel? No... it's a table, with a editor.

On one side I'm like come on guy, it's impressive.

On the other, I imagine some PM is going to read this and expect their developers to get a google docs competitor out in a day!

Post reply on HN