Make sure player initialization code is available in embed and screenshot bundles

This commit is contained in:
Marcin Kulik 2015-05-16 09:50:59 +00:00
parent a76d99b630
commit 66377b8d7d
3 changed files with 38 additions and 38 deletions

View File

@ -8,7 +8,6 @@
//= require jquery_ujs //= require jquery_ujs
//= require jquery.timeago //= require jquery.timeago
//= require bootstrap //= require bootstrap
//= require asciicasts
$(function() { $(function() {
$('abbr.timeago').timeago(); $('abbr.timeago').timeago();

View File

@ -1,37 +0,0 @@
function tryCreatePlayer(parentNode, asciicast, options) {
function createPlayer() {
asciinema.CreatePlayer(
parentNode,
asciicast.width, asciicast.height,
asciicast.stdout_frames_url,
asciicast.duration,
{
snapshot: asciicast.snapshot,
speed: options.speed,
autoPlay: options.autoPlay,
loop: options.loop,
fontSize: options.fontSize,
theme: options.theme
}
);
}
function fetch() {
$.get('/api/asciicasts/' + asciicast.id + '.json', function(data) {
asciicast = data;
checkReadiness();
});
}
function checkReadiness() {
if (asciicast.stdout_frames_url) {
$('.processing-info').remove();
createPlayer();
} else {
$('.processing-info').show();
setTimeout(fetch, 2000);
}
}
checkReadiness();
}

View File

@ -2,3 +2,41 @@
//= require react-0.10.0 //= require react-0.10.0
//= require asciinema-player //= require asciinema-player
//= require screenfull //= require screenfull
function tryCreatePlayer(parentNode, asciicast, options) {
function createPlayer() {
asciinema.CreatePlayer(
parentNode,
asciicast.width, asciicast.height,
asciicast.stdout_frames_url,
asciicast.duration,
{
snapshot: asciicast.snapshot,
speed: options.speed,
autoPlay: options.autoPlay,
loop: options.loop,
fontSize: options.fontSize,
theme: options.theme
}
);
}
function fetch() {
$.get('/api/asciicasts/' + asciicast.id + '.json', function(data) {
asciicast = data;
checkReadiness();
});
}
function checkReadiness() {
if (asciicast.stdout_frames_url) {
$('.processing-info').remove();
createPlayer();
} else {
$('.processing-info').show();
setTimeout(fetch, 2000);
}
}
checkReadiness();
}