Autosaving Form Data #
Due to my penchant for beta browsers and/or clumsy fingers, I have on more than one occasion lost text I had been laboring over in a form. Given that the modus operandi of most blogging and wiki applications is for the user to dump his/her thoughts in a <textarea>
, this is presumably getting more and more common. The usual solution to this is to do all input in a more capable application or, at the very least, to periodically do a select-all-copy on your text. Unfortunately this is all rather tedious and clumsy. OmniWeb is the only browser that attempts to do something about this, but I happen to use Firefox most of the day, thus this doesn't help.
A Firefox extension would be one way to approach this, but I believe I have come up with a more browser-agnostic solution. Simply drag these two bookmarklets to your toolbar:
Clicking the first favelet will save all form data in the currently visible page (and continue to do so automatically every 30 seconds). Conversely, the second one will restore saved data for the current page.
It sounds perfect, and it almost is. The primary caveat is that cookies are used for storage, therefore we are limited to ~4K. If you're going to be writing your NaNoWriMo opus in a <textarea>
, you may need to look elsewhere. One would think that segmenting the form data into 4K chunks would work, but unfortunately most web servers (Apache included) refuse to accept Set-Cookie
headers longer than 4K, even if they are made up of multiple cookies. Solutions to this (beside the obvious workaround of not using cookies to begin with) are welcome.
"Autosave" must be invoked at least once per editing session, which is also not quite ideal. If you are able to edit the HTML behind that page's form, you can insert the following snippet into its source and have autosaving happen at loading time:
<script type="text/javascript">PAS_mode='save'</script>
<script src="http://persistent.info/autosave/favelet.js" type="text/javascript"></script>
This is a hosted favelet, and thus should automatically update itself if/when I find bugs (or work around the cookie length issue). This also means that it will not work in Safari (as of version 1.2). Mozilla and MSIE behave well, though getting it to operate in both took some work. For example, both browser change JavaScript behavior based on DOCTYPE and/or MIME type. Fun stuff.
Post a Comment