jquery - deciding whether a user is "away"
- by Phil Jackson
hi, im doing a little test to check whether the user is "away" (unactive) or not;
function away_status(){
$("#away_stat_update").everyTime(1000, function(i) {
var number = Number($(this).html());
if( number == 20 ) {
// set user as away
alert( "user away" );
}
if( number > 20 ) {
$("*").mousemove(function(e){
$("#away_stat_update").html(0);
var number = Number(0);
// reset user to being online
alert( "user back online" );
});
}
$("#away_stat_update").html( number + 1 );
});
$("*").mousemove(function(e){
$("#away_stat_update").html(0);
});
}
away_status();
the only problem is that when the number is greater than 20 and the mouse is moved it keeps alerting "user back on line" instead of doing it just once. The number is resetting by the way.