Slashdot - comment tree

By Valentin Laube Last update Aug 20, 2009 — Installed 5,352 times.

Archived Comments (locked)

in
Subscribe to Archived Comments 25 posts, 16 voices



Jesse Andrews Admin

The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008)

 
djdutcher User

Slashdot's last change broke this script, and I can't read slashdot without it anymore. I tried to fix it, but I guess I don't have the CSS skills. They changed the class on the comment div from "commentTop" to "commentTop newcomment", so if I add that to the XPath it seems to add the new div in the right spot, but its not visible for some reason.

 
Vijay User

I love this script but Slashdot has broken it again, can somone fix it please?

 
Robert Litzke Scriptwright

Smooth, excellent script

 
Valentin Laube Script's Author

*fixed again* thank god they moved the scores to the left

 
Valentin Laube Script's Author

minor update: less flickering when collapsing up

 
Valentin Laube Script's Author

*Updated* works better with the new layout and has this nice slide effect like the buttons in the sidebar

 
Valentin Laube Script's Author

another quick update:
- major cleanup (less xpath, more css)
- added another icon to the bottom of the comment like Mark suggested

 
Valentin Laube Script's Author

Sorry for the delay. I postet an updated version which includes Matthews patch and some nice icons.

 
Matthew Carroll User

Looks like Slashdot has changed again, actually in a way that removed the need for the final added div hack in the original script. Fixed version and diff here:

http://carroll.org.uk/sandbox/slashdotcommenttree/

...please integrate, It would be nicer not to fork since this page is widely linked to.

 
Justin Goldberg User

This is very nice. I just wish I could quickly expand and collapse the "XXX replies beneath your current threshold" ignominy.

 
GomerPylediver Scriptwright

This seems to work fine. Minor gripe though: If you were to add font-family:monospace to the div.sct_icon class, the comment titles would not shift position when the comment trees are expanded and collapsed.

 
Brian Pilnick Scriptwright

can someone compile these last additions into a script? Thanks.

 
WayneD User

On second thought, a better fix is to just move the code that tweaks the value of titlenode out of collapseComment() into the "else" section of toggleState().

 
WayneD User

Mark's modified script adds a [^] button at the bottom of the comment, but when you click it, that button turns into a [+] and the [-] at the top stays unchanged. I fixed this by making the collapseComment() function end with "return titlenode;", and then I modified the toggleState() function to call setCollapsedStyle(collapseComment(titlenode)); when it is collapsing a comment (it currently calls each of those functions separately with "titlenode" as the arg).

 
mee User

http://www.langenhoven.com.nyud.net:8090/code/s...

 
Mark 1 Scriptwright

If anybody is interested, I have expanded this script to include a [^] link at the bottom of each comment which will collapse that comment in the same way as the [-] currently does.

This just saves you from scrolling up after a long comment.

Here is a link to my version:
http://www.langenhoven.com/code/slashdotcomment...

 
Mark 1 Scriptwright

Would it be possible to move the [+] collapse sign to the bottom of the comment instead of the top? (Or add a second one.)

That way if there is a really long comment and I scroll down to read it then I don't have to scroll up again to collapse it.

 
an mo User

would it be possible to collapse multiple comment pages into one? Thanks for the script.

 
Chris Born User

With ankut's collapse loop it doesn't set the style for comments so they all come out with [-]

Add:
setCollapsedStyle(results.snapshotItem(i).childNodes[1].childNodes[1])

after the CollapseComment call.

X1011 this is what I did to get a little space between comments

addGlobalStyle(".sct_bodypadding{ padding-bottom:3px; }");

var results = document.evaluate(xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

for(var i = 0; i < results.snapshotLength; i++) {
var node = results.snapshotItem(i);
var pad = document.createElement("div");
pad.className = "sct_bodypadding";
node.insertBefore(pad, node.firstChild); }

Add that after ankut's collapse routine.

Really appreciated the original version of this and hope that this one will have the options box soon.

 
ankut Scriptwright

oh boy... hahah... one more time?

var xpath="//li[@class='comment']";
var results=document.evaluate(xpath,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
for(var i=0; i<results>
collapseComment(results.snapshotItem(i).childNodes[1].childNodes[1]);
}

 
ankut Scriptwright

var xpath="//li[@class='comment']";
var results=document.evaluate(xpath,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
for(var i=0; i<results>
collapseComment(results.snapshotItem(i).childNodes[1].childNodes[1]);
}

 
ankut Scriptwright

Well, if anyone wants the "all closed" state,
here's the edit to make it do that... this code goes all the way at the end of the script:
////////////////////////////////////////////////
var xpath="//li[@class='comment']";
var results=document.evaluate(xpath,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
for(var i=0; i<results>
collapseComment(results.snapshotItem(i).childNodes[1].childNodes[1]);
}
/////////////////////////////////////////
And to set the correct closed icon, change the addIcon function:

function addIcon(titlenode) {
...
document.createTextNode("[+]");
...
}

 
ankut Scriptwright

It would be nice if the comments started out closed?

 
X1011 Scriptwright

I've been waiting for this to be redone. The only problem is there's no space between collapsed comments so they run into each other.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel