[thelist] refreshing content like twitter

Nadeem Hosenbokus nadeem at nadeemh.com
Thu Sep 6 16:39:47 CDT 2012


Hi,

If I understand correctly, you want the list of comments to update when a
new comment is posted, i.e. one user adding a new comment triggers the
refresh for any other users viewing the page.

I think you'd need to forego the push method and definitely use a script
that periodically checks for updates.

Where you could optimise this though is how you check for updates.

This is just a suggestion, there may be better ways: when you page loads
store the number of current comments in a Javascript variable. Use an AJAX
function on something like a 30 second timer (how long does it take to write
a comment?) which first checks the number of comments. If the count returned
is greater than the stored count then update the stored count and run a
second AJAX function to refresh the list.

Or you could use dates or IDs: store the last comment date or ID and check
the latest.

The idea is that a simple AJAX call every 30 seconds isn't taxing and you'd
only be running the full comments refresh only when you need to.

If you're using something like Node.js then you might have other options in
terms of triggering when the comments refresh. At the end of the day there
might be other solutions to capture the new comment and push a refresh
through to everyone else but is there a business case in doing that?

For the infinite list, Javascript can capture the scrollbar position
relative to the bottom of the element and then use that to trigger a .load
AJAX call to add more comments to the bottom of the list. You could always
add a fixed number of comments each time and then send the ID of the last
comment when you make the call.

Is there something online to look at? I might be able to help you a bit more
if I could see what you have.

But after all that, I'm sorry I can't point you towards a pre-built script. 

Nadeem Hosenbokus
(230) 766 9169
www.nadeemh.com




-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Bob Meetin
Sent: 05 September 2012 23:29
To: thelist at lists.evolt.org
Subject: [thelist] refreshing content like twitter

I've got some content bits that folks will be regularly adding comments and
such to, very similar to how Twitter works. Registered member adds a
comment. The comment is dynamically posted to the page along, it shows at
the top of the list, and other comments scroll down until it reaches a
limit.

I dabble little enough with AJAX to know how to update a <div>.  I did a
number of searches and found some 'periodic' update scripts, but this will
be more of a whenever. Something like a daemon is watching the queue and
wakes up when new content arrives.


The second complication is scrolling as opposed to simply redrawing.  My
JavaScript skills are weak. Figuring out how to do this in jQuery or
Mootools will be a perilous journey.

Can anyone point me to a pre-built script which will handle the requirements
- 1) update/adds as new content (mysql) arrives and scrolls like Twitter?

Thx, Bob
-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt ! 



More information about the thelist mailing list