Show HN: Replay your typing in a few lines of JavaScript
82 points| Einenlum | 2 years ago |einenlum.github.io
Human replay allows to copy paste a few lines of JS to make a text appear exactly how you typed it.
82 points| Einenlum | 2 years ago |einenlum.github.io
Human replay allows to copy paste a few lines of JS to make a text appear exactly how you typed it.
[+] [-] OmarShehata|2 years ago|reply
I was just talking to a coworker today about "libraries" vs "templates". You could have made this a library, but I think it's actually way nicer for it to be code I can copy/paste, so I can integrate it however I want. Some things are better as templates that I can copy.
If I have a weird use case or want to integrate it deeply into something else, the library doesn't need to accommodate that.
(the tradeoff of course is, if you update the library, my copied code won't update, so obviously this doesn't work for everything, but I think it works for some things!)
[+] [-] jmkni|2 years ago|reply
[+] [-] michaelmior|2 years ago|reply
[+] [-] Einenlum|2 years ago|reply
[+] [-] darkest_ruby|2 years ago|reply
[+] [-] onion2k|2 years ago|reply
On the other hand though, if you want to deliver the minimum code to the user to optimize for download speed, parsing time, and efficiency then a code generator that outputs some 'hardcoded' JS that you drop into the page is the way to go. I really like this approach and I've written plenty of generator functions like this in the past. It's more user-focused than importing a library to the same job.
This is one of the decisions every web dev has to make for themselves. Ideally when a site calls for a tiny function for an effect like this they'll opt for some 'bad' code that results in a better user experience.
[+] [-] michaelmior|2 years ago|reply
[0] https://asciinema.org/
[+] [-] sonofhans|2 years ago|reply
I’m curious — it looks like you’re storing the full text string along with the timestamp. At first I thought you were capturing keystrokes, but it makes more sense to capture the full text, so you can allow people to edit with mouse/arrow keys, etc.
It will fall over at some point though, right? If you work on this more, is the next logical step to store a diff with each timestamp, rather than the full string?
[+] [-] Einenlum|2 years ago|reply
I'll still think about this though. I think I could find a way to reduce the data size for most use cases.
[+] [-] seafoamteal|2 years ago|reply
Capturing keystrokes could still be a viable option if you maintained something like a virtual cursor that could move around the text display area.
Or of course, diffs are the most straightforward way to do it.
[+] [-] Einenlum|2 years ago|reply
[+] [-] daniel_iversen|2 years ago|reply
[+] [-] Einenlum|2 years ago|reply
[+] [-] unknown|2 years ago|reply
[deleted]
[+] [-] unknown|2 years ago|reply
[deleted]
[+] [-] mosselman|2 years ago|reply
I know a stream of diffs comes in, but I think the animation is smoothened by something.
[+] [-] blharr|2 years ago|reply
[+] [-] Einenlum|2 years ago|reply
[+] [-] js4ever|2 years ago|reply
[+] [-] Einenlum|2 years ago|reply
[+] [-] t_zahil|2 years ago|reply
[+] [-] avery17|2 years ago|reply
[+] [-] codetrotter|2 years ago|reply
[+] [-] anon115|2 years ago|reply
[+] [-] Einenlum|2 years ago|reply
[+] [-] Einenlum|2 years ago|reply
[+] [-] p2hari|2 years ago|reply
[+] [-] Einenlum|2 years ago|reply
[+] [-] tamimio|2 years ago|reply
[+] [-] Einenlum|2 years ago|reply
[+] [-] amelius|2 years ago|reply
[+] [-] Einenlum|2 years ago|reply
[+] [-] sourabhrathour|2 years ago|reply
[+] [-] MegaSec|2 years ago|reply
[+] [-] Einenlum|2 years ago|reply