Version 21.58: Nov 21, 2021 Code refactoring in timeline.

This commit is contained in:
acanas 2021-11-21 01:36:36 +01:00
parent 733ae0e86d
commit 9d46cff420
1 changed files with 4 additions and 22 deletions

View File

@ -938,28 +938,10 @@ function readNewTimelineData () {
// ...to the top of UL 'new_timeline_list')
var newTimeline = document.getElementById('new_timeline_list'); // Access to UL with the new timeline
for (var i=1; i<=numNotesJustGot; i++) {
// Check if the last child (the oldest) in just now timeline...
// ...is the last ocurrence of the note
var mostRecentOcurrenceOfNote = true;
var lastChildIndex = numNotesJustGot - i;
var noteCode = justNowTimeline.lastChild.dataset.noteCode;
for (var j=0; j<lastChildIndex; j++)
if (justNowTimeline.childNodes[j].dataset.noteCode == noteCode) {
mostRecentOcurrenceOfNote = false;
break;
}
// Move or remove node from new timeline
if (mostRecentOcurrenceOfNote) {
// Move node from just now timeline to new timeline
newTimeline.insertBefore(justNowTimeline.lastChild, newTimeline.firstChild);
newTimeline.firstChild.className += " Tml_NEW_PUB";
}
else
// Remove last child (because is repeated in more recent pubs)
justNowTimeline.removeChild(justNowTimeline.lastChild);
for (var i=0; i<numNotesJustGot; i++) {
// Move node from just now timeline to new timeline
newTimeline.insertBefore(justNowTimeline.lastChild, newTimeline.firstChild);
newTimeline.firstChild.className += " Tml_NEW_PUB";
}
// Update number of new posts