Delay an event and ignore all future instances in the meantime.
var delayedActivity; // define variable
// wait each time the user does something
// run a function if user doesn't repeat action for a specific length of time
var delay = function(data, timeGap) {
clearTimeout(delayedActivity); // delete previously started activity (if any)
delayedActivity = setTimeout(function(data){ // start new delayed acticity with new data
// do something here if user is idle
}, timeGap); // ms to wait
};