mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-21 07:56:31 +00:00
52 lines
1,001 B
JavaScript
52 lines
1,001 B
JavaScript
|
;// Live commit updates
|
||
|
|
||
|
if(typeof(Drone) === 'undefined') { Drone = {}; }
|
||
|
|
||
|
(function () {
|
||
|
Drone.Buffer = function() {
|
||
|
this.lineFormatter = new Filter({stream: true, newline: false});
|
||
|
}
|
||
|
|
||
|
Drone.Buffer.prototype = {
|
||
|
lineBuffer: "",
|
||
|
autoFollow: false,
|
||
|
stoppingRefresh: false,
|
||
|
|
||
|
start: function(el) {
|
||
|
if(typeof(el) === 'string') {
|
||
|
this.el = document.getElementById(el);
|
||
|
} else {
|
||
|
this.el = el;
|
||
|
}
|
||
|
|
||
|
this.el.innerHTML="";
|
||
|
this.update();
|
||
|
},
|
||
|
|
||
|
stop: function() {
|
||
|
this.stoppingRefresh = true;
|
||
|
},
|
||
|
|
||
|
update: function() {
|
||
|
if(this.lineBuffer.length > 0) {
|
||
|
this.el.innerHTML += this.lineFormatter.toHtml(escapeHTML(this.lineBuffer));
|
||
|
this.lineBuffer = '';
|
||
|
|
||
|
if (this.autoFollow) {
|
||
|
window.scrollTo(0, document.body.scrollHeight);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if(this.stoppingRefresh) {
|
||
|
this.stoppingRefresh = false;
|
||
|
} else {
|
||
|
window.requestAnimationFrame(this.update.bind(this));
|
||
|
}
|
||
|
},
|
||
|
|
||
|
write: function(data) {
|
||
|
this.lineBuffer += data;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
})();
|