-
Notifications
You must be signed in to change notification settings - Fork 0
/
video.html
97 lines (83 loc) · 3.31 KB
/
video.html
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
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - A Pen by Atla Developers</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<!-- <link rel='stylesheet' href='https://vjs.zencdn.net/5-unsafe/video-js.css'><link rel="stylesheet" href="./style.css"> -->
<script src="./api.js"></script>
<link rel="stylesheet" href="./video.css">
</head>
<body>
<!-- partial:index.partial.html -->
<div class="container" id="container">
<div class="mainHeader anim">Video Statistics</div>
<br>
<div class="row">
<div class="column">
<h3>Title : <span id="title"></span></h1>
<h3>Channel : <span id="channel"></span></h3>
<h3>Published Date : <span id="pd"></span></h3>
</div>
<div class="column" id="vPlayer"></div>
</div>
<div class="table">
<table class="tableContainer">
<thead>
<tr>
<th><h1>Date</h1></th>
<th><h1>Time</h1></th>
<th><h1>Views</h1></th>
<th><h1>Likes</h1></th>
<th><h1>Comments</h1></th>
</tr>
</thead>
<tbody id="tableBody">
</tbody>
</table>
</div>
</div>
<!-- partial -->
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://vjs.zencdn.net/5-unsafe/video.js'></script><script src="./script.js"></script>
</body>
</html>
<script>
var url_string =window.location.href;
var urls = new URL(url_string);
var id = urls.searchParams.get("id");
var title = urls.searchParams.get("t");
var channel = urls.searchParams.get("c");
var date = urls.searchParams.get("d");
var div = document.getElementById('vPlayer');
var table = document.getElementById('tableBody');
document.getElementById('title').innerHTML = title;
document.getElementById('channel').innerHTML = channel;
document.getElementById('pd').innerHTML = new Date(date);
document.getElementById('title').innerHTML = title;
getVideoStats(id).then(res => {
// console.log(res)
for(let i=0 ; i<res.length;i++){
const currentDate = new Date(res[i].date);
const currentDayOfMonth = currentDate.getDate();
const currentMonth = currentDate.getMonth(); // Be careful! January is 0, not 1
const currentYear = currentDate.getFullYear();
const dateString = currentDayOfMonth + "/" + (currentMonth + 1) + "/" + currentYear;
// "27-11-2020"
// console.log(res[i].date)
// console.log(res[i].date.substring(0,10))
var row = `
<tr>
<td>${res[i].date}</td>
<td>${res[i].statTime}</td>
<td>${res[i].views}</td>
<td>${res[i].likes}</td>
<td>${res[i].comments}</td>
</tr>
`;
table.innerHTML += row;
}
});
var video = `<iframe width="560" height="315" src="https://www.youtube.com/embed/${id}?&theme=dark&autohide=1&modestbranding=1&fs=0&showinfo=0"><iframe></iframe>`;
div.innerHTML +=video;
</script>