Hi!
I have this code in my 'Learn jQuery' project...

$(document).ready(function() {
    //try idle events
    var _events = [[window, 'scroll'], [window, 'resize'], [document,
'mousemove'], [document, 'keydown']];
    jQuery.each(_events, function(i, e) {
        // console.log(e.toString());
        $(e[0]).bind(e[1], function () {onActive()})
    });

    $(document).bind(
        'state:idle',
        function () {console.log('system idled')}
    );

    var _timer;
    function onActive(){
        // console.log('Neo, wake up!');
        $(document).trigger('state:active');
        clearTimeout(_timer)
        _timer = setTimeout(function ()
{$(document).trigger('state:idle');}, 10000);
    }
});

not perfect, i know. I need help with this - i want it to become perfect and
i want it to make a jQuery plug-in or standalone class i can 'new' with time
parameter... Both tasks simple, i'm sure, but i can't do them.
Can anybody help?

BTW: short story - its something that allow me to check for user idle time
and do something in, say, 10 mins of inactivity (autologoff or discard
changes... of redirect him to Flickr/YouTube ;) )

Reply via email to