<div>
<div>
<div id="prevVideo"> </div>
<div id="listVideo2"> </div>
<div id="nextVideo"> </div>
</div>
<br clear="all" />
<div id="error" style="border:1px #сccc solid; color:#f00"> </div>
</div>
<script type="text/javascript">
$(document).ready ( function (){ //
var user ='имя автора канала на ютубе';
var lenPage=20;
var startOn=false;
var playerWidth="480";
var playerHeight1="360";
var playerHeight2="270";
var startOn=false;
function animeDX(id, data, direct){
$(id).hide();
$(id).html( data);
$(id).animate( {'opacity':'toggle'},500);
loadL();
if (!startOn) {
$('#ytvN0').trigger('click');
startOn=true;
}
return;
var w = $(id).width()+0;
var h = $(id).height()+0;
var top=0;
var left=-w;
if ( direct =="top"){ left=0; top=-h; }
if ( direct =="bottom"){ left=0; top=h; }
if ( direct =="left"){ left=w; top=0; }
if ( direct == "right"){ left=-w; top=0; }
var s='<div id="tmp5421" style="position:relative; top:'+ top +'px; left:'+ left +'px;">' + data + '</div>';
$(id).html(s);
$('#tmp5421').animate(
{left:0,top:0},400,'swing',
function(){
$(id).html(data);
loadL();
if (!startOn) {
$('#ytvN0').trigger('click');
startOn=true;
}
});
}
function loadL(){
$('.oneVideo').click (
function (){
var aspectRatio = $(this).data("ws");
var width = playerHeight1;
if (aspectRatio == "widescreen"){width = playerHeight2;}
var s= '<iframe width="'+playerWidth+'" height="'+ width +'"'+
'src="http://www.youtube.com/embed/'+
$(this).data("href") +
'?html5=1&theme=light&autoplay=1&wmode=transparent&rel=0&color=red&modestbranding=1&autohide=1"'+
' frameborder="0" allowfullscreen=""></iframe>';
$('#player1').html(s);
$('#vdescr').html('<h3>'+decodeURIComponent( $(this).data("title") )+ /*' ('+$(this).data("count")+*/'</h3><p>'+decodeURIComponent( $(this).data("description") )+'</p>');
return (false);
})
}
function clickPage(){
$('.clickPage').click (
function (){
readList($(this).data("page")+0, $(this).data("direct"));
})
}
function loadPages(page){
var i = 0;
var html=[];
if (page > 1) {
i=page-1;
html.push('<a href="#" data-page="' + i + '" class="clickPage" + data-direct="bottom">');
html.push('предыдущие</a>');
}
$
('#prevVideo').html
(html
.join('')); html=[];
i = page + 1;
var serach= 'http://gdata.youtube.com/feeds/api/users/'+user+'/uploads?time=today&max-results='+lenPage+'&v=2&alt=jsonc&orderby=published&start-index='+(1+ (i-1)*lenPage)+'&callback=?';
$.ajax({
url: serach,
dataType:'json',
cache: false,
async: true,
type: "get",
success: function(content){
var entries = content.data.items || [];
if (entries.length > 0) {
html.push('<a href="#" data-page="' + i + '" class="clickPage" + data-direct="top">');
html.push('еще видео</a>');
}
$
('#nextVideo').html
(html
.join('')); html=[];
clickPage();
},
error: function (xhr, ajaxOptions, thrownError) {
$('#error').html(xhr.status+ ' - '+ thrownError);
}
});
}
function readList (page,direct) {
var entries= [];
var html=[];
var serach= 'http://gdata.youtube.com/feeds/api/users/'+user+'/uploads?time=today&max-results='+lenPage+'&v=2&alt=jsonc&orderby=published&start-index='+(1+ (page-1)*lenPage)+'&callback=?';
$.ajax({
url: serach,
dataType:'json',
cache: false,
async: true,
type: "get",
success: function(content){
var entries = content.data.items || [];
var html= [];
var entry = "";
var aspectRatio="";
var viewCount=""
// html.push('<p>Число записей '+entries.length+'</p>');
var datime= [];
for (var i = 0; i < entries.length; i++) {
entry = entries[i];
aspectRatio = entry.aspectRatio || '';
viewCount = entry.viewCount || '';
html.push('<div class="oneV">');
html.push('<p>');
html.push('<a class="oneVideo" id="ytvN'+i+'"');
html.push(' href="#" data-count="'+ viewCount + '"');
html.push(' data-href="'+ entry.id + '"');
html.push(' data-ws="'+ aspectRatio + '"');
html.push(' data-description="'+encodeURIComponent(entry.description)+'"');
html.push(' data-title="'+encodeURIComponent(entry.title)+'"');
html.push(' >');
html.push('<img width="120" height="90" src ="'+entry.thumbnail.sqDefault+'"><br>');
html.push(entry.title+'</a></p></div>');
}
html.push(' <br clear="all">');
animeDX
('#listVideo2',html
.join(''),direct
); loadL();
loadPages(page);
-