jquery - deciding whether a user is "away"
Posted
by Phil Jackson
on Stack Overflow
See other posts from Stack Overflow
or by Phil Jackson
Published on 2010-03-25T09:04:24Z
Indexed on
2010/03/25
9:13 UTC
Read the original article
Hit count: 261
jQuery
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.
© Stack Overflow or respective owner