-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
72 lines (60 loc) · 2 KB
/
scripts.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function generateEmbed(e) {
e.preventDefault();
e.stopPropagation();
var embedCode = "";
var url = document.querySelector("#videoUrl").value;
var image = document.querySelector("#imageUrl").value;
var controls = document.querySelector("#controls").checked;
var autoplay = document.querySelector("#autoplay").checked;
var muted = document.querySelector("#muted").checked;
var loop = document.querySelector("#loop").checked;
var square = document.querySelector("#square").checked;
var padding = '56.25%';
if (square) {
padding = "100%";
}
var embedCodeEl = document.querySelector("#embedCode");
if (!url.length) {
embedCode = "you dummy. you need a video url first.";
} else {
embedCode +=
"<div class='banner-video-wrapper' style='padding-top: "+ padding +"; position: relative; overflow: hidden'>";
embedCode +=
"<video style='display: block; position: absolute; height: 100%; width: 100%; left: 0px; top: 0px;' id='video' playsinline ";
if (controls) {
embedCode += "controls ";
}
if (autoplay) {
embedCode += "autoplay ";
}
if (muted) {
embedCode += "muted ";
}
if (loop) {
embedCode += "loop ";
}
if (image.length) {
embedCode += "poster='" + image + "' ";
}
embedCode += "src='" + url + "'></video></div>";
}
embedCodeEl.value = embedCode;
}
function gifMode(e) {
e.preventDefault();
e.stopPropagation();
if (document.querySelector("#gif").checked) {
document.querySelector("#autoplay").checked = true;
document.querySelector("#muted").checked = true;
document.querySelector("#loop").checked = true;
document.querySelector("#controls").checked = false;
} else {
document.querySelector("#autoplay").checked = false;
document.querySelector("#muted").checked = false;
document.querySelector("#loop").checked = false;
}
document.querySelector("#embedCode").value = "";
}
function clearEmbedCode() {
document.querySelector('#embedCode').value = '';
}