forked from p2sr/Portal2Boards
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyoutubeEmbed.js
More file actions
33 lines (28 loc) · 1.3 KB
/
Copy pathyoutubeEmbed.js
File metadata and controls
33 lines (28 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function embedOnBody(youtubeID, description) {
$("#youtube").remove();
if (youtubeID.indexOf("?start=") == -1)
youtubeID += "?start=0";
if (description != "") {
description = "<div id='description'>" + description + "</div>";
}
var $yt = $(
"<div id='youtube'>" +
"<div id='descriptionContainer'>" +
description +
"<div id='ytclose'>" +
"<i class='fa fa-lg fa-times' aria-hidden='true'></i> " +
"</div>" +
"</div>" +
"<iframe id='ytplayer' allowfullscreen='allowfullscreen' type='text/html' width='640' height='360' align='middle' referrerpolicy='strict-origin-when-cross-origin' src='https://www.youtube.com/embed/"+youtubeID+"&autoplay=1' frameborder='0'>" +
"</iframe>" +
"</div>");
$("body").append($yt);
$("#ytclose").click(function() {
$("#youtube").remove();
});
}
function embedInDiv($element, youtubeID) {
$("#youtube").remove();
var $yt = $("<iframe id='ytplayer' allowfullscreen='allowfullscreen' type='text/html' width='100%' height='100%' align='middle' referrerpolicy='strict-origin-when-cross-origin' src='https://www.youtube.com/embed/"+youtubeID+"&autoplay=1' frameborder='0'></iframe>");
$element.append($yt);
}