Guest User

Untitled

a guest
Jun 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. $(document).ready(function(){
  2.  
  3. idleTime = 0;
  4.  
  5. //Increment the idle time counter every second.
  6. var idleInterval = setInterval("timerIncrement()", 1000);
  7.  
  8. function timerIncrement()
  9. {
  10. idleTime++;
  11. if (idleTime > 2)
  12. {
  13. doPreload();
  14. }
  15. }
  16.  
  17. //Zero the idle timer on mouse movement.
  18. $(this).mousemove(function(e){
  19. idleTime = 0;
  20. });
  21.  
  22. function doPreload()
  23. {
  24. //Preload images, etc.
  25. }
  26.  
  27. })
  28.  
  29. <script type="text/javascript">
  30. idleTime = 0;
  31. $(document).ready(function () {
  32. //Increment the idle time counter every minute.
  33. var idleInterval = setInterval("timerIncrement()", 60000); // 1 minute
  34.  
  35. //Zero the idle timer on mouse movement.
  36. $(this).mousemove(function (e) {
  37. idleTime = 0;
  38. });
  39. $(this).keypress(function (e) {
  40. idleTime = 0;
  41. });
  42. })
  43. function timerIncrement() {
  44. idleTime = idleTime + 1;
  45. if (idleTime > 19) { // 20 minutes
  46. window.location.reload();
  47. }
  48. }
  49. </script>
  50.  
  51. //when the document is loaded
  52. $(function(){
  53.  
  54. //create an event handler for the mousemove
  55. var preLoadTimer;
  56. $(this).mousemove(function(e){
  57. //clear prior timeout, if any
  58. window.clearTimeout(preLoadTimer);
  59.  
  60. //create new timeout.
  61. preLoadTimer = window.setTimeout(doPreLoad, 2000);
  62. });
  63.  
  64. });
  65.  
  66. // Call aFunction after 1 second
  67. window.setTimeout(aFunction, 1000);
Add Comment
Please, Sign In to add comment