Timer

I am using the following script to time out a user. It works great but once I added it other parts of the system such as validation scripts and other things stopped working. Perhaps because the script is applied to 'document' ?
Is there an alternative I can try ?  this is my code as it is currently:

<script src="../includes/js/plugins/toastr/toastr.min.js"></script>
<script>
var timer;
$(document).ready(function () {
  // Set idle time
  $(document).idleTimer(5000);
});

$(document).on('idle.idleTimer', function(event, elem, obj){
  toastr.options = {
    "positionClass": "toast-top-right",
    "timeOut": 300000
  }

  toastr.warning('You have been idle for too long, to stayed logged in please move your mouse.','Idle for too long');
  $('.custom-alert').fadeIn();
  $('.custom-alert-active').fadeOut();
  timer = setTimeout(function() {
    window.location = '../Signout.asp';
  }, 300000);
});

$(document).on("active.idleTimer", function(event, elem, obj, triggerevent){
	toastr.options = {
    "timeOut": 3000
  }
  // function you want to fire when the user becomes active again
  clearTimeout(timer);
  toastr.clear();
  $('.custom-alert').fadeOut();
  toastr.success('Great to see you back!','You are back. ');
});
</script>

Open in new window

LVL 1
AleksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
We would need to see this in the context of the page that is not working.

Are there errors in the console?
0
AleksAuthor Commented:
Yes there is one. when I load the page it displays the error attached.  If I add the toast scipt here, or anywhere for that matter then I get this error and it some of the scripts in the include file like the validation scripts.

 I put the script inside an include file with the rest of the scripts below:

And the include file is right before the </body>  tag.

<!-- Mainly scripts -->
<script src="../includes/js/jquery-2.1.1.js"></script>
<script src="../includes/js/bootstrap.min.js"></script>
<script src="../includes/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="../includes/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    
<!-- Custom and plugin javascript -->
<script src="../includes/js/inspinia.js"></script>
<script src="../includes/js/plugins/pace/pace.min.js"></script>

<!-- iCheck -->
<script src="../includes/js/plugins/iCheck/icheck.min.js"></script>
 <script>
            $(document).ready(function () {
                $('.i-checks').iCheck({
                    checkboxClass: 'icheckbox_square-green',
                    radioClass: 'iradio_square-green',
                });
            });
</script>

<!-- Forms validation scripts -->
<script src="../includes/formvalidation/dist/js/formValidation.min.js"></script>
<script src="../includes/formvalidation/dist/js/framework/bootstrap.min.js"></script>

<!-- Date picker validation scripts -->
<script src="../includes/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="../includes/js/plugins/clockpicker/clockpicker.js"></script>  

<!-- Toastr script -->

<script src="../includes/js/plugins/toastr/toastr.min.js"></script>
<script>
var timer;
$(document).ready(function () {
  // Set idle time
  $(document).idleTimer(5000);
});

$(document).on('idle.idleTimer', function(event, elem, obj){
  toastr.options = {
    "positionClass": "toast-top-right",
    "timeOut": 300000
  }

  toastr.warning('You have been idle for too long, to stayed logged in please move your mouse.','Idle for too long');
  $('.custom-alert').fadeIn();
  $('.custom-alert-active').fadeOut();
  timer = setTimeout(function() {
    window.location = '../Signout.asp';
  }, 300000);
});

$(document).on("active.idleTimer", function(event, elem, obj, triggerevent){
	toastr.options = {
    "timeOut": 3000
  }
  // function you want to fire when the user becomes active again
  clearTimeout(timer);
  toastr.clear();
  $('.custom-alert').fadeOut();
  toastr.success('Great to see you back!','You are back. ');
});
</script>

Open in new window

error.PNG
0
sajayj2009Commented:
Which is plugin for idleTimer in above code?
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Julian HansenCommented:
I don't see anywhere where you re including the idle-timer library.

The javascript code is erroring on that missing file and so the rest is failing.

Fix that first.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AleksAuthor Commented:
That was the issue. I found the library and now the issue is fixed !  Thanks so much !
0
Julian HansenCommented:
You are welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.