RadioRadio
Wednesday, December 18, 2002
[7:16:38 PM]
Follow-up on chronologically-ordered weblogs.... Here's a example of using client-side javascript and cookies to hide previously-viewed posts [new window].
Why are blogs in reverse order? Partly because we don't want the server to remember which items each viewer has already seen. We also don't want the server to do the work of delivering only unseen items for each user. That would get expensive, compared to Radio, that generates static pages.
The script uses client-side memory and processing power, which is scalable. That is, if a million people hit your weblog, the server doesn't have to do any extra work.
The example assumes the server doesn't help by providing variables like the ids of the first and last items on the page. Slightly cooperative weblog software would reduce the complexity of the Javascript code.
[11:43:34 AM]
Re-ordering weblogs is easy. Give it a separate page. Maybe restrict it to a shorter timespan. Use Javascript and DOM:
1) use Javascript to write a cookie with the id of the last-viewed entry.
2) use Javascript to set "display: none" for the items that have already been read. This will work in fancy new browsers like IE5+, Mozilla, and NS6+. For old and primitive browsers, be sure to include a link to the (current) standard reverse-order page.
3) add a link to display the hidden items.
Not having done this yet, I presume the Javascript won't be entirely straightforward. Ideally, the weblog server software would give you access to variables for the last id, and the ids would have to be numerically ordered. Radio's ids will work.
Of course the server software would have to give you the option. I don't know if any do, but it certainly wouldn't be hard.
Dave Winer provoked this outburst by linking to Ken Hirsch.
Copyright © 2003 Licentious Radio.
Last update: 9/20/03; 2:54:10 PM.