1
0
Fork 0
mirror of git://git.psyced.org/git/psyced synced 2024-08-15 03:25:10 +00:00

threads: toggle comments js

This commit is contained in:
Gabor Adam Toth 2010-02-15 13:36:17 +01:00
parent ca4da0725b
commit 249ecc4237
2 changed files with 37 additions and 10 deletions

View file

@ -495,7 +495,10 @@ htMain(last) {
int i;
int len;
string t;
string ht = "";
string ht =
"<script type='text/javascript'>"
"function toggle(e) { e = document.getElementById(e); e.className = e.className.match('hidden') ? e.className.replace(/ *hidden/, '') : e.className + ' hidden'; }"
"</script>";
len = sizeof(_thread);
if (last > len) last = len;
@ -503,21 +506,30 @@ htMain(last) {
// reverse order
for (i = len-1; i >= len - last; i--) {
P3((">>> _thread[%O]: %O\n", i, _thread[i]))
t = htquote(_thread[i]["text"]);
mapping item = _thread[i];
t = htquote(item["text"]);
t = replace(t, "\n", "<br>\n");
t = replace(t, "<", "&lt;");
t = replace(t, ">", "&gt;");
string c = "";
if (item["comments"])
foreach(mapping comment : item["comments"])
c += "<div class='comment'><span class='comment-author'>" + comment["nick"] + "</span>: <span class='comment-text'>" + comment["text"] + "</span></div>\n";
ht += "<div class='entry'>\n"
"<div class='title'>\n"
"<span class='author'>" + _thread[i]["author"] + "</span>\n"
"<span class='subject'>" + htquote(_thread[i]["thread"]) + "</span>\n"
"<span class='author'>" + item["author"] + "</span>\n"
"<span class='subject'>" + htquote(item["thread"]) + "</span>\n"
"</div>\n"
"<div class='body'>\n"
"<div class='text'>" + t + "</div>\n"
"<div id='comments-" + i + "' class='comments hidden'>" + c + "</div>\n"
"</div>\n"
"<div class='footer'>\n"
"<span class='date'>" + _thread[i]["date"] + "</span>\n"
"<span class='comments'>"
"<a href='" + webact + "?comments=" + i + "'>" + sizeof(_thread[i]["comments"]) + " comments</a>"
"<span class='date'>" + item["date"] + "</span>\n"
"<span class='comments-link'>"
"<a onclick=\"toggle('comments-"+i+"')\">" + sizeof(item["comments"]) + " comments</a>"
"</span>\n"
"</div>\n"
"</div>\n";

View file

@ -77,11 +77,21 @@ body.threads,
margin: 22px 44px;
}
.entry .text {
.entry .body {
background: black;
padding: 5px;
}
.entry .body .comment {
margin: 0.5em 1em 0;
padding: 2px;
border-top: 1px solid #933;
}
.entry .body .comment-author {
font-weight: bold;
}
.entry .title {
display: none;
}
@ -90,6 +100,7 @@ body.threads,
.entry .footer a,
.entry .footer a:visited {
cursor: pointer;
color: white;
background: transparent;
}
@ -99,6 +110,10 @@ body.threads,
text-decoration: underline;
}
.entry .footer .comments {
.entry .footer .comments-link {
float: right;
}
.hidden {
display: none;
}