Home Features Demos Download Installation User Manual Developer Manual Relation function Credits

Login

Reload automatically after Overtime

You can add some AJAX to your skin so that it reloads automatically pages after long requests that end up in an overtime event.

Wrap swParsedcontent in a divider

<div id='parsedcontent'>$swParsedContent</div>

Add this code at the end:

if (isset($swOvertime) && $swOvertime && count($_POST) == 0)
{

echo '
<script>
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
s = xmlhttp.responseText;
overtime = s.substr(0,1);
t = s.substr(1);
document.getElementById("parsedcontent").innerHTML=t;
if (overtime=="1")
{
var u = document.URL;
if (u.indexOf("?") == -1) u = u+"?ajax=1"; else u = u+"&ajax=1";
xmlhttp.open("GET",u,true);
xmlhttp.send();
document.title = document.title+"-";
}
else
document.title = document.title+".";
}
}
setTimeout(function()
{
var u = document.URL;
if (u.indexOf("?") == -1) u = u+"?ajax=1"; else u = u+"&ajax=1";
xmlhttp.open("GET",u,true);
xmlhttp.send();
document.title = document.title+"-";
}, 3000)
</script>';
}

And add a conditional output at the beginning

if (isset($_REQUEST['ajax']))
{
if (isset($swOvertime) && $swOvertime)
echo '1';
else
echo '0';
echo $swParsedContent;

return;
}