Textarea Backup Localstorage

Retains what you type into textareas and contentEditable elements.

This script is only compatible with Opera 10.50 and up. If you need to use it with an older version use Textarea Backup but be advised that it comes with some disadvantages.

  1. Can automatically place previously typed text in textareas.
  2. Can add an unobtrusive menu in the top right corner of textareas

Actions menu screenshot (note the transparent object in the top right corner of the textarea):

Development can be followed on GitHub. Don't be shy, open an issue or send me a pull request if you think you have something to contribute! wink

Changelog

25-07-2013

1.21 July 25, 2013. Sorry, I was a bit hasty about that last one. I passed my testcase, but only noticed that many contentEditables work differently in practice on this very site.

  • Fixed a bug that occurred when BODY was contentEditable, as is typical in iframes.
  • Properly compare initial value of contentEditable element to backed up value so you'll only get prompted to overwrite when relevant.
  • Full changelog.
25-07-2013

1.20 July 25, 2013. I wasn't going to make yet another release in three days, but these new features could be implemented much faster than I initially predicted.

  • Trustworthy old persistent preferences support added. I also uploaded a sample settings file.
  • Fixed the keep_after_submission bug, so setting it to false is safe again.
  • Removed the form requirement.
  • Support contentEditable. This is a pretty big one, seeing how it was the most obvious missing feature.
24-07-2013

1.11 July 24, 2013. Added configuration switches for the new feature.

For Opera 11.6x and Opera 12.x it now defaults to off because of potential performance concerns.

Syndicate content

Tested with Opera version(s): 
11.11
11.5x
11.6
12.0
12.10
Your rating: None Average: 3.2 (76 votes)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Neat! Oddly enough it does

Neat! Oddly enough it does not seem to work on this site. A conflict with rich text editors perhaps? (or maybe just WYMeditor) It works perfectly on the my.opera forum as far as i can tell, even after closing the browser.

Probably a rich text editor issue

I think they all work by replacing the textarea, so if I'm not mistaken about this then none will work with the script.

Intelligent alien life does exist, otherwise they would have contacted us.

Autocomplete

Is this js adding Autocomplete feature like ops.js?

I hadn't thought of it

I personally never used that script (I only like autocomplete I explicitly filled out previously), however it should probably be fairly trivial for someone to port that script from cookies to localStorage (if only because localStorage is much easier to use). I don't think incorporating it into Textarea Backup would be the right thing to do because of the different scope (textarea vs. input). If anybody disagrees with me they're free to start a different branch. ;) I see no reason the two scripts couldn't work in conjunction, at any rate.

Intelligent alien life does exist, otherwise they would have contacted us.

Excellent work on the menu,

Excellent work on the menu, it's a keeper.

Thanks!

I think one of the best things is that because of the transitioning effects it takes the menu about half a second to appear. In other words, just moving the mouse over it (while trying to reach something else) won't make things jump on your screen. Of course this would've been easy to accomplish using JS, but having it as CSS simplifies things (plus it's going to be nice to be able to do that on JS-free pages).

Intelligent alien life does exist, otherwise they would have contacted us.

Wow

Lear innovative way of using userjs and nifty features of Opera. THANKS. Huge THANKS. There is small problem in 10.50 linux. In menu beyond the Restore, Delete, Clear, I see about 20 entries named 'Undefined'

Does this happen on a

Does this happen on a particular site? For me it functions identically on Windows and Linux (build 6242 x86_64 is what I used to test it).

Intelligent alien life does exist, otherwise they would have contacted us.

Works fine on x86_32 build as

Works fine on x86_32 build as well. Only glitch that i have seen is text from one forum thread being carried over into another. Not a huge issue.

Mostly one singl site.

It happens for example on http://filmweb.pl forum and form.

Example: http://www.filmweb.pl/Twórca+%22Stanu+gry%22+szykuje+thriller+o+świadkach+morderstwa,News,id=58820 It looks like this: http://yfrog.com/2edef003p

You will probably need accont there. I will try to find other sites also.

I'm using build 6240 linux i386.

Temporary Patch

I don't understand what's going on there. Even if there were an array named menuFunctions (which I don't think there is), my variable should exist only within the scope of my function, so how does it get polluted from outside? 

Anyhow, I patched it for now, though the real question is how this variable can be leaking. I changed the code like follows:

		for (var i in menuFunctions) {
			menuList.appendChild(li = document.createElement('li'));
			li.appendChild(a = document.createElement('a'));
			with (a) {
				textContent = menuFunctions[i][0];
				addEventListener('click', menuFunctions[i][1], false);
			}
		}

To this


for (var i in menuFunctions) { // Checking if there are no outside "menuFunctions" leaking into the script. They can still leak (I don't understand why), but only if they are constructed the exact same way. if (typeof menuFunctions[i] == 'object' && typeof menuFunctions[i][0] == 'string' && typeof menuFunctions[i][1] == 'function') { menuList.appendChild(li = document.createElement('li')); li.appendChild(a = document.createElement('a')); with (a) { textContent = menuFunctions[i][0]; addEventListener('click', menuFunctions[i][1], false); } } }

Intelligent alien life does exist, otherwise they would have contacted us.

I added to it, a else {

I added to it, a else { alert("strange: "+i); }

and got:

each, eachSlice, all, any, collect, detect, findAll, grep, include, inGroupsOf, inject, invoke, max, min, partition, pluck, reject, sortBy, toArray, zip, size, inspect, find, select, member, entries, _reverse, _each, clear, first, last, compact, flatten, without, uniq, clone, toJSON

It looks that some freamwork added this function to Array. I guess this is because somebody redefined Array function/object creation (so var menuFunctions = new Array(); will create object with additional methods).

IMHO it is sufficient to test if varible i is integer. Your solution is also working, but testing for integer is simpler, and probably will be more compatible with other freamworks.

For the specific site you

For the specific site you linked to, sure. That would suffice. But what about other stuff out there? Why would we want compatibility with other frameworks? That sounds like asking for other stuff leaking in to me.

Intelligent alien life does exist, otherwise they would have contacted us.

So please add integer testing.

Adding (typeof i == "integer") to this conditoinal (as first) will only help in preventing problems.

Adding this is crucial, because there CAN be something added by some freamworks which will happen to be of the same form as your entries! But i guess nobody will be so stupid to mess with integer indices becuase it is purpose of Arrays!

Thanks.

I will add it. I thought you

I will add it. I thought you were saying we should get rid of all other conditionals. Sorry about that.

Intelligent alien life does exist, otherwise they would have contacted us.

Simpler way

How about using this:

if( menuFunctions.hasOwnProperty(i)) {
}

// where i is some kind of value, like integer or string.

I think this is built in feature of JavaScript, to distinguish between own properties and this derived from type prototype. I found this really important, and actually pure "for (var i in x)" without this "if (x.hasOwnProperty(i)) " is in most cases of some interactions with other frameworks just dangerous.

I was was thinking of

I was was thinking of propertyIsEnumerable(). The result seems essentially equivalent if I'm not mistaken. :)

Intelligent alien life does exist, otherwise they would have contacted us.

(No subject)

This script & opera 1051

Can you tell me if this java script works on opera 1051 please, because I don't seem to be able to get this working!!!

It works for me. 

It works for me. 

Intelligent alien life does exist, otherwise they would have contacted us.

Doesn't seem to work.

When does the saver kick in? after every keypress, 10 characters or a enter? Because didn't seem to work on some pages including my opera forums, but worked some other places. But then my comment could have been small or one-lined. Opera 10.52 here.

That depends on your settings

By default after each keypress and on blur (i.e. as you put it, when you press enter). There's a bug in Opera or DragonFly at the moment so that using DragonFly makes localStorage stop working for some reason. Perhaps you did that?

Also note that by default there's a timeout of 2.5 hours. If you think you need backups to remain for longer, increase the number of hours or days. Perhaps I'll increase the default (which is mostly aimed at keeping the previous cookie-based method from completely overflowing) to a couple of days or so in the next version, since 5MB of localStorage is a lot to fill up. But in my personal usage the default easily fills my needs. I'm thinking it might get a little annoying to see something you typed days ago again, so I don't think I'd be very keen on increasing it too much. But since you can make it 300 days if you please, whatever the default is shouldn't be an issue.

Intelligent alien life does exist, otherwise they would have contacted us.

Ok

Ok. I had used Dragonfly but not on those pages. Will try again today.

Meanwhile I have other issues today. On a Vbulletin forum I had used quick reply option and since that is on every page on that forum I am getting annoying popups about filling the text areas the moment I go to any page on that forum. And I can't seem to clear data from localStorage so it becomes even more annoying. Only delete private data option is working to clear it.

You could add it to the list

You could add it to the list of exceptions, or disable "Restore automatically", "Ask before overwriting" or both. Strange that they all come up with the same baseURI, though.

Intelligent alien life does exist, otherwise they would have contacted us.

hidden

This JS gives more trouble than it solves.

I think thnx to it I had some trouble with spell check, and it always tries to put text in text field even when I did not pressed that button...  it need to be hidden until awaken!

Could you try to be more

Could you try to be more specific?

Is the restore_auto setting not functioning correctly or did you never put it on false? In the latter case, there are various configuration options available which should hopefully allow you to customize the script to work in a way you like. The default settings are essentially my personal preferences. The Unite UserJS application makes changing these settings very easy.

Is there any particular site where you have problems with the spell checker? If the spell checker ceases to work somewhere in combination with this script I would be inclined to think it's an Opera bug or something with the site, but I will of course try to investigate.

If you hadn't guessed, that

If you hadn't guessed, that was me. Whoops.

Intelligent alien life does exist, otherwise they would have contacted us.

Most of my complains were

Most of my complains were solved by using UserJS manager(tried to install it, did not work, tried editing JS, just false/true, but it strangely did not work ^^ , then I realized I had no unite turn on, so I finally installed manager)

You should emphasize the use of UserManager regarding possibilities of options of your userJS, they take it to next level.

www.reddit.com is my next problem

1. The restore button often flied all over the page as I remember when I tried it first time

2. But now, when I am trying this userJS (10.53), I can't restore text of replies as oppose to comments (comment is in the field that is always at the top of the page so theres no issue there, but reply can be buried anywhere on the page or can be done from inbox or any strange way. I think it worked before, but I am not sure. But don't be too concerned by reddit yet, they have some other issues even with clean 10.5+ opera as well and I had no real time to test it properly

Not working in 10.53

This has stopped working for me in 10.53.

Same for anyone else? or can I feel a fresh installation coming on.

Works for me in 3370 (10.52)

Works for me in 3370 (10.52) and 3381 (currently latest snapshot). I skipped 3374 (10.53), but I see no reason for it not to work in that. Unless it's on a particular URL I'm afraid it's probably on your end.

Intelligent alien life does exist, otherwise they would have contacted us.

Time for a fresh install then.

Thought it might be at my end. It doesn't work anywhere at all, when it was fine before.

Oh well fresh install tomorrow then, I've tried deleting operaprefs.ini in the hope that would sort it but no such luck.

 I'll report back if it works then.

Today it works before a reinstall

Didn't have time today to reinstall.

But today it works everywhere that it wasn't yesterday.

There be some strange sorcery going on. ;o)

Using DragonFly sometimes

Using DragonFly sometimes results in the failing of localStorage for me, though I thought they'd fixed that by now. Perhaps something like that?

Intelligent alien life does exist, otherwise they would have contacted us.

Rarely use Dragonfly

Rarely use Dragonfly, but possible I suppose.

It stopped working again next time I ran Opera, so I bit the bullet and did a fresh install. Has been working fine since, so hopefully whatever broke it won't do so again.

hello this does not work in

hello

this does not work in website interpals.com

the script does not distinguish the text field and it restores the latest entered text in any textfield

Works on 10.60

Thx for your work! Its perfekt :p

mfg o.c.b

You're welcome!

You're welcome!

Intelligent alien life does exist, otherwise they would have contacted us.

On Facebook

On Facebook, after installing GM_emulator userjs, It kinda seems to keep bringing back old comments. 

I will try and eliminate the issue and report it clearly.

Unable to browse through search results

Hello!

When I have Textarea-Backup enabled I can't browse through the search results on http://www.ncbi.nlm.nih.gov/pubmed.

Try to search for something and then click on "next". Nothing happens.
Please fix this.

Here's a screenshot from the error console:

I would just add it under

I would just add it under @exclude. I took a quick look and they seem to be using tons of scripts for what doesn't even seem to require any scripting at all.

Intelligent alien life does exist, otherwise they would have contacted us.

Thanks for the solution

Thanks for the solution Frenzie!

Buggy: Script goes into

Buggy:

Script goes into recursion on submit event in some cases. For instance in Joomla, in NetFtp etc. Probably there, where submit event generated by other script.

Opera Dragonfly show recursion at

theform.submit = function() {
 >>> onsubmit();
self.ta.form.the_actual_submit_method();
 };

Same problem occurred on LibraryThing

Sorry, I must've missed overlooked this comment last year . I didn't actually fix the bug, but I changed it so that it won't occur with the default settings. 

Intelligent alien life does exist, otherwise they would have contacted us.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

By submitting this form, you accept the Mollom privacy policy.