Skip to content

Commit 5f6fec0

Browse files
committedNov 1, 2020
Merge branch 'master' of https://github.com/codershiyar/javascript into master
2 parents 2c7793f + 8837bb1 commit 5f6fec0

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
 

‎Lesson_97/codershiyar_app/app.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=PLMTdZ61eBnyp1nMM8mGRzpwuu6FNxFy0D&maxResults=50&key=AIzaSyAaRjH-yWMxGLPBOvDdqkGjTn84-wqY--o";
2+
fetch(url).then( response => { return response.json()}).then(data =>{
3+
4+
getData(data.items);
5+
6+
}).catch(error =>{
7+
// هنا نضع اوامر الذي نرغب بتنفيذها عند حدوث خطا اثناء استرداد بيانات من API
8+
9+
console.log(error); // هنا طلبنا بعر ض الخطا الذي حدث اثناء استرداد البيانات
10+
})
11+
12+
13+
function getData(data){
14+
console.log(data);
15+
data.forEach(element => {
16+
var title = element.snippet.title;
17+
var videoId = element.snippet.resourceId.videoId;
18+
var img = element.snippet.thumbnails.standard.url;
19+
var description = element.snippet.description;
20+
21+
document.getElementById("content").innerHTML +=
22+
'<div class="card-header shadow p-3 mb-5 bg-white rounded" onclick="loadVideo(\'' +videoId+ '\')"> ' + title+ '</div>'
23+
24+
;
25+
26+
;
27+
});
28+
}
29+
30+
31+
function loadVideo(videoId){
32+
document.getElementById("player").src= "https://www.youtube.com/embed/"+videoId + "?showinfo=0; rel=0;";
33+
34+
35+
}
36+
37+
38+
39+
40+
setInterval(function () {
41+
document.getElementById("player").style.height =
42+
document.getElementById("player").getBoundingClientRect().width * 0.5625 + "px";
43+
44+
},1000);

‎Lesson_97/codershiyar_app/index.html

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html >
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Coder Shiyar APP</title>
7+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
8+
<style>
9+
div{
10+
cursor: pointer;
11+
}
12+
</style>
13+
</head>
14+
<body>
15+
16+
17+
<div class="container" style="max-width: 720px; text-align: center;">
18+
19+
20+
<iframe id="player" width="100%"
21+
src="https://www.youtube.com/embed/Xn9yiZRg4m4"
22+
frameborder="0" allow="accelerometer; autoplay;
23+
encrypted-media; gyroscope; picture-in-picture"
24+
allowfullscreen></iframe>
25+
26+
<main id="content">
27+
28+
</main>
29+
30+
</div>
31+
<script src="app.js"></script>
32+
</body>
33+
</html>

0 commit comments

Comments
 (0)
Failed to load comments.