Version: 1.0, by Scandal
Developer Last Online: Nov 2023
Category: Mini Mods -
Version: 4.x.x
Rating:
Released: 10-25-2014
Last Update: Never
Installs: 17
Template Edits
No support by the author.
A template modification for session auto-refresh! :up: What does this mod do?
By default, vbulletin refreshes the session only on a page refresh - move to new page by the user. With this, when a user has not close the browser, it continuous display as ONLINE, on the page the browser is.
Copy and paste the following code at the end of your headinclude template and you're ready!
On the *zip package below you can find also the code for vB3 version.
Credits: to madness85 for him idea and the donation for creating this hack.
HTML Code:
<vb:if condition="$show[member]"><script type="text/javascript">
var sc_sessionrefresh_handleSuccess = function(o)
{
if(o.responseText !== undefined)
{
if (sc_sessionrefresh_callback.object_name[o.tId] !== undefined)
{
fetch_object(sc_sessionrefresh_callback.object_name[o.tId]).innerHTML = o.responseText;
}
}
}
var sc_sessionrefresh_handleFailure = function(o)
{
if(o.responseText !== undefined)
{
alert(o.responseText);
}
}
var sc_sessionrefresh_callback =
{
success: sc_sessionrefresh_handleSuccess,
failure: sc_sessionrefresh_handleFailure,
timeout: vB_Default_Timeout,
cache: false,
object_name: new Array()
}
function sc_sessionrefresh_fetch()
{
var sUrl = document.URL;
var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, sc_sessionrefresh_callback);
return true;
}
setInterval(function () {
sc_sessionrefresh_fetch();
}, {vb:raw vboptions.cookietimeout} * 1000);
</script></vb:if>
I would use this instead and just wrap it around the same conditional:
Change the minutes and seconds highlighted in red to your choice....
Code:
<vb:if condition="$show[member]">
<script type="text/javascript">// <![CDATA[
/*
Auto Refresh Page with Time script
By JavaScript Kit (javascriptkit.com)
Over 200+ free scripts here!
*/
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="00:10"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
curtime=cursec+" seconds left until page refresh!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}
}
function makeDoubleDelegate(function1, function2) {
return function() {
if (function1)
function1();
if (function2)
function2();
}
}
window.onload = makeDoubleDelegate(window.onload, beginrefresh );
// ]]></script>
</vb:if>
I would use this instead and just wrap it around the same conditional:
Change the minutes and seconds highlighted in red to your choice....
Code:
<vb:if condition="$show[member]">
<script type="text/javascript">// <![CDATA[
/*
Auto Refresh Page with Time script
By JavaScript Kit (javascriptkit.com)
Over 200+ free scripts here!
*/
//enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit="00:10"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
curtime=cursec+" seconds left until page refresh!"
window.status=curtime
setTimeout("beginrefresh()",1000)
}
}
function makeDoubleDelegate(function1, function2) {
return function() {
if (function1)
function1();
if (function2)
function2();
}
}
window.onload = makeDoubleDelegate(window.onload, beginrefresh );
// ]]></script>
</vb:if>
This works very well. However the refresh time should be a little high, I have mine set to 15 minutes. This is because if someone is posting a reply or starting a new thread, if the refresh time is very low, the page will be refreshing when the user is trying post, and if the page is refreshed before the post is finished, the user's post will be cleared. Now i have my vB settings to save a draft of the user post before the refresh, so the user just has to click "Restore Auto-Saved Content" at the bottom of the Input Area. I don't know if that is a default setting or not, im not sure. But if its not, you could see how that could become a problem if the refresh time was really low.