Thursday, February 3, 2011

There's no special prize.

There's no special prize.

I love when companies have a sense of humor. Redbox demonstrates theirs by reminding customers "There's no special prize for putting the dvd back in the case the right way. But you'll be a better person for it."

Sadly I have received a few damaged disks from redbox (and Netflix) - I often wonder what people do to them. Do their dogs maul them? Kids toss them around the house?

Tuesday, February 1, 2011

Desktop / Web notifications

Inspired by GMail's recent release of Desktop Notifications, I decided to research the feasibility of using them to replace the notification area for an application I work on. Since I develop for a small internal group I can target newer browsers such as Chrome and Firefox.

The W3C specification for Web Notifications is still in draft but outlines the concept well. The website must request permission and then may publish notifications for the browser to display.

Google Chrome / Chromium
Chromium has published their API specification and it closely resembles the W3C specification. The onclick attribute is currently missing and onshow is called ondisplay.

Firefox
Sadly Firefox 4 will not have support for Web Notifications. Bug 594543 is currently tracking the implementation for a future version but does not have a milestone listed. It's slightly concerning that the bug author is already suggesting a deviation from the W3C specification - they would rather include a callback on the Notification constructor instead of implementing the onshow, onclick, onerror, and onclose attributes.

Examples:

The last example uses setTimeout to call cancel after 15 seconds. This seems like a good way to ensure the popup is closed; however, I'm slightly surprised they did not call setTimeout within the Notification's onshow method. Unless the notification is immediately displayed the setTimeout timer is needlessly wasting time. The rationale for this choice may be because there is no guarantee that the onshow method will be called immediately.