Skip to content

Commit

Permalink
discussion2 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pudge committed Apr 11, 2006
1 parent f068828 commit 742bc67
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
11 changes: 7 additions & 4 deletions Slash/Slash.pm
Expand Up @@ -250,6 +250,7 @@ sub jsSelectComments {
return <<EOT;
comments = $anon_comments;
root_comments = $anon_roots;
user_uid = $user->{uid};
$extra
renderRoots('commentlisting');
EOT
Expand Down Expand Up @@ -1932,8 +1933,8 @@ EOT1
EOT2

my $return = <<EOT;
<li id="$comment->{cid}_tree" class="comment">
<div id="$comment->{cid}_comment"$classattr>
<li id="tree_$comment->{cid}" class="comment">
<div id="comment_$comment->{cid}"$classattr>
<div class="commentTop">
<div class="title">
$head
Expand Down Expand Up @@ -2000,8 +2001,10 @@ EOT

if ($discussion2) {
$return .= <<EOT;
<ul id="$comment->{cid}_group">
<li id="$comment->{cid}_hiddens" class="hide"></li>
<div id="replyto_$comment->{cid}"></div>
<ul id="group_$comment->{cid}">
<li id="hiddens_$comment->{cid}" class="hide"></li>
</ul>
EOT
Expand Down
37 changes: 19 additions & 18 deletions themes/slashcode/htdocs/images/comments.js
Expand Up @@ -18,6 +18,7 @@ var currentdepth = 1;
var pointsums = [];
var viewmodevalue = { full: 3, oneline: 2, hidden: 1};
var prerendered = 0;
var user_uid = 0;

var remainingroots = [];
var allroothiddens = 0;
Expand Down Expand Up @@ -129,7 +130,7 @@ function renderComment(cid, mode) {
}

function updateComment(cid, mode) {
var existingdiv = $(cid + '_comment');
var existingdiv = $('comment_'+cid);
if (existingdiv) {
//existingdiv.innerHTML = renderComment(cid, mode);
existingdiv.className = mode;
Expand All @@ -142,9 +143,9 @@ function updateComment(cid, mode) {
}
}
/* if (displaymode[cid] == 'hidden') {
$(cid + "_tree").className = "hide";
$("tree_" + cid).className = "hide";
} else {
$(cid + "_tree").className = "comment";
$("tree_" + cid).className = "comment";
} */
}
displaymode[cid] = mode;
Expand All @@ -166,12 +167,12 @@ function renderCommentTree(cid) {
var comment = comments[cid];
var retval;
/* if (futuredisplaymode[cid] == 'hidden') {
retval = '<li id="'+cid+'_tree" class="hide">';
retval = '<li id="tree_'+cid+'" class="hide">';
} else { */
retval = '<li id="'+cid+'_tree" class="comment">';
retval = '<li id="tree_'+cid+'" class="comment">';
/* } */
retval = retval + divit(cid + '_comment', renderComment(cid, futuredisplaymode[cid]));
retval = retval + '<ul id="'+cid+'_group">';
retval = retval + divit('comment_'+cid, renderComment(cid, futuredisplaymode[cid]));
retval = retval + '<ul id="group_'+cid+'">';
var hiddens = 0;
if (comment['kids'].length) {
for (var kiddie = 0; kiddie < comment['kids'].length; kiddie++) {
Expand All @@ -185,12 +186,12 @@ function renderCommentTree(cid) {
}

if (futuredisplaymode[cid] == 'hidden') {
retval = retval + '<li id="'+cid+'_hiddens" class="hide"></li>';
retval = retval + '<li id="hiddens_'+cid+'" class="hide"></li>';
hiddens += 1;
} else if (hiddens) {
retval = retval + '<li id="'+cid+'_hiddens">'+hiddens+" reply beneath your current threshhold.</li>";
retval = retval + '<li id="hiddens_'+cid+'">'+hiddens+" reply beneath your current threshhold.</li>";
} else {
retval = retval + '<li id="'+cid+'_hiddens" class="hide"></li>';
retval = retval + '<li id="hiddens_'+cid+'" class="hide"></li>';
}

retval = retval + '</ul>';
Expand All @@ -211,20 +212,20 @@ function updateCommentTree(cid) {
}
}

var cid_hiddens = $(cid+"_hiddens");
if (! cid_hiddens) { // race condition, probably: new comment added in between rendering, and JS data structure
var hiddens_cid = $("hiddens_"+cid);
if (! hiddens_cid) { // race condition, probably: new comment added in between rendering, and JS data structure
return 0;
}

if (displaymode[cid] == 'hidden') {
cid_hiddens.className = "hide";
hiddens_cid.className = "hide";
return kidhiddens + 1 ;

} else if (kidhiddens) {
cid_hiddens.innerHTML = kidhiddens+" comments are hidden.";
cid_hiddens.className = "show";
hiddens_cid.innerHTML = kidhiddens+" comments are hidden.";
hiddens_cid.className = "show";
} else {
cid_hiddens.className = "hide";
hiddens_cid.className = "hide";
}
return 0;
}
Expand Down Expand Up @@ -543,9 +544,9 @@ function setFocusComment(cid) {
focalcids.push(cid);
focalcidshash[cid] = 1;

var comment_y = getOffsetTop($(Math.abs(cid)+"_comment"));
var comment_y = getOffsetTop($("comment_"+Math.abs(cid)));
refreshCommentDisplays();
var newcomment_y = getOffsetTop($(Math.abs(cid)+"_comment"));
var newcomment_y = getOffsetTop($("comment_"+Math.abs(cid)));
if (comment_y != newcomment_y) {
var diff = newcomment_y - comment_y;
scroll(viewWindowLeft(), viewWindowTop() + diff);
Expand Down
8 changes: 4 additions & 4 deletions themes/slashcode/templates/dispComment;misc;default
Expand Up @@ -23,8 +23,8 @@ __name__
dispComment
__template__
[% discussion2 = user.discussion2 && (user.discussion2 == "slashdot" || user.discussion2 == "uofm") %]
<li id="[% cid %]_tree" class="comment">
<div id="[% cid %]_comment"[% IF discussion2 %] class="[% class %]"[% END %]>
<li id="tree_[% cid %]" class="comment">
<div id="comment_[% cid %]"[% IF discussion2 %] class="[% class %]"[% END %]>
<div class="commentTop">
<div class="title">
[% IF discussion2 %]
Expand Down Expand Up @@ -90,8 +90,8 @@ __template__
[% IF discussion2 %]
<div id="replyto_[% cid %]"></div>

<ul id="[% cid %]_group">
<li id="[% cid %]_hiddens" class="hide"></li>
<ul id="group_[% cid %]">
<li id="hiddens_[% cid %]" class="hide"></li>
</ul>
[% END %]

Expand Down

0 comments on commit 742bc67

Please sign in to comment.