Last active
          August 29, 2015 13:56 
        
      - 
      
- 
        Save logicaroma/9211136 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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
    
  
  
    
  | var handleVisibility = function(){ | |
| if ( document.hidden ) { | |
| // The page is hidden. | |
| Store.set('app:hidden', Date.now()); | |
| } else if( Store.has('rabobank:app:hidden') ){ | |
| // The page is visible and has a timestamp saved. | |
| var timestamp = new Date(Store.get('app:hidden')), | |
| maxTimePassedAllowed = 1000 * 60 * 2, | |
| isPast = (new Date().getTime() - timestamp < maxTimePassedAllowed) ? false : true; | |
| if( isPast ){ | |
| services.logOff(); | |
| } | |
| } | |
| }; | |
| document.addEventListener('visibilitychange', handleVisibility); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment