Guest User

Untitled

a guest
Jul 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.08 KB | None | 0 0
  1.   (function($){
  2.     $.idleTimer = function(){
  3.        var timerIdleCheck=window.setTimeout(function(){
  4.          showTimeoutWarning();
  5.        }, 5000);
  6.        //var timerKeepAlive=window.setInterval(function(){alert('Woot Woot')},5000);
  7.        
  8.        $(document).mousemove(function(){
  9.          window.clearTimeout(timerIdleCheck);
  10.          timerIdleCheck = window.setTimeout(function(){
  11.           showTimeoutWarning();
  12.          }, 5000);
  13.        });
  14.        
  15.        this.showTimeoutWarning = function(){
  16.          var dialog=document.createElement('div');
  17.          var timeRemaining=document.createTextnode('60')
  18.          $(dialog).append("Warning! Youve been idle too long and will be log shortly.<br/><b>Time Remaining:</b>").append(timeRemaining).append("<br/><br/>Extend Session?");
  19.           $(dialog).dialog({
  20.             width: 700,
  21.             modal: true,
  22.             buttons:{'Done':function(){ $(this).dialog('destroy') }}
  23.           });
  24.          var timerWarning = window.setInterval(function(){timeRemaing.value=Number(timeRemaining)-1});
  25.        }
  26.     }
  27.   })(jQuery);
Add Comment
Please, Sign In to add comment