blob: e2c63e48cc91e2e15e7ce6dac6546b54dd44a653 (
plain) (
blame)
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
|
$(document).ready(function()
{
$(".search_input").focus();
$(".search_input").keyup(function()
{
$("#video").html('');
var search_input = $(this).val();
var keyword= encodeURIComponent(search_input);
var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&max-results=12&v=2&alt=jsonc';
$.ajax({
type: "GET",
url: yt_url,
dataType:"jsonp",
success: function(response)
{
if(response.data.items)
{
$.each(response.data.items, function(i,data)
{
var video_id=data.id;
var video_title=data.title;
var video_viewCount=data.viewCount;
var video_frame="<img src='http://i.ytimg.com/vi/"+video_id+"/mqdefault.jpg'/>";
var final="<div class='result'><div>"+video_frame+"</div><a href='http://www.youtube.com/embed/"+video_id+"' target='viewer' id='title' onclick='showframe()' title='"+video_title+"'>"+video_title+"</a></div>";
$("#video").append(final);
});
}
else
{
$("#video").html("<div id='no'>No video found.</div>");
}
}
});
});
});
|