Created
March 11, 2012 20:44
-
-
Save collingo/2018157 to your computer and use it in GitHub Desktop.
Touch screen InactivityTimer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function InactivityTimer() { | |
this.timer = 0; | |
this.threshold = 5000; | |
window.addEventListener('click', this.resetTimer.bind(this), true); // binding to capture phase | |
this.startTimer.call(this); | |
} | |
InactivityTimer.prototype = { | |
startTimer: function() { | |
this.timer = setTimeout(this.resetContent.bind(this), this.threshold); | |
}, | |
resetTimer: function() { | |
clearTimeout(this.timer); | |
this.startTimer.call(this); | |
}, | |
resetContent: function() { | |
clearTimeout(this.timer); | |
// do your reset stuff here | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment