4 ms·
Interesting. Looking at the source I see that you calculate and store an md5 hash for each comment: var commentContentMd5 = md5($this.find('table td:eq(2)
by bambax 16y ago
Interesting.
Looking at the source I see that you calculate and store an md5 hash for each comment:
var commentContentMd5 = md5($this.find('table td:eq(2) span.comment').text());
However each comment on HN has a unique id, that can be found on the links of the up and down keys:
<a id="up_1943152" href="vote?for=1943152&...
Wouldn't it be easier (and maybe faster) to use these ids to identify comments?
- jules 16y agoThe hash approach has the advantage of marking edited comments as unread? Perhaps you could do both and mark edited comments with a different color.
- CWIZO 16y agoThat is how it was done in the v1.0, but once you vote on a comment that id is gone. Or maybe I missed something :) Will have a look if I can use the IDs instead. edit: bonus "feature" of md5-ing the comments is, that if a comment changes it is marked as unread again ...
- bambax 16y ago> but once you vote on a comment that id is gone The score is in a span that has the same id: <span id="score_1944875">3 points</span> > if a comment changes it is marked as unread again But identical comments in different conversations are marked as read... ;-)
- CWIZO 16y agoI guess I really did miss something then :) HN's markup is really a mess ... >But identical comments in different conversations are marked as read... ;-) true, but that seems highly unlikely here on HN, where you don't have comments like "lol :)" everywhere.
- raganwald 16y agoIf one person writes LOL and another repeats it, I consider it a feature that the second one is also marked as read. YMMV ;-)
- kgermino 16y agoTwo thoughts: 1) If you've already read a comment you've already read it regardless of where you read it, and if the comments are exactly the same they are probably not terribly context sensitive. 2) I believe that if a submitted comment is exactly the same as one in memory than it is auto-killed so in general this is a moot point anyway.
- pmjordan 16y agoUnless I've missed something, the ID can be found in the 'link' link URL for that comment.