I have a ResetTime function implemented that I need to stop once a modal is being called. The ResetTime function is being used for a session timeout. Everytime there is user interaction the time gets reset.
ResetTime function
function ResetTime() {
timer = SetLastResetTimeStamp((new Date()).getTime());
}
function SetLastResetTimeStamp(timeStamp) {
if (_localStorage) {
_localStorage[_localStorageKey] = timeStamp;
} else {
_lastResetTimeStamp = timeStamp;
}
}
User Interaction checks:
AttachEvent(document, 'click', ResetTime);
AttachEvent(document, 'mousemove', ResetTime);
AttachEvent(document, 'keypress', ResetTime);
AttachEvent(window, 'load', ResetTime);
Is there a way to stop the ResetTime function in another function?
if(modal is open) return;if driving -> don't hold phoneand so in code it's only logical to set up conditions as well. you need to useifstatement, and then set the condition for which the function should be called in the first place, or if the condition cannot be set there then you should set it within the function itself, like @Phiter wrote above.