Forum Moderators: open

Message Too Old, No Replies

Timeout Re-direct firing automatically

Timeout Re-direct firing automatically

         

typomaniac

4:15 pm on Jul 22, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



After searching for days for a script which re-directs based on client side inactivity I found what closest resembles what I was looking for. The reason I say closest is because the script activates automatically after a given amount of time but it is not based on inactivity. I’m looking for something like the timeout function banks use. Once the script has fired it can be reset easy enough but still it isn’t based on inactivity. The original can be found at [codepen.io ] but I was unable to locate any contact information. I’ve tried all kinds of things with the index.js script but most attempts usually manage to only break it.
I have links to all the .js and .css readily available in the source code. I can see that it is time for me to learn about javascript. Any help or guidance would be much appreciated.
This is the html in the page where it is being tested shows links to 3 different .js scripts and for some reason I’m thinking the answer to this is probably in the index.js script.

[edited by: not2easy at 4:19 am (utc) on Jul 23, 2017]
[edit reason] removed example link [/edit]

typomaniac

1:47 am on Jul 23, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



Another question I have, what is a good book for getting into javascript, ajax, and jquery programming? I'm not the smartest on the block when it comes to programming but have worked with php and perl. I never used javascript much and when & what I did, I always went with cut and paste but tmtowtdi don't mean nothing if you can't write it. With the perl and php, along with html and css I have a good idea of what is going on and I want to juse some js scripts and would really like to be able to write my own. Any online courses would also be nice.

typomaniac

5:32 am on Jul 23, 2017 (gmt 0)

10+ Year Member Top Contributors Of The Month



This is the code which is responsible for making the script fire automatically instead of based on inactivity.
!function(a){jQuery.sessionTimeout=function(b){function c(b){switch(b){case"start":e=setTimeout(function(){a("#sessionTimeout-dialog").dialog("open"),d("start")},h.warnAfter);break;case"stop":clearTimeout(e)}}function d(a){switch(a){case"start":f=setTimeout(function(){window.location=h.redirUrl},h.redirAfter-h.warnAfter);break;case"stop":clearTimeout(f)}}var e,f,g={message:"Your session is about to expire.",keepAliveUrl:"/keep-alive",redirUrl:"/timed-out",logoutUrl:"/log-out",warnAfter:9e5,redirAfter:12e5},h=g;b&&(h=a.extend(g,b)),a("body").append('<div title="Session Timeout" id="sessionTimeout-dialog">'+h.message+"</div>"),a("#sessionTimeout-dialog").dialog({autoOpen:!1,width:400,modal:!0,closeOnEscape:!1,open:function(){a(".ui-dialog-titlebar-close").hide()},buttons:{"Log Out Now":function(){window.location=h.logoutUrl},"Stay Connected":function(){a(this).dialog("close"),a.ajax({type:"POST",url:h.keepAliveUrl}),d("stop"),c("start")}}}),c("start")}}(jQuery);

$.sessionTimeout({
warnAfter: 3000,
redirAfter: 300000
});

not2easy

5:51 am on Jul 23, 2017 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I use few scripts, not much help on this. There is a free self-directed learning course at w3schools that might help in learning to write your own. There are probably more authoritative sources out there that others could suggest.