From 66377b8d7d6cf18ad950c25c534e4e6dfaadafa6 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sat, 16 May 2015 09:50:59 +0000 Subject: [PATCH] Make sure player initialization code is available in embed and screenshot bundles --- app/assets/javascripts/application.js | 1 - app/assets/javascripts/asciicasts.js | 37 -------------------------- app/assets/javascripts/player.js | 38 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 38 deletions(-) delete mode 100644 app/assets/javascripts/asciicasts.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 1abe5c7..f94967c 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -8,7 +8,6 @@ //= require jquery_ujs //= require jquery.timeago //= require bootstrap -//= require asciicasts $(function() { $('abbr.timeago').timeago(); diff --git a/app/assets/javascripts/asciicasts.js b/app/assets/javascripts/asciicasts.js deleted file mode 100644 index d8d94a2..0000000 --- a/app/assets/javascripts/asciicasts.js +++ /dev/null @@ -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(); -} diff --git a/app/assets/javascripts/player.js b/app/assets/javascripts/player.js index cbcd7ad..bda2ea1 100644 --- a/app/assets/javascripts/player.js +++ b/app/assets/javascripts/player.js @@ -2,3 +2,41 @@ //= require react-0.10.0 //= require asciinema-player //= 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(); +}