Tuesday, June 16, 2009

IE 6 usage ... boooournn

I was curious to see how the announcement that IE 8 would be included in an automated update would affect the Google Analytics for the application I work on. I took a months sample of IE usage before and after the announcement just to see how the number stacked up. Here's what I found:

7.0 68.18%
6.0 20.50%
8.0 11.27%

7.0 58.39%
6.0 21.96%
8.0 19.59%

Unfortunately, I don't see IE 6 disappearing any time soon. Neither does ppk.

Heh ... unless this tricks a few users into upgrading.

In other browser news, I just saw this site springing up: http://dowebsitesneedtolookexactlythesameineverybrowser.com/

Wednesday, June 3, 2009

Idle Handler with dojo

After reading Nicholas Zakas' blog posting about handling idle listeners with YUI, I decided to take a bash at porting his logic to dojo. It turned out to be pretty simple - here's the code:
dojo.declare("my.IdleListener", [], {

_mouseMoveHandle: null,
_keyDownHandle: null,
_timeout: 30000,

isRunning: function() {
return this._enabled;

isIdle: function() {
return this._idle;

start: function(newTimeout) {
this._enabled = true;
this._idle = false;
if (typeof newTimeout == "number") {
this._timeout = newTimeout;
this._mouseMoveHandle = dojo.connect(dojo.doc, "onmousemove", this, "_handleUserEvent");
this._keyDownHandle = dojo.connect(dojo.doc, "onkeydown", this, "_handleUserEvent");
// set a timeout to toggle state
this._idleTimeout = setTimeout(dojo.hitch(this, "_toggleIdleState"), this._timeout);

stop: function() {
this._enabled = false;
// clear any pending timeouts
// detach the event handlers
dojo.forEach([this._mouseMoveHandle, this._keyDownHandle], function(item, index, array) {
if(item) {

_handleUserEvent: function() {
// clear any existing timeout
if (this._enabled) {
// if the user is just waking us up again, toggle the idle state.
// otherwise, reset the timeout with a new timeout
this._idle ? this._toggleIdleState() : this._idleTimeout = setTimeout(dojo.hitch(this, "_toggleIdleState"), this._timeout);

_toggleIdleState: function() {
this._idle = !this._idle;
this._idle ? dojo.publish("idle", []) : dojo.publish("active", []);

To start your idle handler with a default timeout of 30 seconds, all you need to do is:
 var idleListener = new my.IdleListener();

Then in whatever parts of your application deal with polling network resources, all you need to do is:
dojo.subscribe("idle", function() {

dojo.subscribe("active", function() {


For jQuery users, Paul Irish has ported the code. too.

Just posted an update of this code to github. Check it out!