NetTalk Central

Author Topic: Client countdown  (Read 2096 times)

hkalmbach

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
    • Email
Client countdown
« on: March 18, 2021, 07:51:58 AM »
Hello,

I want to offer the user a countdown for being logged out and of course activate the countdown on client side.
I found no example where I can see this all. I found some where page footer the embed code

  if (p_web.GetSessionLoggedIn() and p_web.PageName <> 'LoginForm')
    ! parameter 1 is the session time
    ! parameter 2 is the name of the login page.
    ! parameter 3 is the id of the <div> in the html.
    p_web.Script('startCountDown('& int(p_web.site.SessionExpiryAfterHS/100) &',"' & clip(p_web.site.DefaultPage) & '?logout_btn=logout_btn","countdown");') 
  end


is present (one is web67), but the logout is not performed. Also I did not succeed to show the user the count down.
Is there an example which contains all that?
What can be wrong?
Where exactly I have to insert the code for showing the countdown to the user?

Thanks for every help.
Cheers
Heinz

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Client countdown
« Reply #1 on: March 18, 2021, 04:42:41 PM »
Well, that is convenient for me. I was just about to ask why my countdown was no longer working.

The developer Console says:

Uncaught Error: Syntax error, unrecognized expression: #
    error https://resschedtest.com/scripts/all.js?c=1:4
    tokenize https://resschedtest.com/scripts/all.js?c=1:4
    select https://resschedtest.com/scripts/all.js?c=1:4
    se https://resschedtest.com/scripts/all.js?c=1:4
    find https://resschedtest.com/scripts/all.js?c=1:4
    init https://resschedtest.com/scripts/all.js?c=1:4
    k https://resschedtest.com/scripts/all.js?c=1:4
    countDown https://resschedtest.com/scripts/all.js?c=1:15271
    startCountDown https://resschedtest.com/scripts/all.js?c=1:15295
    <anonymous> https://resschedtest.com/BrowseForm:642

And sure enough there is a # in countDown

  jQuery('#' + icnt).html(t);

Using NT11.48

Any advice gratefully received.  Thanks

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: Client countdown
« Reply #2 on: March 19, 2021, 07:35:48 AM »
hi Heinz,

If you want proper session-timeout-management then you probably want to use NetTalk 12 for this. It has a Client-Side Session Manager widget which allows for the countdown, popup warning to the user, and so on.

That said;
The embed code works with the <DIV> as specified in the xHTML of the footer.
And as you can see it only applies if the user is logged in. Since example 67 does not have a login procedure, then user can never be logged in there, and hence there's no automatic logout.

Casey:
what does your code in the Footer procedure look like, and do you have an appropriate <div> in your footer area?
Also you might need to be on 11.50.

cheers
Bruce

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Client countdown
« Reply #3 on: March 22, 2021, 12:00:51 PM »
Hi, Bruce

Here is what I have done so far

Updated to 11.50:
Confirmed that all of the js files included in update are present in the app web\script folder;
Removed all of the custom and third party scripts from all.js;
Stripped all other code in the page footer procedure;
Ran GZIPALL (seveal times);
Regenerated and recompiled app (several times);
Cleared the browsers' caches (several times).

------------------------------
Here is the only code embed left in PageFoorter procedure

          !Set count down to inactivity timeout
IF (p_web.GetSessionLoggedIn() and p_web.PageName <> p_web.site.LoginPage)                                           !parameter 1 is session time (server setttings in seconds from Clarion Long)
   p_web.Script('startCountDown('&int(p_web.site.SessionExpiryAfterHS/100)&',"'&'LogoutPage'&'","");')                !parameter 2 is logout page
END                                                                                                                                                                           !parameter 3 is the id of <div> in the html
! output eg.  startCountDown(900,"LogoutPage","");                               

-------------------------------
Here is the html for the pagefooter and the scripts:

<div id="pagefootertag_div"   data-role="footer">
<div  class="nt-width-100 nt-left nt-margin-top"><fieldset  class="ui-corner-all">
</fieldset></div>
</div><!-- pagefootertag -->

<body class="PageBody">
<div id="body_div" class="PageBodyDiv">
<script>$("#menu1").ntmenu({ position:{ my: "left top", at: "left+0 bottom+1"},
burger:"menu1_burger",
icons:{ submenu: "ui-icon-circle-triangle-s"},
touch:0,
ul:"menu1"});

initTabID();

getScreenSize();

startCountDown(120,"LogoutPage","");

</script>

Just to mention the line <body class="PageBody"> is showing in red the source code view.

Thanks

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: Client countdown
« Reply #4 on: March 22, 2021, 11:46:53 PM »
hi Casey,

Probably best if you make an example app with the problem that I can run here.
also, you might try your app in Development mode, not Performance mode (aka Debug not Web) to see if that makes a difference.

Cheers
Bruce

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Client countdown
« Reply #5 on: March 24, 2021, 05:35:50 PM »
Found it.

  p_web.Script('startCountDown('& int(p_web.site.SessionExpiryAfterHS/100)  &',"'& 'LogoutPage' &'","countdown");')   

works

  p_web.Script('startCountDown('& int(p_web.site.SessionExpiryAfterHS/100)  &',"'& 'LogoutPage' &'","");')   

doesn't

The only difference is the word 'countdown' between the double quotes.  That wasn't necessary before but it is now, even though there is no DIV labeled countdown in either the source or target page.

Thanks.