Friday, August 27, 2010

Capturing window "close" action

I was presented with the task of capturing the event in which one of our users would hit the close browser button (you know, that little 'x' on the top right).  The business wanted me to give a warning to the user that his information was still not saved yet.

  I remembered a solution I did a couple of years ago where I simply added a before unload event to my body and some simple Javascript:

     
This works great... in IE, not in Firefox or Chrome though.  The problem is that IE tracks the clientY mouse position and the other browsers don't, so a different solution was needed.  I got some snippets off of the web for tracking mouse position and came up with this cross-browser solution and it works great. First, add the following Javascript to your page:
    


    

Next, add the following form to your page, this simply stores the mouse coordinates, you could use the var values, but I liked having these to debug and see what's happening.
   

That's it! Now you can warn users using any browser that they still have unsaved work. You will still need to monitor whether the page is dirty, etc, but this allows you to at least capture the event.

Monday, August 9, 2010

Backup sensitive file information using Amazon's S3 cloud

Everyone please answer the following questions honestly:

1. Do you store all your digital pictures on your home computer's hard drive, and do you have backups if the hard drive got corrupted?

Would your data be safe? Do you have duplicate media?

2. What if your entire house burned down? (hopefully this will never be the case!)

I have backups, and the HD backup sits about 2 feet from my computer, so I realized that if my house burned down, I could not retrieve my photos.

There are a few options, what I like to call "The Ghetto" backup, which would entail me giving my backup HD to a friend, but guess what? Then I lose access to that and it can easily be outdated.

There are some very good backup services, but they run $50 year, still good to have though.

I opted for Amazon's S3 cloud services, here is their pricing, considering I've got about 10 Gig of pictures, I'm only out about $20/year.

It's honestly pretty rudimentary, they don't really have a great interface, you are left using REST/SOAP calls for advanced handling. That is until I discovered the S3Fox Firefox plugin which makes things a breeze!

Now I have my pictures backed up, and another cool feature is that if I am away from my computer, I still have full access to all my original photos. See the screenshot below, real easy...