blob: 4bb54b0fcdf672e2a0a97d5e662b52461be59811 (
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
44
45
46
47
48
49
50
|
// For appending new comments to the thread on page (appendcomments.js)
HashOver.prototype.appendComments = function (comments)
{
// Run through each comment
for (var i = 0, il = comments.length; i < il; i++) {
// Skip existing comments
if (this.permalinks.getComment (comments[i].permalink, this.instance.comments.primary) !== null) {
// Check comment's replies
if (comments[i].replies !== undefined) {
this.appendComments (comments[i].replies);
}
continue;
}
// Check if comment is a reply
var isReply = (comments[i].permalink.indexOf ('r') > -1);
// Add comment to comments array
this.addComments (comments[i], isReply, i);
// Check that comment is not a reply
if (isReply !== true) {
// If so, append to primary comments
var element = this.instance['more-section'];
} else {
// If not, append to its parent's element
var parent = this.permalinks.getParent (comments[i].permalink, true);
var element = this.elements.get (parent, true) || this.instance['more-section'];
}
// Parse comment
var html = this.comments.parse (comments[i], null, true);
// Check if we can insert HTML adjacently
if ('insertAdjacentHTML' in element) {
// If so, just do so
element.insertAdjacentHTML ('beforeend', html);
} else {
// If not, convert HTML to NodeList
var comment = this.HTMLToNodeList (html);
// And append the first node
element.appendChild (comment[0]);
}
// Add controls to the comment
this.addControls (comments[i]);
}
};
|