Guest User

piwikautologout_testing.html

a guest
Feb 20th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 2.52 KB | None | 0 0
  1. <!--
  2.  
  3.     piwikautologout.html
  4.  
  5. -->
  6.  
  7.  
  8. <!DOCTYPE html>
  9. <html>
  10. <head>
  11. <meta charset="UTF-8">
  12. <title>Title of the document</title>
  13. </head>
  14.  
  15. <body>
  16.     <script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>
  17. <script>
  18. (function ($) {
  19.  
  20.     $(document).ready(function () {
  21.         var idleTimer = null,
  22.             idleState = false,
  23.             /**
  24.              *  idleWait -  number of milliseconds after which idle user session should be destroyed
  25.              *  by redirecting automatically to logout page
  26.              *
  27.              *  => Sample Values (Give appropriate value as per Piwik's collective desicion)
  28.              *  idleWait = 86400000;  // no. of milliseconds in 1 day
  29.              *  idleWait = 172800000; // no. of milliseconds in 2 day
  30.              *  idleWait = 259200000; // no. of milliseconds in 3 day
  31.              *  idleWait = 345600000; // no. of milliseconds in 4 day
  32.              *  idleWait = 432000000; // no. of milliseconds in 5 day
  33.             */
  34.             idleWait = 10000; // user idle session expiry time is set at 3 day
  35.  
  36.         // when none of these events occurs after the prolonged auto-expiry time has passed,
  37.         //we redirect to logout page. Add any missing events to 'bind' if any.    
  38.         $('*').bind('mousemove click mouseup mousedown keydown keypress keyup submit change mouseenter scroll resize dblclick', function () {
  39.             // clear idleTimer
  40.             clearTimeout(idleTimer);
  41.                    
  42.             if (idleState == true) {
  43.                 // Reactivated event. Do nothing
  44.             }
  45.            
  46.             idleState = false;
  47.            
  48.             idleTimer = setTimeout(function () {
  49.                 // Idle Event
  50.                 var protocol = window.location.protocol;
  51.                 var host = window.location.hostname;
  52.                 var loginRedirectUrl = protocol + '//' + host + '/piwik/index.php?module=Login&action=logout';
  53.                 /*
  54.                  *  This alert is for developers willing to test the functionality
  55.                  *  by setting idleTime=5000 (5 millisecond) or so. Uncomment alert and change idleTime to test.
  56.                 */
  57.                 //alert('You are idle for a prolonged period of time and so redirected back to login page!');
  58.                 window.location.replace(loginRedirectUrl);
  59.                 idleState = true; }, idleWait);
  60.         });
  61.        
  62.         $("body").trigger("mousemove");
  63.    
  64.     });
  65. }) (jQuery)
  66. </script>
  67. Content of the document......
  68. </body>
  69.  
  70. </html>
Add Comment
Please, Sign In to add comment