//雷达图
var NHRadar = {
n: -1,
time: 1000,
time2: null,
LodaData: function () {
$.ajax({
type: "GET",
url: "/Handler/RadarListHandler.ashx",
//dataType: "json",
data: { Type: "NH" },
success: function (imgList) {
if (imgList == "[]") {
$(".rad_li4 .ldpage").hide();
$(".maintainNH").css('display', 'block');
} else {
var imgjsonList = eval(imgList);
var lastImg = imgjsonList[0];
$(".rad_li4 .ldPic").attr("src", lastImg);
var picyear = lastImg.substring(28, 32);
var picmon = lastImg.substring(32, 34);
var picday = lastImg.substring(34, 36);
var pichour = lastImg.substring(36, 38);
var picmin = lastImg.substring(38, 40);
var pictime = new Date(picyear, picmon * 1 - 1, picday, pichour, picmin).getTime();
///pub/picture/radar/nh/Z9757_201711070304Z_PPI_01_19.png
//获取当前时间
var nowtime = new Date().getTime();
var diffminnh = (nowtime - pictime) / 60000;
if (diffminnh > 510) {
$(".rad_li4 .ldpage").hide();
$(".maintainNH").css('display', 'block');
$(".rad_li4 .ldPic").hide();
} else {
NHRadar.PlayPic(imgjsonList);
$(".maintainNH").css('display', 'none');
$(".rad_li4 .ldPic").css('display', 'block');
}
}
}
});
//近2小时内的图片
$.ajax({
type: "GET",
url: "/Handler/RadarsixHourListHandler.ashx",
dataType: "json",
data: { Type: "sixHourOfNH" },
success: function (json) {
var _sixHourImg = $(".rad_li4 .sixHourImg");
$.each(json, function (key, content) {
if (key < 40)//只显示40张图片
$("" + content[1] + "").appendTo(_sixHourImg);
})
$(".rad_li4 .sixHourImg a").bind("click", function () {
$(".rad_li4 .ldPic").attr("src", $(this).attr("rel"));
$(".rad_li4 .timeStart i").html($(this).text())
NHRadar.playStop();
$(".rad_li4 .ldpage p span").removeClass("hover");
})
}
});
},
PlayPic: function (Dayun_radar_a) {
//反序
var Dayun_radar = Array();
for (var i = Dayun_radar_a.length - 1; i >= 0 ; i--) {
Dayun_radar.push(Dayun_radar_a[i]);
}
if (typeof Dayun_radar == 'undefined' || Dayun_radar == null) return;
var sd = ''; ulcontent = '';
for (var i = 1; i <= Dayun_radar.length; i++) {
ulcontent += '' + (i) + '';
}
$(".rad_li4 .ldpage p").empty();
$(".rad_li4 .ldpage p").append(ulcontent);
var $span = $(".rad_li4 .ldpage p span");
var n = count = -1;
count = $span.size() - 1;
$(".rad_li4 .ldplay").bind("click", function () {
if ($(this).hasClass("stop")) { clearInterval(NHRadar.time2); $(this).removeClass("stop").attr("src", "/images/ldNext.jpg").attr("title", "播放"); } else {
$(this).addClass("stop").attr("src", "/images/ldstop.jpg").attr("title", "暂停");
NHRadar.time2 = setInterval(function () { NHRadar.showAuto($span, Dayun_radar); }, NHRadar.time);
}
});
$span.bind("click", function () {
var i = $(this).index();
NHRadar.picChang(i, $span, Dayun_radar);
NHRadar.playStop();
})
$(".rad_li4 .ldRight img.ldPic").bind("click", function () {
$(".rad_li4 .ldplay").click();
})
//播放
$(".rad_li4 .ldplay").click();
$(".rad_li4 .stemp a").bind("click", function () {
var ctime = $(this).attr("rel");
clearInterval(NHRadar.time2);
NHRadar.time2 = setInterval(function () { NHRadar.showAuto($span, Dayun_radar); }, ctime);
})
},
showAuto: function ($span, Dayun_radar) {
NHRadar.n = NHRadar.n >= (count) ? 0 : NHRadar.n + 1;
NHRadar.picChang(NHRadar.n, $span, Dayun_radar);
//$span.eq(Radar.n).trigger('click');
},
picChang: function (i, $span, Dayun_radar) {
//debugger;
NHRadar.n = i;
$(".rad_li4 .ldPic").attr("src", Dayun_radar[NHRadar.n]);
var s = $span.eq(Radar.n);
$span.eq(NHRadar.n).siblings().removeClass("hover");
$span.eq(NHRadar.n).addClass("hover");
},
playStop: function () {
// debugger;
if (NHRadar.time2 != null)
clearInterval(NHRadar.time2);
$(".rad_li4 .ldplay").removeClass("stop").attr("src", "/images/ldNext.jpg").attr("title", "播放");
}
}