diff --git a/inc/instance-config.php b/inc/instance-config.php index 63772843..f1522988 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -349,7 +349,7 @@ $config['enable_embedding'] = true; $config['youtube_js_html'] = '
'; $config['embedding'] = array(); diff --git a/js/youtube.js b/js/youtube.js index 9fe81b60..db53f186 100644 --- a/js/youtube.js +++ b/js/youtube.js @@ -25,21 +25,32 @@ onready(function(){ var do_embed_yt = function(tag) { - $('div.video-container a', tag).click(function() { - var videoID = $(this.parentNode).data('video'); - - $(this.parentNode).html(''); + const ON = "[Remove]"; + const OFF = "[Embed]"; - return false; + var videoNode = $('div.video-container', tag); + var videoId = videoNode.data('video'); + var span = $("[Embed]"); + var embedNode = $('') + span.click(function() { + if (span.text() == ON){ + embedNode.remove(); + span.text(OFF); + } else{ + videoNode.append(embedNode); + span.text(ON); + } }); + + videoNode.append(span); }; do_embed_yt(document); - // allow to work with auto-reload.js, etc. - $(document).on('new_post', function(e, post) { - do_embed_yt(post); - }); + // allow to work with auto-reload.js, etc. + $(document).on('new_post', function(e, post) { + do_embed_yt(post); + }); });