Live data from Hacker News

Show HN: Scratch.js – Interactive JavaScript Scratchpad

hole.dev

61–69 of 69 posts

Re: Show HN: Scratch.js – Interactive JavaScript Scratchpad

#64
post #7

Earlier quoted context omitted.

I find myself opening and using the web console to do simple tasks like string manipulation, maths, sorting often. I wanted a dedicated and persistent way to do this. And also just a place to keep notes, urls and stuff. So I made this "literate programming" notepad. I'm also former Emacs user, and I like the lisp scratch buffer there, which is similar.

I love how simple and effective this is. I'm also building a web-based literate programming environment called Starboard[1] that's probably a hundred times the amount of code (but then it has additional features such as top-level await, plugin, and Python support). Consider supporting lit-html[2] literals instead of strings for HTML output, it works really well in notebook environments. One more thing you can conside…

Starboard looks very cool as well. Is there anyway to push all the outputs into a separate 'document'? That'd be super cool for e.g. Latex too.

My issue with these notebooks is they always get very cluttered with inline outputs after a couple 100 lines.

Re: Show HN: Scratch.js – Interactive JavaScript Scratchpad

#65
post #6

Earlier quoted context omitted.

The source is very small and can be used both through the file:// and hosted http protocols. So you can easily make it do whatever you like. I could maybe expose some global variables to make it customizable, but I went for simplicity and smaller source instead.

if it helps, all you need to do is add this listener to support the cmd key: `document.addEventListener('keydown', (e) => (e.metaKey && e.code === 'Enter' && evaluate() && e.preventDefault()));` The metaKey[1] is only accessible for keydown. [1] https://stackoverflow.com/questions/3902635/how-does-one-cap...

Fixed
Post reply on HN