The version of vichan running on lainchan.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4KB

  1. /*
  2. * youtube
  3. * https://github.com/savetheinternet/Tinyboard/blob/master/js/youtube.js
  4. *
  5. * Don't load the YouTube player unless the video image is clicked.
  6. * This increases performance issues when many videos are embedded on the same page.
  7. * Currently only compatiable with YouTube.
  8. *
  9. * Proof of concept.
  10. *
  11. * Released under the MIT license
  12. * Copyright (c) 2013 Michael Save <savetheinternet@tinyboard.org>
  13. * Copyright (c) 2013-2014 Marcin Łabanowski <marcin@6irc.net>
  14. *
  15. * Usage:
  16. * $config['embedding'] = array();
  17. * $config['embedding'][0] = array(
  18. * '/^https?:\/\/(\w+\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9\-_]{10,11})(&.+)?$/i',
  19. * $config['youtube_js_html']);
  20. * $config['additional_javascript'][] = 'js/jquery.min.js';
  21. * $config['additional_javascript'][] = 'js/youtube.js';
  22. *
  23. */
  24. onready(function(){
  25. var do_embed_yt = function(tag) {
  26. $('div.video-container a', tag).click(function() {
  27. var videoID = $(this.parentNode).data('video');
  28. $(this.parentNode).html('<iframe style="float:left;margin: 10px 20px" type="text/html" '+
  29. 'width="360" height="270" src="//www.youtube.com/embed/' + videoID +
  30. '?autoplay=1&html5=1" allowfullscreen frameborder="0"/>');
  31. return false;
  32. });
  33. };
  34. do_embed_yt(document);
  35. // allow to work with auto-reload.js, etc.
  36. $(document).on('new_post', function(e, post) {
  37. do_embed_yt(post);
  38. });
  39. });