Last active
June 2, 2018 01:12
-
-
Save AlexR1712/68da3c0a78d8839b87c34c4433f759d2 to your computer and use it in GitHub Desktop.
Revisions
-
AlexR1712 revised this gist
Jun 2, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,4 +17,4 @@ window.setInterval(function(){ console.log('Last Activity Date time', lastActivityDatetime); console.log('Seconds spended on site', timeActiveOnSite); console.log('Seconds out the site', timeActiveOnSite); -
AlexR1712 created this gist
Jun 2, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ // Script for track user activity in page and out the page var timeActiveOnSite = 0; // seconds var timeInactive = 0; // seconds var lastActivityDatetime; window.setInterval(function(){ if(document['visibilityState'] === 'visible'){ timeActiveOnSite++; lastActivityDatetime = Date.now(); } else { timeInactive++; var timeDiff = Date.now() + (timeInactive * 1000) if( (timeDiff - Date.now()) > 10*1000 ) { // 10 seconds inactity invokes alert alert('User is inactive, clear session data!'); } } },1000); console.log('Last Activity Date time', lastActivityDatetime); console.log('Seconds spended on site', timeActiveOnSite); console.log('Seconds spended on site', timeActiveOnSite);