Skip to content

Commit aeec3c3

Browse files
committed
Autorefresh bug fixed
1 parent 34320a6 commit aeec3c3

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Olog/public_html/static/js/rest.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ function prepareParentAndChildren(i, children, prepend) {
455455
var logTemplate = getTemplate("template_log");
456456
var historyTemplate = getTemplate("template_log_history");
457457
var html = "";
458-
var htmlBlock = "";
459458

460459
var item = children[0];
461460

@@ -526,7 +525,7 @@ function prepareParentAndChildren(i, children, prepend) {
526525
$("#load_logs").append(html);
527526

528527
} else {
529-
htmlBlock += html;
528+
$(".log").first().before(html);
530529
}
531530

532531
// Append children
@@ -588,9 +587,16 @@ function repeatLogs(data, prepend){
588587
var children = [];
589588

590589
var logId = "";
590+
var logIndex = 0;
591+
592+
// If we are prepending new data, reverse the order of logs so the will be prepended correctly
593+
if(prepend) {
594+
data.reverse();
595+
}
591596

592597
// Go through all the logs
593598
$.each(data, function(i, item) {
599+
logIndex = i;
594600
savedLogs[item.id + "_" + item.version] = item;
595601
var currentLogId = item.id;
596602

@@ -613,6 +619,12 @@ function repeatLogs(data, prepend){
613619
children.push(item);
614620
logId = currentLogId;
615621
});
622+
623+
// Print the last element (with children)
624+
if(children.length > 0) {
625+
logIndex ++;
626+
prepareParentAndChildren(logIndex, children, prepend);
627+
}
616628
}
617629

618630
/*

0 commit comments

Comments
 (0)