We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Great News, Code to refresh newsfeed! | Forum

tammy harris
tammy harris Jun 17 '14
try something like this i dont have time right now to play with it 
use inspect element to find the div id for newsfeed 
but it would need code to stop the refresh if using keyboard so not refresh while trying to type
from 
http://www.webdeveloper.com/...lt-DIV-gt-using-ajax
Step 1:
Copy the following code and paste it in the head section of your webpage.

<script src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script>
var auto_refresh = setInterval(
function()
{
$('#loaddiv').fadeOut('slow').load('reload.php').fadeIn("slow");
}, 20000);
</script>

Here , above the file “reload.php” will be reloaded in every 20000ms ie 20 second . You can change the file which you have to reload and you can also change the reload time as per your requirement.
and secondly , the #loaddiv is the name of DIV which is going to be refreshed.

Step 2:
and now you need to put the div in the body section of your page

<div id="loaddiv"></div>
tammy harris
tammy harris Jun 17 '14
also these may be good to try
http://osazeworld.wordpress.com/...-a-page-from-server/

http://wowjava.wordpress.com/2010/02/06/auto-refreshing-the-content-without-reloading-page-using-jquery/

integrating a better comments system like this would be cool 
http://www.commentics.org/

Pedro Machado
Pedro Machado Jul 11 '14
The problem is what should be called instead 'reload.php'.


Newsfeed is loaded in div feed1, but i don't know how load only it.


I tried find the solution, but I don't had sucess.

Carol Schumacher
Carol Schumacher Sep 6 '14

Will someone contact me when a newfeed refresh can be used here.  I have a site that has live events and we all have to refresh manually to see the next ones post in a group.   I want it to work like chat does so those of us that forget to refresh don't miss anything.  Please let me know?

 

Pete
Pete Jan 3 '15
Maybe we could edit the code also to  run cron  from inside the admin  that would be good
Marcel
Marcel Jan 3 '15
Here refresh the all page? not only newsfeed?
Marcel
Marcel Jan 3 '15

This woks fine:


<script src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
<script>var auto_refresh = setInterval(
function()
{
$('#feed1').fadeOut('slow').load('reload.php').fadeIn("slow");
}, 20000);
</script>

Marcel
Marcel Jan 3 '15

Hi   S.Williams



I have now:


<script>var auto_refresh = setInterval(
function()
{
$('#feed1').fadeOut('slow').load(location.href="/index").fadeIn("slow");
}, 20000);
</script>


But newsfeeds reload first 1 sec after the whole index page.


When i have:


<script>var auto_refresh = setInterval(
function()
{
$('#feed1').fadeOut('slow').load('reload.php').fadeIn("slow");
}, 20000);
</script>


Then reload only the newsfeed.




Marcel
Marcel Jan 3 '15
I have My Diary theme maby thats the problem here
Marcel
Marcel Jan 3 '15
Yes i have this code in the Custom text/HTML widget .
Marcel
Marcel Jan 3 '15

I have this in the HTML widget:


<script>var time = new Date().getTime();

var refreshTime = 20*1000;

$(document).bind("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error hover change", function(e) {

time = new Date().getTime(); });

function refresh()

{

if(new Date().getTime() - time >= refreshTime)

$('#feed1').fadeOut('slow').load('reload.php').fadeIn("slow");

else

setTimeout(refresh, refreshTime);

}

setTimeout(refresh, refreshTime);

</script>



That works when i ('reload.php') replace with (location.href="/index") then refresh the whole index page


Maby my theme?

Marcel
Marcel Jan 3 '15

That works (location.href+"/dashboard, #feed1") now.


Marcel
Marcel Jan 5 '15

Hi


This script workt fine here thanks


Marcel

JoshWho
JoshWho Jan 6 '15
so what is the correct script to make this work?
JoshWho
JoshWho Jan 6 '15
when i put 


<script>
var time = new Date().getTime();

var refreshTime = 20*1000;

$(document).bind("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error hover change", function(e) {
    time = new Date().getTime(); 
});

var previousScrollPos = localStorage.getItem("lastScrollPos");
if(previousScrollPos)
{
    $('#feed1').scrollTop(previousScrollPos);
    localStorage.removeItem("lastScrollPos");
}

function refresh() {

    if(new Date().getTime() - time >= refreshTime)
    {
        localStorage.setItem("lastScrollPos", $('#feed1').scrollTop());
        location.reload();
    }

}

setInterval(refresh, refreshTime);
</script>



in a custom widget and placed it under my news feed it just refreshes the whole page

Marcel
Marcel Jan 6 '15
 totally agree  S.Williams
Mohammad
Mohammad Jan 7 '15
Guys,

I did not read all your posts, but AFAIK The newsfeed feature you want is a hard and risky task to complete.(if it wasn't there would be plugin in store until now !)it's not possible only with client side changes, or if you could get this done,It will not function properly(as u pictured it)

there are just lots of details

Don't waste your time at this since not worth it

MarkieMark67
MarkieMark67 Jan 28 '15
After reading everyone ones responses at this time this is still the best option..


<script>

    var time = new Date().getTime();

    var refreshTime = 6*1000;


    $(document).bind("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error hover change", function(e) {

    time = new Date().getTime(); });


    function refresh()

    {

       if(new Date().getTime() - time >= refreshTime)

           window.location.reload(true);

       else

    setTimeout(refresh, refreshTime);    

      }

  

     setTimeout(refresh, refreshTime);


</script>  

JoshWho
JoshWho Jan 30 '15
does that refresh the newsfeed only?
Umair
Umair Apr 28 '15
Did anybody get the refresh newsfeed only code?
Pages: « 1 2 3 »