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.
asciinema.org/app/assets/javascripts/player.js

46 lines
1.1 KiB
JavaScript

//= require asciinema-player
function tryCreatePlayer(parentNode, asciicast, options) {
function createPlayer() {
asciinema.player.js.CreatePlayer(
parentNode,
asciicast.url,
{
width: asciicast.width,
height: asciicast.height,
poster: options.poster || asciicast.snapshot,
speed: options.speed,
autoPlay: options.autoPlay,
loop: options.loop,
preload: options.preload,
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();
}