Browse Source

Revamp the renderer to use terminalizer-player v0.3.0

master
Mohammad Fares 4 years ago
parent
commit
2a749db26d
  1. 6
      render/index.js
  2. 61
      render/src/js/app.js

6
render/index.js

@ -41,7 +41,11 @@ app.on('ready', createWindow);
function createWindow() {
// Create a browser window
var win = new BrowserWindow({show: false, width: 8000, height: 8000});
var win = new BrowserWindow({
show: false,
width: 8000,
height: 8000
});
// Load index.html
win.loadURL('file://' + __dirname + '/index.html');

61
render/src/js/app.js

@ -36,53 +36,66 @@ $(document).ready(function() {
$('#terminal').terminalizer({
recordingFile: 'data.json',
autoplay: true,
controls: false,
controls: false
});
/**
* A callback function for the event:
* When the terminal playing is started
*/
$('#terminal').on('playingStarted', function() {
$('#terminal').one('playingStarted', function() {
var terminalizer = $('#terminal').data('terminalizer');
var framesCount = terminalizer.getFramesCount();
var tasks = [];
// Pause the playing
terminalizer.pause();
for (var i = 0; i < framesCount; i++) {
});
(function(frameIndex) {
/**
* A callback function for the event:
* When the terminal playing is paused
*/
$('#terminal').one('playingPaused', function() {
tasks.push(function(callback) {
var terminalizer = $('#terminal').data('terminalizer');
terminalizer._applySnapshot(terminalizer._snapshots[frameIndex]);
// Reset the terminal
terminalizer._terminal.reset();
// A workaround delay to allow rendering
setTimeout(function() {
capture(frameIndex, callback);
}, 20);
});
// When the terminal's reset is done
$('#terminal').one('rendered', render);
}(i));
});
}
});
async.series(tasks, function(error, result) {
/**
* Render each frame and capture it
*/
function render() {
var terminalizer = $('#terminal').data('terminalizer');
var framesCount = terminalizer.getFramesCount();
// Foreach frame
async.timesSeries(framesCount, function(frameIndex, next) {
terminalizer._renderFrame(frameIndex, true, function() {
capture(frameIndex, next);
})
if (error) {
throw new Error(error);
}
}, function(error) {
currentWindow.close();
});
if (error) {
throw new Error(error);
}
currentWindow.close();
});
});
}
/**
* Capture the current frame

Loading…
Cancel
Save