2014-03-02 05:43:20 +00:00
|
|
|
;// Live commit updates
|
|
|
|
|
|
|
|
if(typeof(Drone) === 'undefined') { Drone = {}; }
|
|
|
|
|
|
|
|
(function () {
|
2014-07-12 02:10:18 +00:00
|
|
|
Drone.Console = function() {
|
2014-03-02 05:43:20 +00:00
|
|
|
this.lineFormatter = new Drone.LineFormatter();
|
|
|
|
}
|
|
|
|
|
2014-07-12 02:10:18 +00:00
|
|
|
Drone.Console.prototype = {
|
2014-03-02 05:43:20 +00:00
|
|
|
lineBuffer: "",
|
|
|
|
autoFollow: false,
|
|
|
|
|
2014-07-12 02:10:18 +00:00
|
|
|
start: function(el) {
|
2014-03-02 05:43:20 +00:00
|
|
|
if(typeof(el) === 'string') {
|
|
|
|
this.el = document.getElementById(el);
|
|
|
|
} else {
|
|
|
|
this.el = el;
|
|
|
|
}
|
|
|
|
|
2014-07-12 02:10:18 +00:00
|
|
|
this.update();
|
2014-03-02 07:08:30 +00:00
|
|
|
},
|
|
|
|
|
2014-07-12 02:10:18 +00:00
|
|
|
stop: function() {
|
2014-03-02 07:08:30 +00:00
|
|
|
this.stoppingRefresh = true;
|
2014-03-02 05:43:20 +00:00
|
|
|
},
|
|
|
|
|
2014-07-12 02:10:18 +00:00
|
|
|
update: function() {
|
2014-03-02 05:43:20 +00:00
|
|
|
if(this.lineBuffer.length > 0) {
|
|
|
|
this.el.innerHTML += this.lineBuffer;
|
|
|
|
this.lineBuffer = '';
|
|
|
|
|
|
|
|
if (this.autoFollow) {
|
|
|
|
window.scrollTo(0, document.body.scrollHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-02 07:08:30 +00:00
|
|
|
if(this.stoppingRefresh) {
|
|
|
|
this.stoppingRefresh = false;
|
|
|
|
} else {
|
|
|
|
window.requestAnimationFrame(this.updateScreen.bind(this));
|
|
|
|
}
|
2014-03-02 05:43:20 +00:00
|
|
|
},
|
|
|
|
|
2014-07-12 02:10:18 +00:00
|
|
|
write: function(e) {
|
2014-03-02 05:43:20 +00:00
|
|
|
this.lineBuffer += this.lineFormatter.format(e.data);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Polyfill rAF for older browsers
|
|
|
|
window.requestAnimationFrame = window.requestAnimationFrame ||
|
|
|
|
window.webkitRequestAnimationFrame ||
|
|
|
|
function(callback, element) {
|
|
|
|
return window.setTimeout(function() {
|
|
|
|
callback(+new Date());
|
|
|
|
}, 1000 / 60);
|
|
|
|
};
|
|
|
|
|
2014-03-02 07:08:30 +00:00
|
|
|
window.cancelRequestAnimationFrame = window.cancelRequestAnimationFrame ||
|
|
|
|
window.cancelWebkitRequestAnimationFrame ||
|
|
|
|
function(fn) {
|
|
|
|
window.clearTimeout(fn);
|
|
|
|
};
|
|
|
|
|
2014-03-02 05:43:20 +00:00
|
|
|
})();
|