2014-06-24 18:34:34 +00:00
|
|
|
//= require asciinema-player
|
2015-05-16 09:50:59 +00:00
|
|
|
|
|
|
|
function tryCreatePlayer(parentNode, asciicast, options) {
|
|
|
|
function createPlayer() {
|
2015-09-19 11:29:26 +00:00
|
|
|
asciinema_player.core.CreatePlayer(
|
2015-05-16 09:50:59 +00:00
|
|
|
parentNode,
|
2015-12-22 17:40:20 +00:00
|
|
|
asciicast.url,
|
2015-05-16 09:50:59 +00:00
|
|
|
{
|
2015-12-26 12:51:52 +00:00
|
|
|
width: asciicast.width,
|
|
|
|
height: asciicast.height,
|
2015-05-16 09:50:59 +00:00
|
|
|
snapshot: asciicast.snapshot,
|
|
|
|
speed: options.speed,
|
|
|
|
autoPlay: options.autoPlay,
|
|
|
|
loop: options.loop,
|
2015-10-13 18:38:37 +00:00
|
|
|
startAt: options.startAt,
|
2015-05-16 09:50:59 +00:00
|
|
|
fontSize: options.fontSize,
|
2015-10-08 09:55:14 +00:00
|
|
|
theme: options.theme,
|
|
|
|
title: options.title,
|
|
|
|
author: options.author,
|
|
|
|
authorURL: options.authorURL,
|
|
|
|
authorImgURL: options.authorImgURL
|
2015-05-16 09:50:59 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function fetch() {
|
|
|
|
$.get('/api/asciicasts/' + asciicast.id + '.json', function(data) {
|
|
|
|
asciicast = data;
|
|
|
|
checkReadiness();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkReadiness() {
|
2016-04-07 07:10:06 +00:00
|
|
|
if (asciicast.url) {
|
2015-05-16 09:50:59 +00:00
|
|
|
$('.processing-info').remove();
|
|
|
|
createPlayer();
|
|
|
|
} else {
|
|
|
|
$('.processing-info').show();
|
|
|
|
setTimeout(fetch, 2000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
checkReadiness();
|
|
|
|
}
|