$(function () {
queryyears();
})
function getchannelid(){
return $("#cid").val();
}
function querylistbyyear(year){
$.ajax({
url:"/xhr/querylistbyyear/"+getchannelid()+"/"+year,
success:function(data){
putlist(data);
}
})
}
function putlist(data){
var str = "";
$.each(data,function(i,n){
str += '
';
str += ''+n.title+'
';
str += ''+n.description+'
';
str += '';
})
$("#history_ul").html(str);
}
function queryyears(){
$.ajax({
url:"/xhr/queryyears/"+getchannelid(),
asycn:false,
success:function(data){
putyears(data);
}
})
}
function putyears(data){
var str = "";
var year = "";
$.each(data,function(i,n){
if(i == 0){
year = n.datetime;
}
str += '';
str += '
'+n.datetime+'
';
str += ' ';
str += '';
})
$("#years").html(str);
history();
querylistbyyear(year);
}
function history(){
$anchortop=$('.his_ll').offset().top ;
$(window).scroll(function(){
wint=$(window).scrolltop();
if (wint>$anchortop) {
$('.his_ll').addclass('anchor_fixed');
}
else{
$('.his_ll').removeclass('anchor_fixed');
}
})
var his_slide = new swiper('.history-part .his_ll .swiper-container',{
direction: 'vertical',
slidesperview: 7,
slidespergroup : 1,
spacebetween: 0,
prevbutton:'.history-part .his_ll .swiper-button-prev',
nextbutton:'.history-part .his_ll .swiper-button-next',
breakpoints:{
1024: {
slidesperview: 6,
direction: 'horizontal',
},
767: {
slidesperview: 3,
direction: 'horizontal',
}
}
})
var _ind=0;
var _len = $(".history-part .his_ll .swiper-slide").length;
//console.log(_len);
btnjudge();
$(".history-part .his_ll .swiper-slide").click(function(){
_ind = $(this).index();
btnjudge();
var url = $(this).data("src");
$(this).addclass("on").siblings().removeclass("on");
//caseajax(".his_rr",url);
})
$(".history-part .his_ll .swiper-button-prev").click(function(){
_ind--;
btnjudge();
$(".history-part .his_ll .swiper-slide").eq(_ind).addclass("on").siblings().removeclass("on");
$(".history-part .his_ll .swiper-slide.on").click();
})
$(".history-part .his_ll .swiper-button-next").click(function(){
_ind++;
btnjudge();
$(".history-part .his_ll .swiper-slide").eq(_ind).addclass("on").siblings().removeclass("on");
$(".history-part .his_ll .swiper-slide.on").click();
})
$(".history-part .his_ll .swiper-slide:eq(0)").click();
function btnjudge() {
if(_ind >= _len - 1) {
$('.history-part .his_ll .swiper-button-next').addclass("disabled")
_ind = _len - 1;
} else {
$('.history-part .his_ll .swiper-button-next').removeclass("disabled")
}
if(_ind <= 0) {
$(".history-part .his_ll .swiper-button-prev").addclass("disabled")
_ind = 0;
} else {
$(".history-part .his_ll .swiper-button-prev").removeclass("disabled")
}
}
}