Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session time out counter show NAN #33

Open
joshiamit24 opened this issue May 16, 2016 · 15 comments
Open

Session time out counter show NAN #33

joshiamit24 opened this issue May 16, 2016 · 15 comments
Assignees

Comments

@joshiamit24
Copy link

Session time out counter shows NAN till the page gets redirect. The dialog box doesn't disappear.

image

@joshiamit24
Copy link
Author

How to disable the confirmation dialog once click on Log Out Now.? Can I customize the look and feel of the dialog box.

@JillElaine
Copy link
Owner

If the redirect process takes longer than the time remaining on the countdown timer...or if public variable 'redirectUrl' is set to false, the dialog box will show NaN. I do not have the ability to fix the code right now, but you could modify it: modify the jquery-idleTimeout-for-testing.js and watch the console to see how your changes affect the process.

To prevent the 'NaN' display, modify the 'countdownDisplay' function:

    // display remaining time on warning dialog
    countdownDisplay = function () {
      var dialogDisplaySeconds = currentConfig.dialogDisplayLimit, mins, secs;

      remainingTimer = setInterval(function () {
        mins = Math.floor(dialogDisplaySeconds / 60); // minutes
        secs = dialogDisplaySeconds - (mins * 60); // seconds
        if (mins == 0 && secs == 0) {
           $('#countdownDisplay').html('Times up! Be patient while we redirect.'); 
        } else {
          if (mins < 10) { mins = '0' + mins; } 
          if (secs < 10) { secs = '0' + secs; }
          $('#countdownDisplay').html(mins + ':' + secs);
          dialogDisplaySeconds -= 1;
        }
      }, 1000);
    };

To customize the look and feel of the dialog box, please see this FAQ: https://github.com/JillElaine/jquery-idleTimeout/wiki/Frequently-Asked-Questions

@joshiamit24
Copy link
Author

Thanks.


From: JillElaine notifications@github.com
Sent: Tuesday, May 17, 2016 1:11 PM
To: JillElaine/jquery-idleTimeout
Cc: joshiamit24; Author
Subject: Re: [JillElaine/jquery-idleTimeout] Session time out counter show NAN (#33)

If the redirect process takes longer than the time remaining on the countdown timer...or if public variable 'redirectUrl' is set to false, the dialog box will show NaN. I do not have the ability to fix the code right now, but you could modify it: modify the jquery-idleTimeout-for-testing.js and watch the console to see how your changes affect the process.

To prevent the 'NaN' display, modify the 'countdownDisplay' function:

// display remaining time on warning dialog
countdownDisplay = function () {
  var dialogDisplaySeconds = currentConfig.dialogDisplayLimit, mins, secs;

  remainingTimer = setInterval(function () {
    mins = Math.floor(dialogDisplaySeconds / 60); // minutes
    secs = dialogDisplaySeconds - (mins * 60); // seconds
    if (mins == 0 && secs == 0) {
       $('#countdownDisplay').html('Times up! Be patient while we redirect.');
    } else {
      if (mins < 10) { mins = '0' + mins; }
      if (secs < 10) { secs = '0' + secs; }
      $('#countdownDisplay').html(mins + ':' + secs);
      dialogDisplaySeconds -= 1;
    }
  }, 1000);
};

To customize the look and feel of the dialog box, please see this FAQ: https://github.com/JillElaine/jquery-idleTimeout/wiki/Frequently-Asked-Questions

[https://avatars0.githubusercontent.com/u/1692562?v=3&s=400]https://github.com/JillElaine/jquery-idleTimeout/wiki/Frequently-Asked-Questions

Frequently Asked Questions · JillElaine/jquery-idleTimeout ...https://github.com/JillElaine/jquery-idleTimeout/wiki/Frequently-Asked-Questions
github.com
jquery-idleTimeout - Idle activity timeout and logout redirect for jQuery for multiple windows & tabs

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHubhttps://github.com//issues/33#issuecomment-219787146

@joshiamit24
Copy link
Author

joshiamit24 commented May 19, 2016

Hi Elaine,

In my project, I have three master pages and some pages don't have reference of master page. so I have created user control(added ideal time out script here) and added on master page and the page which doesn't have master page reference. The page without master page reference opens in tab. It shows time out dialog but when I click on logout button it is not logging out from parent page(with master page reference).

Do you have any suggestions?

@JillElaine
Copy link
Owner

Are all of your page from the same domain? If some of your pages are from a subdomain within your main domain, please see this: #24

Also, you must load the idleTimeout script only once per site. It sounds like you add the script multiple times, which will not work correctly.

@joshiamit24
Copy link
Author

joshiamit24 commented May 19, 2016

All the pages are from same domain. But some don't have master page reference. so I need to add the user control on that page. The user control has the script for timeout. If I don't add user control on the page which doesn't have master page reference then time out dialog will not be displayed. It will get displayed on page which has master page reference.

Will this work in this scenario?

@JillElaine
Copy link
Owner

You need to configure your site so that only one instance of the idleTimeout script is running. If you load the script on the master page, and then load the script again on pages without a reference to the master page, the script will not work correctly.

@joshiamit24
Copy link
Author

joshiamit24 commented May 20, 2016

Thanks Elaine for quick response. so in this demo http://jillelaine.github.io/jquery-idleTimeout/ it creates single instance because it opens same page in different tab. Is that correct? do I need to implement the session at db side? or can we use local storage to check if script is already loaded.

What if I create separate script file and reference it from all pages which don't have master page reference?

@JillElaine
Copy link
Owner

When I have use the script on a website, it is for logged-in users. So, when a user logs in (username + password), I then load the scripts (store.js & jquery-idleTimeout.js)
<script src="javascripts/store.min.js" type="text/javascript"></script>
<script src="javascripts/jquery-idleTimeout.js" type="text/javascript"></script>
in a header file that is included on every page on the site.

And then I add the document.ready function to start the idleTimeout script in the body of the page.
<script type="text/javascript" charset="utf-8"> $(document).ready(function () { $(document).idleTimeout({ redirectUrl: 'my-logged-out-page.html', // redirect to this url }); }); </script>

Once I have started the script, I do not start it again. It will already be running on every page within the domain.

@joshiamit24
Copy link
Author

are you adding the document.ready function on every page? or on master page?

@JillElaine
Copy link
Owner

The document.ready function is on a page snippet that is included within every page, like a template piece.

@joshiamit24
Copy link
Author

joshiamit24 commented May 20, 2016

ok thanks. How to identify if one or more instance of scripts are running? so on every page header and document.ready code is present.

@a-espitia
Copy link

in my branch, i added:
if (dialogDisplaySeconds <= 0) dialogDisplaySeconds = 0; //get rid of NaN display
on the line after dialogDisplaySeconds -= 1;

@joshiamit24
Copy link
Author

Thanks

I have already modified my code.

Thanks

Amit Joshi


From: a-espitia notifications@github.com
Sent: Tuesday, June 28, 2016 2:38 PM
To: JillElaine/jquery-idleTimeout
Cc: joshiamit24; Author
Subject: Re: [JillElaine/jquery-idleTimeout] Session time out counter show NAN (#33)

in my branch, i added:
if (dialogDisplaySeconds <= 0) dialogDisplaySeconds = 0; //get rid of NaN display
on the line after dialogDisplaySeconds -= 1;

You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com//issues/33#issuecomment-229142386, or mute the threadhttps://github.com/notifications/unsubscribe/AHx71MfrAAfmk7am6yTAmlWP9AHfXEhGks5qQWo1gaJpZM4Ifwrg.

@JillElaine
Copy link
Owner

joshiamit24, did you use my suggestion to prevent NaN or a-espitia's? Thank you both for your input. I hope to be able to update my code someday and appreciate the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants