From 2913c04570896eba68e393b077265c744c0fbf05 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sat, 12 Oct 2013 13:24:48 +0200 Subject: [PATCH] Add ability to start playback in widget via postMessage --- app/views/asciicasts/raw.html.slim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/views/asciicasts/raw.html.slim b/app/views/asciicasts/raw.html.slim index c37b094..3d95d6a 100644 --- a/app/views/asciicasts/raw.html.slim +++ b/app/views/asciicasts/raw.html.slim @@ -8,4 +8,13 @@ javascript: var h = $('.player').css('height'); target.postMessage(['asciicast:size', { id: #{@asciicast.id}, width: w, height: h }], '*'); } + + function onMessage(e) { + var event = e.data[0]; + if (event == 'asciicast:play') { + $('.start-prompt').click(); + } + } + + window.addEventListener("message", onMessage, false); });