vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=246)
-   -   Mini Mods - Session Auto-Refresh (if user has not close the browser: show as online!) (https://vborg.vbsupport.ru/showthread.php?t=315057)

Scandal 10-25-2014 10:00 PM

Session Auto-Refresh (if user has not close the browser: show as online!)
 
1 Attachment(s)
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>


Justinphx 10-26-2014 12:56 PM

Looks good. I just added the script. Thanks.

KHALIK 11-01-2014 08:49 PM

Installed.


EDIT.

It doesn't seem to be working


:(

ahobilam 11-16-2014 12:29 PM

How to conform as it is working?!

tme_power 11-27-2014 08:50 PM

It still stay the same for me.

CAG CheechDogg 11-27-2014 09:07 PM

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>


zorcocuq 12-29-2014 09:06 PM

Thanks Scandal. Looks good.

thetechgenius 01-09-2015 07:43 PM

Quote:

Originally Posted by CAG CheechDogg (Post 2524551)
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.

madness85 01-13-2015 05:08 PM

you must have your Session Timeout higher than in the code above for it to work {vb:raw vboptions.cookietimeout} * 1000); mine is set to 1800

@CAG CheechDogg nice script but that actually refreshes the page :(


All times are GMT. The time now is 12:53 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01140 seconds
  • Memory Usage 1,742KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete