Live data from Hacker News

Turn your browser into a notepad with one line

coderwall.com

141–150 of 186 posts

Re: Turn your browser into a notepad with one line

#141
post #138

Earlier quoted context omitted.

They are loaded when you re-open the extension by the looks of it.

Doesn't work for me - seems I am doing something wrong. I open a tab, write something, close the tab. I open a fresh tab - no text. I'd expect that the written text would show up.

Did you save it? (CTRL+S)

Re: Turn your browser into a notepad with one line

#142
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'; } }

Is there an equivalent to `this.onkeyup` for touch devices that don't generate onkeyup events? Trying to make this work on an iPad, but I only have surface knowledge of JS.

It's pretty brutal and stupid, but:

    window.setInterval(function(){eval(this.innerText)},1000);

Re: Turn your browser into a notepad with one line

#143
post #138

Earlier quoted context omitted.

Doesn't work for me - seems I am doing something wrong. I open a tab, write something, close the tab. I open a fresh tab - no text. I'd expect that the written text would show up.

Did you save it? (CTRL+S)

No, I didn't. Now it works, thanks!

Re: Turn your browser into a notepad with one line

#144

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…

You could use some JavaScript to change window.location.href to a new data uri containing the content of the page that you could then bookmark. There's a limit to the length of URLs so it would be an interesting trade off of save size vs features.

Re: Turn your browser into a notepad with one line

#145

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…

If you don't mind loading jquery I made a version which saves to OpenKeyVal. Just set your secret key..

https://gist.github.com/4672169

Re: Turn your browser into a notepad with one line

#146
post #93

After some mix-and-matching of the awesome code snippets posted in the comments, I came up with something easy on the eyes (with a nice little color transition (for webkit-enabled browsers): data:text/html, http://fonts.googleapis.com/css?family=Lato:100,200,300,400,... rel='stylesheet' type='text/css'> html { font-family: "Lato"; color:#e9e9e9; background-color:#222; } * { -webkit-transition: all linear 1s; }

Here's a version that can be copy/pasted: data:text/html, html { font-family: "Lato"; color:#e9e9e9; background-color:#222; } * { -webkit-transition: all linear 1s; }

Nice, i've added a few divs and borders for my version.

  data:text/html,  html { font-family: "Lato"; color:#e9e9e9; background-color:#222; } * { -webkit-transition: all linear 1s; }Notes

Re: Turn your browser into a notepad with one line

#147
post #48

The nicest thing about this is that you can CTRL+S save it as a .html file, and then you can also CTRL+O load the file and it's still editable, and save it again!

Does not work in Opera. If you save as type: text, the text saves OK. But if you save as html, the file just contains " <html contenteditable>"

Also, HOW to open an existing file while retaining 'contenteditable' mode? Everything I try alters the URL field, so returning the browser to standard display-only mode.

Re: Turn your browser into a notepad with one line

#149
It's cute, but I can't help observing that we're what, 70 years into the computer age, and there's still no ubiquitous, small, fast, clean text editor present by default on all personal computers. (DO NOT speak to me of Notepad.exe)

So discovering that 'by accident' web browsers can act as a simple (but huge, bloated and feature-starved) text editor seems like a big deal.

Personally I keep a simple, tiny, old freeware editor called Editpad 3.4, on every PC I use, accessed via desktop shortcut and 'right-click send-to'.

Re: Turn your browser into a notepad with one line

#150
post #133

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

Made it a chrome extension for an easier install. https://chrome.google.com/webstore/detail/textpad/edopaieiod...

Thanks, works like a charm.
Post reply on HN