-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno_videos_found.js
133 lines (122 loc) · 5.09 KB
/
no_videos_found.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
export const noVideosFound = (gamertag) => {
const first = document.getElementsByClassName("first")[0];
first.style.display = "none";
const splash = document.getElementsByClassName("splash-content")[0];
splash.style.display = "none";
const logo = document.getElementsByClassName("logo")[0];
logo.style.display = "none";
const parent = document.createElement("section")
const button = document.createElement("span");
button.innerHTML = '←';
button.classList.add("back");
parent.appendChild(button);
const container = document.createElement("section");
parent.classList.add("parent-container");
const player = document.createElement("div");
player.innerHTML = `<h2>${ gamertag }</h2>`;
container.appendChild(player);
const message = document.createElement("div");
message.innerHTML = '<p>No videos found for this user</p>';
container.appendChild(message);
parent.appendChild(container);
document.body.appendChild(parent);
button.onclick = function() {
window.location = '/';
}
}
export const videosFound = (gamertag, clips) => {
const first = document.getElementsByClassName("first")[0];
first.style.display = "none";
const splash = document.getElementsByClassName("splash-content")[0];
splash.style.display = "none";
const logo = document.getElementsByClassName("logo")[0];
const parent = document.createElement("section")
const button = document.createElement("span");
button.innerHTML = '←';
button.classList.add("back");
parent.appendChild(button);
const container = document.createElement("section");
parent.classList.add("parent-container");
const player = document.createElement("div");
player.innerHTML = `<h2>${ gamertag }</h2>`;
container.appendChild(player);
const listOfVids = document.createElement("ul");
listOfVids.classList.add("list-of-vids");
for(let i = 0; i < clips.length; i++) {
const ul = document.createElement("ul");
ul.innerHTML = `<h3>${ clips[i].value.event.killer.name }</h3><span>killing ${ clips[i].value.event.victim.name }</span>`;
ul.classList.add(`${ clips[i].value.event.killer.name === gamertag ? "g" : "r" }`, "videoBox", `videoBox${ i }`);
const modal = document.createElement("section");
modal.classList.add("modal", `modal${ i }`);
const div = document.createElement("div");
div.setAttribute("id", `${ i }`);
div.classList.add("vframe2");
const btn = document.createElement("span");
btn.innerHTML = '✖';
btn.classList.add(`close${ i }`, "close");
div.appendChild(btn);
modal.appendChild(div);
ul.appendChild(modal);
listOfVids.appendChild(ul);
}
// const btn = document.createElement("span");
// btn.innerHTML = '✖';
// btn.classList.add("close");
container.appendChild(listOfVids)
parent.appendChild(container);
// parent.appendChild(btn);
document.body.appendChild(parent);
let names = [];
for(let j = 0; j < clips.length; j++) {
names.push("player" + j)
}
for(let i = 0; i < clips.length; i++) {
var options = {
width: 970,
height: 540,
autoplay: false,
time: `${ clips[i].value.timestampInSeconds }`,
video: `${ clips[i].value.vod._id }`,
parent: ["clipd.herokuapp.com"]
};
names[i] = new Twitch.Player(`${ i }`, options);
names[i].setVolume(0.5);
// document.querySelectorAll(".close").forEach(b => {
document.getElementsByClassName(`close${ i }`)[0].addEventListener('click', () => {
names[i].pause();
document.getElementsByClassName(`modal${ i }`)[0].style.display = "none";
document.getElementsByClassName(`close${ i }`)[0].style.display = "none";
// console.log("clicked");
})
// })
}
document.querySelectorAll('.videoBox').forEach((item, idx) => {
const frm = item.querySelector(`.modal${ idx }`);
const btn = document.querySelector(`.close${ idx }`);
// console.log(frm)
item.addEventListener('click', e => {
// debugger
if(e.target === item) {
frm.style.display = "flex";
btn.style.display = "block";
// console.log("clicked box")
}
})
// btn.addEventListener('click', e => {
// debugger
// frm.style.display = "none";
// btn.style.display = "none";
// })
})
// document.querySelectorAll('.close').forEach((x, i) => {
// x.addEventListener('click', e => {
// document.querySelectorAll('.modal').forEach(frm => {
// frm.style.display = "none";
// x.style.display = "none";
// })
// })
// })
button.onclick = function() {
window.location = '/';
}
}