Member Avatar for iamthwee

Just wondering how you did the activity stream, is it something you bolted on or is it part of CI?

Also does it take up a lot of resources?

Recommended Answers

All 16 Replies

I do it a really crappy way and I actually need to redo it very soon.

It's just simple ajax with jQuery ... every 5 seconds, it fetches an updated list from the server and overwrites the HTML. The better way to do it is fetch the changes since the last 5 seconds as JSON and only make the necessary adjustments. This way we don't have the bandwidth overhead of the entire list every time. It takes up the same amount of resources as fetching a pageview every 5 seconds.

Now to steal the jQuery from the webpage:

<script type="text/javascript">
<!--
function refresh()
{
    $.post('/stats/js_refresh_online', { csrf_token: csrf_hash }, function(data) {
        $('#online-list').html(data);
    }); 
}

$(function() {
    var timer = setInterval(refresh, 1000);
});
//-->
</script>

Oh, looks like it's every single second.

You've motivated me to make changes to our activity stream page tonight. :) Thanks for that!

Member Avatar for iamthwee

haha good luck. Thanks for sharing.

What, no comment on the changes? :)

Why is it now looping information?

What, no comment on the changes? :)

It's jacked up to the point of being useless now. :( The times are all jumbled rather than in order, and it's difficult to tell what's current. Also, the update is too fast to properly investigate what's happening in realtime.

commented: Was thinking the same +0

I thought this was about the activity stream on the main page. I figured now this is about the member stats page.

Yes, its very difficult to follow now.

Darn you people! I really loved it looping the data, and always having somethign new to show. But no one else liked it, so I've reverted it :(

Looping? what looping, the only looping was my eyes trying to keep up with the information on the screen.

Looping as in if there was no new information to display, it looped back to 10 minutes ago and replayed the last 10 minutes.

Interesting. Just watched the activity stream after browsing Web Dev forum and saw this:

83b6baec534f037182a67d9efc276230

I wonder how it determined I was reading that thread, while instead I was watching the activity stream and coming from a different forum altogether...

Tried visiting a PHP thread and going back to the activity stream, yet still that same link kept showing ;)

Are you going to try and tell me you didn't read that thread at all?

Correct. At least before it was showing. After I took a screenshot I looked.

That's incredibly, incredibly odd!! If it happens again please let me know ... the only thing I can think of is that you clicked into it and out of it in a different browser window or something and forgot, I don't know. I really have no idea how the system could just make it up.

the only thing I can think of is that you clicked into it and out of it in a different browser window or something and forgot

I didn't. I have no explanation either.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.