diff --git a/js/dom-functions.js b/js/dom-functions.js index 9a19e25..1208baf 100644 --- a/js/dom-functions.js +++ b/js/dom-functions.js @@ -950,14 +950,14 @@ function expand_queet(q,doScrolling) { // if there's only one thumb and it's a youtube video, show it inline if(q.children('.queet').find('.queet-thumbs.thumb-num-1').children('.thumb-container.play-button.youtube').length == 1) { - var youtubeId = q.children('.queet').find('.queet-thumbs.thumb-num-1').children('.thumb-container.play-button.youtube').children('.attachment-thumb').attr('data-full-image-url').replace('http://www.youtube.com/watch?v=','').replace('https://www.youtube.com/watch?v=','').replace('http://youtu.be/','').replace('https://youtu.be/','').substr(0,11); - if(q.children('.queet').find('.expanded-content').children('.media').children('iframe[src="//www.youtube.com/embed/' + youtubeId + '"]').length < 1) { // not if already showed + var youtubeURL = q.children('.queet').find('.queet-thumbs.thumb-num-1').children('.thumb-container.play-button.youtube').children('.attachment-thumb').attr('data-full-image-url'); + if(q.children('.queet').find('.expanded-content').children('.media').children('iframe[src="' + youTubeEmbedLinkFromURL(youtubeURL) + '"]').length < 1) { // not if already showed // hide video thumbnail if it's the only one if(q.children('.queet').find('.queet-thumbs').children('.thumb-container').length < 2) { q.children('.queet').find('.queet-thumbs').addClass('hide-thumbs'); } // show video - q.children('.queet').find('.expanded-content').prepend('
'); + q.children('.queet').find('.expanded-content').prepend('
'); } } @@ -1841,14 +1841,14 @@ function buildQueetHtml(obj, idInStream, extraClassesThisRun, requeeted_by, isCo // play button for videos and animated gifs var playButtonClass = ''; - if(this.url.indexOf('://www.youtube.com') > -1 + if((this.url.indexOf('://www.youtube.com') > -1 || this.url.indexOf('://youtu.be') > -1) || (typeof this.animated != 'undefined' && this.animated === true)) { var playButtonClass = ' play-button'; } // youtube class var youTubeClass = ''; - if(this.url.indexOf('://www.youtube.com') > -1) { + if(this.url.indexOf('://www.youtube.com') > -1 || this.url.indexOf('://youtu.be') > -1) { youTubeClass = ' youtube'; } diff --git a/js/misc-functions.js b/js/misc-functions.js index 4044812..285b8c7 100644 --- a/js/misc-functions.js +++ b/js/misc-functions.js @@ -1645,3 +1645,23 @@ function theUserOrGroupThisStreamBelongsTo(stream) { return stream; } } + +/* · + · + · Youtube embed link from youtube url + · + · · · · · · · · · · · · · */ + +function youTubeEmbedLinkFromURL(url) { + var youtubeId = url.replace('http://www.youtube.com/watch?v=','').replace('https://www.youtube.com/watch?v=','').replace('http://youtu.be/','').replace('https://youtu.be/','').substr(0,11); + + // get start time hash + var l = document.createElement("a"); + l.href = url; + if(l.hash.substring(0,3) == '#t=') { + return '//www.youtube.com/embed/' + youtubeId + '?start=' + l.hash.substring(3); + } + else { + return '//www.youtube.com/embed/' + youtubeId; + } + }