[Devel] Mark-as-read via javascript and cookies
Chris Dolan
chris at chrisdolan.net
Wed Dec 15 02:32:01 EST 2004
On Dec 14, 2004, at 8:26 AM, Jeff Waugh wrote:
> <quote who="Chris Dolan">
>
>> Yesterday I noodled with a solution to allow visitors to my Planet
>> mark
>> items as read via javascript.
>
> Sweet baby jebus.
>
> - Jeff (taking some time to digest)
Thanks, Jeff. I'll take that as a compliment. :-)
To forestall some comments, I'll point out an implementation detail and
an associated bug. The javascript stores the marked items in a cookie
in a compact format to avoid the 4K limit on cookie data. This format
is:
top: ID of first story during the last visit
list: comma-separated list of zero-based indices of marked stories
relative to the "top" story
So, on my planet right now the top story is
"http://www.macrumors.com/pages/2004/12/20041214094914.shtml". If I
mark that story as read, and the third, fourth and eighth story down as
well, my cookie will read
top=http://www.macrumors.com/pages/2004/12/20041214094914.shtml
list=0,2-3,7
This relies on the critical assumption that the order of stories always
remains fixed, and that new stories are only added to the top of the
list. That is true for most Planets. However, when you add a new feed
to your Planet, stories may be inserted into the "past" if your
"new_feed_items" config is non-zero. This would lead to the wrong
stories being flagged as read. Therefore, if you employ my
mark-as-read feature into your Planet, I suggest you set
"new_feed_items=0" as a workaround to this issue.
Chris
--
Chris Dolan, Software Developer, www.chrisdolan.net
Public key: http://www.chrisdolan.net/public.key
Planet: http://www.chrisdolan.net/planet/
Arch repository: chris at chrisdolan.net--2004
Arch mirror: http://www.chrisdolan.net/arch/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://lists.waugh.id.au/archives/devel/attachments/20041214/955cb4e3/PGP.pgp
More information about the Devel
mailing list