commento.js: use a more stable sort in comments
This commit is contained in:
parent
7e9b3e5b26
commit
0e54739980
@ -566,7 +566,7 @@
|
|||||||
"score": 0,
|
"score": 0,
|
||||||
"state": "approved",
|
"state": "approved",
|
||||||
"direction": 0,
|
"direction": 0,
|
||||||
"creationDate": (new Date()).toISOString(),
|
"creationDate": new Date(),
|
||||||
}],
|
}],
|
||||||
}, "root")
|
}, "root")
|
||||||
|
|
||||||
@ -658,13 +658,22 @@
|
|||||||
cur.sort(function(a, b) {
|
cur.sort(function(a, b) {
|
||||||
if (a.commentHex === stickyCommentHex) {
|
if (a.commentHex === stickyCommentHex) {
|
||||||
return -Infinity;
|
return -Infinity;
|
||||||
}
|
} else if (b.commentHex === stickyCommentHex) {
|
||||||
if (b.commentHex === stickyCommentHex) {
|
|
||||||
return Infinity;
|
return Infinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (a.score !== b.score) {
|
||||||
return b.score - a.score;
|
return b.score - a.score;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a.creationDate < b.creationDate) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var curTime = (new Date()).getTime();
|
||||||
var cards = create("div");
|
var cards = create("div");
|
||||||
cur.forEach(function(comment) {
|
cur.forEach(function(comment) {
|
||||||
var commenter = commenters[comment.commenterHex];
|
var commenter = commenters[comment.commenterHex];
|
||||||
@ -694,7 +703,6 @@
|
|||||||
} else {
|
} else {
|
||||||
name = create("div");
|
name = create("div");
|
||||||
}
|
}
|
||||||
var date = new Date(comment.creationDate);
|
|
||||||
|
|
||||||
card.id = ID_CARD + comment.commentHex;
|
card.id = ID_CARD + comment.commentHex;
|
||||||
body.id = ID_BODY + comment.commentHex;
|
body.id = ID_BODY + comment.commentHex;
|
||||||
@ -733,12 +741,12 @@
|
|||||||
} else {
|
} else {
|
||||||
sticky.title = "Sticky";
|
sticky.title = "Sticky";
|
||||||
}
|
}
|
||||||
timeago.title = date.toString();
|
timeago.title = comment.creationDate.toString();
|
||||||
|
|
||||||
card.style["borderLeft"] = "2px solid " + color;
|
card.style["borderLeft"] = "2px solid " + color;
|
||||||
name.innerText = commenter.name;
|
name.innerText = commenter.name;
|
||||||
text.innerHTML = comment.html;
|
text.innerHTML = comment.html;
|
||||||
timeago.innerHTML = timeDifference((new Date()).getTime(), date);
|
timeago.innerHTML = timeDifference(curTime, comment.creationDate);
|
||||||
score.innerText = scorify(comment.score);
|
score.innerText = scorify(comment.score);
|
||||||
|
|
||||||
if (commenter.photo === "undefined") {
|
if (commenter.photo === "undefined") {
|
||||||
@ -1089,6 +1097,9 @@
|
|||||||
if (!(parentHex in parentMap)) {
|
if (!(parentHex in parentMap)) {
|
||||||
parentMap[parentHex] = [];
|
parentMap[parentHex] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
comment.creationDate = new Date(comment.creationDate);
|
||||||
|
|
||||||
parentMap[parentHex].push(comment);
|
parentMap[parentHex].push(comment);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user