diff --git a/public/style.css b/public/style.css index ea80321..36214aa 100644 --- a/public/style.css +++ b/public/style.css @@ -115,8 +115,8 @@ summary { .title a p { display: inline; } -.post.distinguished .title a, -.dark .post.distinguished .title a:visited { +.post.distinguished .title a, .post.announcement .title a, +.dark .post.distinguished .title a:visited, .post.announcement .title a:visited { color: #228822; font-weight: bold; } @@ -228,6 +228,13 @@ summary { .dark .meta a { color: #6a98af; } +.comment .meta a.distinguished.admin, .post.distinguished a.admin, .post.announcement a.admin { + background-color: #ff0011; + color: white; + font-weight: bold; + border-radius: 3px; + padding: 0px 2px; +} .meta a:hover { text-decoration: underline; } @@ -472,7 +479,7 @@ form.nsfw div { .expando-button:hover{ background-color: #466599; } -.expando-button.hidden, .children.hidden .comment { +.expando-button.hidden, .children.hidden .comment, .children.hidden .morecomments { display: none; } .hidechildren .show { diff --git a/public/utils.js b/public/utils.js index 3c7a935..ae67624 100644 --- a/public/utils.js +++ b/public/utils.js @@ -91,8 +91,7 @@ function commentClick(e) { } return false } - if ((e.target.className.indexOf("loadmore") != -1) || - (e.target.className.indexOf("edit") != -1) || + if ((e.target.className.indexOf("edit") != -1) || (e.target.className.indexOf("source") != -1) || (e.target.className.indexOf("reply") != -1)) { var id = targ.id @@ -104,6 +103,32 @@ function commentClick(e) { }) return false } + if (e.target.className.indexOf("loadmore") != -1) { + var id = targ.id + if (e.target.getAttribute("for") != id) { return } + e.preventDefault() + var comments = targ.getElementsByClassName("comment") + var skip = [] + for (var i = 0; i < comments.length; i++) { + skip.push(comments[i].id) + } + request(e.target.href+"&xhr",false, function(res){ + var parent = e.target.parentNode + parent.innerHTML = res + parent.innerHTML = parent.getElementsByClassName("children")[0].innerHTML + var comments = parent.getElementsByClassName("comment") + for (var i = 0; i < skip.length; i++) { + for (var c = 0; c < comments.length; c++) { + if (skip[i] == comments[c].id) { + comments[c].remove() + } + } + } + parent.outerHTML = parent.innerHTML + setup() + }) + return false + } } function loadMoreComments(e) { diff --git a/routes.go b/routes.go index 24f5385..1507480 100644 --- a/routes.go +++ b/routes.go @@ -165,6 +165,9 @@ var funcMap = template.FuncMap{ "sub": func(a int32, b int) int { return int(a) - b }, + "add": func(a int32, b int) int { + return int(a) + b + }, } func Initialize(Host string, r *http.Request) (State, error) { diff --git a/state.go b/state.go index a36d295..266eddc 100644 --- a/state.go +++ b/state.go @@ -627,19 +627,19 @@ func (state *State) UploadImage(file multipart.File, header *multipart.FileHeade func getChildren(parent *Comment, pool []types.CommentView, postCreatorID int) { var children []Comment - total := -1 + total := int32(0) for _, c := range pool { levels := strings.Split(c.Comment.Path, ".") for i, l := range levels { id, _ := strconv.Atoi(l) if id == parent.P.Comment.ID { - total = total + 1 if i == (len(levels) - 2) { children = append(children, Comment{ P: c, C: children, State: parent.State, }) + total += c.Counts.ChildCount } } @@ -647,7 +647,8 @@ func getChildren(parent *Comment, pool []types.CommentView, postCreatorID int) { } for i, _ := range children { getChildren(&children[i], pool, postCreatorID) + parent.ChildCount += 1 } parent.C = children - parent.ChildCount = total + parent.P.Counts.ChildCount -= total } diff --git a/templates/comment.html b/templates/comment.html index 87481a1..2a740ea 100644 --- a/templates/comment.html +++ b/templates/comment.html @@ -21,7 +21,7 @@ [-] {{ end }} - {{fullname .P.Creator}} + {{fullname .P.Creator}} {{.P.Counts.Score}} points {{ humanize .P.Comment.Published.Time }} {{- if gt .P.Comment.Updated.Time.Unix .P.Comment.Published.Time.Unix -}} * (last edited {{ humanize .P.Comment.Updated.Time }}) @@ -97,8 +97,8 @@ context {{ end }} -{{ if gt .ChildCount 0 }} -