Live data from Hacker News

Turn your browser into a notepad with one line

coderwall.com

171–180 of 186 posts

Re: Turn your browser into a notepad with one line

#171

Earlier quoted context omitted.

No, it doesn't. It just drops you to another shell prompt.

Not in zsh it doesn't. (tip: it's a zsh thing.)

oh, well, unspecified shell snippets are usually assumed to be some bourne derivative, in which case the cat is necessary.

Re: Turn your browser into a notepad with one line

#174

Ah shoot. If Chrome allowed localStorage to be accessible from file:/// then we could add save (CTRL+S) and automatic load using this: data:text/html, window.onload=function(){var a=document.body;a.innerText=localStorage.mydoc;a.addEventListener("keydown",function(b){b.ctrlKey&&83==b.which&&(localStorage.mydoc=a.innerHTML,b.preventDefault())},!1)}; Firefox will save it to localStorage but clear the local storage afte…

    data:text/html,window.onload=function(){var a=document.body;a.addEventListener("keydown",    	function(b){if(b.ctrlKey&&83===b.which){document.location = 'data:text/html,' + document.childNodes[0].outerHTML;b.preventDefault();}},!1);document.title= document.body.innerText.replace(/\n[\s\S]+$/," - ")+new Date().toString();};
With this you can save using the URL!

Just press Ctrl+S and use the browser history to access it later! And this means it also haves a pseudo-version-control-system included! For easy access the first line in the text becomes the title.

In coderwall: https://coderwall.com/p/xh9u3w

Re: Turn your browser into a notepad with one line

#175
post #34

This is what the scratch (EDIT: read scratch as * scratch * without the spaces--is there any way to escape that properly on HN?) buffer is for in Emacs, and I find it extremely useful. Also, unlike using a different tool, it allows me to use all the Emacs-specific features I usually rely on. (For example, I can easily type special characters like r₁ × r₂ ≈ r₃ using the TeX mode.) If you want more than one scratch buf…

[deleted]

Re: Turn your browser into a notepad with one line

#176
post #19

For even more fun, turn your notepad into an interactive JavaScript environment: data:text/html, Then you can upgrade it by pasting in something like this: this.onkeyup = function () { this.style.backgroundColor = 'white'; try { eval(this.innerText); } catch (e) { this.style.backgroundColor = '#FFAAAA'; } }

For me Firefox seems not to work with this.innerText . Instead you can use this.textContent to get it to work.

Re: Turn your browser into a notepad with one line

#178
post #169

Earlier quoted context omitted.

That is so cool :). I just slapped together a (really) simple chrome ext for opening up a new tab in "contenteditable" mode. It saves the contents into localStorage, thats it for now :) Here it is if anyones interested https://github.com/jwaterfaucett/textpad

I forked your code, added support so you can do (C-N) to open a new tab, click tab and start typing (the cursor will be at the end of the line), polished it up a bit (changed font to consolas, added a grey background with a tint of white text-shadow). I've sent a pull request. https://github.com/AeonAxan/textpad

nice :) I just merged your modifications.

Re: Turn your browser into a notepad with one line

#179
It's about 10 years since I did any software development, and I only bother with surface tracking of web-languages progress. So a lot of this is news to me. Also maybe some of the posted 'improved versions' provide what I'd like with this 'contenteditable' thing. It'll take a while to try them all.

Anyway...

So far I don't see one crucial feature: the ability to load an existing file, and edit it. Am I stupidly missing something 'obvious'?

Being able to edit text and save, but not load existing documents and edit them makes this a useless novelty.

I did notice one suggestion to load a doc then use a short js command to switch to contenteditable. But that's not quite there.

Ideally, a browser could be made to work like this:

* Multiple ways to get it started: bookmark, desktop shortcut icon, url to public or private html page containing the config script. Once working like an editor it should stay that way, for multiple file load/saves and multiple tabs open.

* An 'open file' for any existing plaintext or html file, loaded from local filesystem (via file selector popup or bookmark) or the web (type known url or use bookmark).

* Ability to switch back and forth between three modes on the same document: raw plain ascii (no formatting), minimal formatting (B, I, U, bullets), and full html formated display.

* A document 'save as' as plain text (formatting stripped) or html, to the local filesystem, OR (best feature yet) anywhere with write enabled on a public or private web server.

* Nice if also handles encrypted load/save, so the doc is never in plaintext except on the local machine.

With that, the big name 'cloud' services can go take a leap. I could use my own server(s), or ones I happened to trust. There is flatly no way I would ever trust large enterprise cloud services.

Also, a tool like that which would allow editing on ANY machine with web access and local file r/w enabled for the browser, would be very useful for... things.

It always astonished me that browsers did not provide the capability to natively edit the html they displayed. Such an obvious need, and you'd think so simple to implement, that I'd concluded the absence of this ability had to be a deliberate industry-wide agreed policy of capability avoidance. Which means, for political reasons.

Re: Turn your browser into a notepad with one line

#180

Earlier quoted context omitted.

Not in zsh it doesn't. (tip: it's a zsh thing.)

oh, well, unspecified shell snippets are usually assumed to be some bourne derivative, in which case the cat is necessary.

Agreed, just adding the caveat.
Post reply on HN