Jump to content
vBWarez - Rest In Peace

Recommended Posts

Between AJAX partial content refresh, UserID timeout and several DBTech modules with their own timers, the problem of keeping a page up to date is annoying. For moderators and even admins, sitting in the Online Users page is particularly irritating because after so many minutes of monitoring, suddenly they appear to have logged out.
I tried a simple META refresh in the Header and Head_Include template, but that forces a complete page reload. This could result in users losing entire posting before being submitted.
My solution is a very simple script.

Go to the Online Users page.
Go into the Site Editor.
Add a Static HTML module.
Name it.
(Don't show title.)
Add this code to the module.
[CODE] <head>
<meta http-equiv="refresh" content="[COLOR="#00FF00"]365[/COLOR]">
<script type="text/javascript">
// set minutes
var mins = [COLOR="#00FF00"]5[/COLOR];

// calculate the seconds (don't change this! unless time progresses at a different speed for you...)
var secs = mins * 60;
function countdown() {
function Decrement() {
if (document.getElementById) {
minutes = document.getElementById("minutes");
seconds = document.getElementById("seconds");
// if less than a minute remaining
if (seconds < 59) {
seconds.value = secs;
} else {
minutes.value = getminutes();
seconds.value = getseconds();
function getminutes() {
// minutes is seconds divided by 60, rounded down
mins = Math.floor(secs / 60);
return mins;
function getseconds() {
// take mins remaining (as seconds) away from total seconds remaining
return secs-Math.round(mins *60);

<div id="timer">
This page will refresh in <input id="minutes" type="text" style="width: 14px; border: none; background-color:none; font-size: 16px; font-weight: bold;"> minutes and <input id="seconds" type="text" style="width: 26px; border: none; background-color:none; font-size: 16px; font-weight: bold;"> seconds.


Save it.
It will produce a 5 minute count down timer which will refresh only that page (not the entire forum).
The code may be useful in other areas of the forum, but for me, it serves its purpose.


There are two [COLOR="#00FF00"]timers [/COLOR]at work here. The first sets the META refresh while the second creates the readable display.
The META timer is not very accurate. 60 seconds times 5 minutes is 300 count. This works very well in the script which relies upon the internal clock, but the META timer works on its own and a count of 300 is closer to 3 min 55 seconds. 365 count is more accurately 5 minutes.
Keep this in mind if you adjust the timing.
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...