I think if there's one thing website users take for granted, it's the fact that browsers crash and that data must be "lost."

For example, let's say I am posting an entry to my Tabulas using this crappy old control panel. What if I were to accidentally close my browser? I know that if this happened to me a few weeks ago, I would have cursed my stupidity, but I never would have blamed the site.

It occured to me yesterday that it really shouldn't be that hard for autosave functions to be built into websites; especially sites like Tabulas where people have a tendency to write longer entries. Imagine the JOY of a user if they were writing, their browser/computer crashed, they cursed, they signed online, and saw... the entry still in their browser! I have yet to lose an entry due to browser crashes (knock on silicon), but I have lost huge amounts of text on other sites (LJ back when they had no servers; this is pre-Tabulas)

Technically, I don't think it would be horribly difficult to pull off.

On the backend, you would have a receiving script that would accept two values: username and the entry. The backend script, whenever it receives any information, would create a temp file (maybe something like /tmp/roy.txt).

On the entry page itself, there would be a JS script that would listen. The idea is *not* to add any type of user-oriented actions; I want to limit the number of buttons displayed to the user, so having a 'save' button is not what I want. I'm thinking of just having a JS function count the number of keypresses on a given textarea, and execute a XMLOverHttp request for every 128 keypresses (or 256). So basically every 128 characters you typed, the site would take that data and save it to some backend without you knowing! When you hit 'submit,' the site would delete your temp file. So the idea is if you accidentally leave or your computer crashes, the site has a somewhat fresh copy of whatever you last typed. Of course, if you opened up for a new entry and the site detected a temp file in existence, it would automatically fill out your textarea with that entry.

I'm not sure how memory-intensive it would get on the client side (wouldn't be anything more than a simple onkeypress and storing a counter), but it would definitely be lightweight on the server side (no db hits; just a simple receive and dump it into a text file).

Food for thought.

Posted by roy on June 28, 2005 at 11:45 PM in Web Development | 10 Comments

Related Entries

Want to comment with Tabulas?. Please login.

jackson (guest)

Comment posted on June 29th, 2005 at 07:29 AM
Roy, I know Blogger does this now and WordPress is adding it to the next version. I think they both do it client-side with cookies rather than making server calls (link: http://twilightuniverse.com/2005/04/twilight-autosave/)
Comment posted on June 29th, 2005 at 07:48 AM
Oh, I had absolutely no idea they were already doing this. Thanks for the link.
Comment posted on June 29th, 2005 at 06:03 AM
That would be so cool. I usually type in Notepad to avoid losing entries to browser crashes, but the copy-paste routine is tedious -- being able to use the control panel without fear of entry loss would be awesome.
Comment posted on June 29th, 2005 at 05:08 AM
Hmmmm... good idea. Manual saving would never get used... I like the auto saving idea!

Is there any way to make the text transferable from the basic editor to the advanced and vice versa? It sounds like you could just implement the autosave to save when the "change editor type" button is pressed and then have it appear in the other editor.
Comment posted on June 30th, 2005 at 06:23 PM
It's something I'm going to look into. If I can hack it out in a few hours, I'll definitely add it into 2.1.
Comment posted on June 29th, 2005 at 04:37 AM
That description would have been much cooler if you had used the term 'automagically' rather than 'automatically'. Might have been a misuse, but to hell with proper use when you are speaking US English, right? :-]
Comment posted on June 29th, 2005 at 12:18 AM
it would be great if the advanced editor would support copy & paste.
Comment posted on June 29th, 2005 at 07:48 AM
clarify
Comment posted on June 29th, 2005 at 08:46 AM
for example, if I wanted to copy and past a url or a text phrase from another web page onto the advanced editor, I do not get an option to paste when I right click. At least this is the case with Firefox. Not sure about IE.
Comment posted on June 29th, 2005 at 09:12 AM
Oh, so right click copy/paste doesn't work. Just use Ctrl+V