You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
//= require asciinema-player
|
|
|
|
function tryCreatePlayer(parentNode, asciicast, options) {
|
|
function createPlayer() {
|
|
asciinema_player.core.CreatePlayer(
|
|
parentNode,
|
|
asciicast.url,
|
|
{
|
|
width: asciicast.width,
|
|
height: asciicast.height,
|
|
snapshot: asciicast.snapshot,
|
|
speed: options.speed,
|
|
autoPlay: options.autoPlay,
|
|
loop: options.loop,
|
|
startAt: options.startAt,
|
|
fontSize: options.fontSize,
|
|
theme: options.theme,
|
|
title: options.title,
|
|
author: options.author,
|
|
authorURL: options.authorURL,
|
|
authorImgURL: options.authorImgURL
|
|
}
|
|
);
|
|
}
|
|
|
|
function fetch() {
|
|
$.get('/api/asciicasts/' + asciicast.id + '.json', function(data) {
|
|
asciicast = data;
|
|
checkReadiness();
|
|
});
|
|
}
|
|
|
|
function checkReadiness() {
|
|
if (asciicast.url) {
|
|
$('.processing-info').remove();
|
|
createPlayer();
|
|
} else {
|
|
$('.processing-info').show();
|
|
setTimeout(fetch, 2000);
|
|
}
|
|
}
|
|
|
|
checkReadiness();
|
|
}
|