forked from gdisf/teaching-materials
-
Notifications
You must be signed in to change notification settings - Fork 5
/
htmlapis_solution.html
103 lines (87 loc) · 2.97 KB
/
htmlapis_solution.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
98
99
100
101
102
103
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Video Watcher</title>
<link rel="stylesheet" type="text/css" href="http://teaching-materials.org/ajax/lib/bootstrap.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="span12">
<h2 class="page-header">Best Videos Ever ❤</h1>
</div>
</div>
<div class="row">
<div class="span3">
<ul id="videos-list">
</ul>
</div>
<div class="span9" id="video-watcher">
</div>
</div>
<div style="text-align:center; margin-top: 30px; clear:both;">
<a href="http://info.flagcounter.com/nEFy"><img src="http://s04.flagcounter.com/count/nEFy/bg_FFFFFF/txt_000000/border_CCCCCC/columns_2/maxflags_12/viewers_0/labels_0/pageviews_0/flags_0/" alt="Flag Counter" border="0"></a>
</div>
</div>
<script type="text/javascript" src="http://teaching-materials.org/ajax/lib/youtube.js"></script>
<script type="text/javascript" src="http://teaching-materials.org/ajax/lib/jquery.min.js"></script>
<script>
function addVideoToList(video) {
var videoLink = $('<a>');
videoLink.append(video.title);
var linkUrl = videoLink.attr('href');
var thumbnailUrl = youtube.generateThumbnailUrl(video.youtubeId);
var thumbnailImg = $('<img>');
thumbnailImg.attr('src', thumbnailUrl);
videoLink.append(thumbnailImg);
videoLink.on('click', function(e) {
e.preventDefault();
var videoTitle = $('<h2>');
videoTitle.html(video.title + ' <small>' + video.author + '</small>');
var videoEmbed = $('<iframe></iframe>');
videoEmbed.attr('src', youtube.generateEmbedUrl(video.youtubeId) + '?autoplay=1');
videoEmbed.attr('width', 560);
videoEmbed.attr('height', 315);
var videoRating = $('<img></img>');
videoRating.attr('src', 'https://chart.googleapis.com/chart?chs=225x125&cht=gom&chd=t:' + video.rating);
var videoWatcher = $('#video-watcher');
videoWatcher.hide();
videoWatcher.empty();
videoWatcher.append(videoTitle);
videoWatcher.append(videoEmbed);
videoWatcher.append(videoRating);
videoWatcher.fadeIn();
});
var videoItem = $('<li>');
videoItem.append(videoLink);
$('#videos-list').append(videoItem);
}
var videos = [
{"youtubeId": "TddFnTB_7IM",
"title": "Trip through the 80s",
"author": "meliberty",
"rating": 90
},
{"youtubeId": "HwSKkKrUzUk",
"title": "Circle of Life",
"author": "parkerjademerce",
"rating": 70
},
{"youtubeId": "il2IrgFHfsg",
"title": "The Ooooh Cat",
"author": "RnBTree",
"rating": 60
},
{"youtubeId": "epUk3T2Kfno",
"title": "Otters Holding Hands",
"author": "cynthiaholmes",
"rating": 100
}
]
for (var i = 0; i < videos.length; i++) {
addVideoToList(videos[i]);
}
</script>
</body>
</html>