blob: 292d41fbe97adf1a9128b8ceaa35b88ba218c318 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// For adding new comments to comments array (addcomments.js)
HashOver.prototype.addComments = function (comment, isReply, index)
{
isReply = isReply || false;
index = index || null;
// Check that comment is not a reply
if (isReply !== true) {
// If so, add to primary comments
if (index !== null) {
this.instance.comments.primary.splice (index, 0, comment);
return;
}
this.instance.comments.primary.push (comment);
return;
}
// If not, fetch parent comment
var parentPermalink = this.permalinks.getParent (comment.permalink);
var parent = this.permalinks.getComment (parentPermalink, this.instance.comments.primary);
// Check if the parent comment exists
if (parent !== null) {
// If so, check if comment has replies
if (parent.replies !== undefined) {
// If so, add comment to reply array
if (index !== null) {
parent.replies.splice (index, 0, comment);
return;
}
parent.replies.push (comment);
return;
}
// If not, create reply array
parent.replies = [ comment ];
}
// Otherwise, add to primary comments
this.instance.comments.primary.push (comment);
};
|