diff --git a/js/youtube.js b/js/youtube.js
index db53f186..cd1b0fa9 100644
--- a/js/youtube.js
+++ b/js/youtube.js
@@ -24,16 +24,15 @@
onready(function(){
- var do_embed_yt = function(tag) {
- const ON = "[Remove]";
- const OFF = "[Embed]";
+ const ON = "[Remove]";
+ const OFF = "[Embed]";
- var videoNode = $('div.video-container', tag);
+ function addEmbedButton(index, videoNode) {
var videoId = videoNode.data('video');
var span = $("[Embed]");
var embedNode = $('')
+ '?autoplay=1&html5=1" allowfullscreen frameborder="0"/>');
span.click(function() {
if (span.text() == ON){
embedNode.remove();
@@ -45,12 +44,14 @@ onready(function(){
});
videoNode.append(span);
- };
- do_embed_yt(document);
+ }
+
+ $('div.video-container', document).each(addEmbedButton);
+
// allow to work with auto-reload.js, etc.
$(document).on('new_post', function(e, post) {
- do_embed_yt(post);
+ $('div.video-container', post).each(addEmbedButton);
});
});