asciinema.org/app/assets/javascripts/player.js

45 lines
1.0 KiB
JavaScript
Raw Normal View History

2014-06-24 18:34:34 +00:00
//= require asciinema-player
function tryCreatePlayer(parentNode, asciicast, options) {
function createPlayer() {
2015-09-19 11:29:26 +00:00
asciinema_player.core.CreatePlayer(
parentNode,
2015-12-22 17:40:20 +00:00
asciicast.url,
{
2015-12-26 12:51:52 +00:00
width: asciicast.width,
height: asciicast.height,
snapshot: asciicast.snapshot,
speed: options.speed,
autoPlay: options.autoPlay,
loop: options.loop,
2015-10-13 18:38:37 +00:00
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() {
2016-04-07 07:10:06 +00:00
if (asciicast.url) {
$('.processing-info').remove();
createPlayer();
} else {
$('.processing-info').show();
setTimeout(fetch, 2000);
}
}
checkReadiness();
}