Post by gitbro » Thu Mar 02, 2023 8:42 pm

For anyone thats added this mod to there website and want auto refresh.. try the code below iv added it to my site seems to work ok.

Got this code off a website i didnt make it myself just added the if logged.

Add it to catalog/view/theme/default/template/common/header.twig just before </header>

Remember to set the timer in (var IDLE_TIMEOUT = 3600;) // <---- set your timer in seconds 3600 is 10 mins, set it lower to test like 30 seconds.

Code: Select all

 {% if logged %}
 <script type="text/javascript">
 var IDLE_TIMEOUT = 3600; //seconds
 var _idleSecondsCounter = 0;
 document.onclick = function () {
 _idleSecondsCounter = 0;
 };

 document.onmousemove = function () {
 _idleSecondsCounter = 0;
 };

 document.onkeypress = function () {
 _idleSecondsCounter = 0;
 };

 window.setInterval(CheckIdleTime, 1000);

 function CheckIdleTime() {
 _idleSecondsCounter++;
 var oPanel = document.getElementById("SecondsUntilExpire");
 if (oPanel)
 oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
 if (_idleSecondsCounter >= IDLE_TIMEOUT) {
 
 document.location.reload();
 
}

}
</script>
{% endif %}

New member

Posts

Joined
Sat Oct 31, 2015 6:58 am
Who is online

Users browsing this forum: No registered users and 50 guests