//雷达图
var GMRadar = {
n: -1,
time: 1000,
time2: null,
LodaData: function () {
$.ajax({
type: "GET",
url: "/Handler/RadarListHandler.ashx",
//dataType: "json",
data: { Type: "GM" },
success: function (imgList) {
if (imgList == "[]") {
$(".rad_li2 .ldpage").hide();
$(".maintainGM").css('display', 'block');
} else {
var imgjsonList = eval(imgList);
var lastImg = imgjsonList[0];
$(".rad_li2 .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/gm/Z9757_201711070251Z_COMP_00_COMP.gif
//获取当前时间
var nowtime = new Date().getTime();
var diffminpt = (nowtime - pictime) / 60000;
//GMRadar.PlayPic(imgjsonList);
//$(".maintainGM").css('display', 'none');
if (diffminpt > 510) {
$(".rad_li2 .ldpage").hide();
$(".maintainGM").css('display', 'block');
$(".rad_li2 .ldPic").hide();
} else {
GMRadar.PlayPic(imgjsonList);
$(".maintainGM").css('display', 'none');
$(".rad_li2 .ldPic").css('display', 'block');
}
}
}
});
//近2小时内的图片
$.ajax({
type: "GET",
url: "/Handler/RadarsixHourListHandler.ashx",
dataType: "json",
data: { Type: "sixHourOfGM" },
success: function (json) {
var _sixHourImg = $(".rad_li2 .sixHourImg");
$.each(json, function (key, content) {
if (key < 40)//只显示40张图片
$("" + content[1] + "").appendTo(_sixHourImg);
})
$(".rad_li2 .sixHourImg a").bind("click", function () {
$(".rad_li2 .ldPic").attr("src", $(this).attr("rel"));
$(".rad_li2 .timeStart i").html($(this).text())
GMRadar.playStop();
$(".rad_li2 .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_li2 .ldpage p").empty();
$(".rad_li2 .ldpage p").append(ulcontent);
var $span = $(".rad_li2 .ldpage p span");
var n = count = -1;
count = $span.size() - 1;
$(".rad_li2 .ldplay").bind("click", function () {
if ($(this).hasClass("stop")) { clearInterval(GMRadar.time2); $(this).removeClass("stop").attr("src", "/images/ldNext.jpg").attr("title", "播放"); } else {
$(this).addClass("stop").attr("src", "/images/ldstop.jpg").attr("title", "暂停");
GMRadar.time2 = setInterval(function () { GMRadar.showAuto($span, Dayun_radar); }, GMRadar.time);
}
});
$span.bind("click", function () {
var i = $(this).index();
GMRadar.picChang(i, $span, Dayun_radar);
GMRadar.playStop();
})
$(".rad_li2 .ldRight img.ldPic").bind("click", function () {
$(".rad_li2 .ldplay").click();
})
//播放
$(".rad_li2 .ldplay").click();
$(".rad_li2 .stemp a").bind("click", function () {
var ctime = $(this).attr("rel");
clearInterval(GMRadar.time2);
GMRadar.time2 = setInterval(function () { GMRadar.showAuto($span, Dayun_radar); }, ctime);
})
},
showAuto: function ($span, Dayun_radar) {
GMRadar.n = GMRadar.n >= (count) ? 0 : GMRadar.n + 1;
GMRadar.picChang(GMRadar.n, $span, Dayun_radar);
//$span.eq(Radar.n).trigger('click');
},
picChang: function (i, $span, Dayun_radar) {
//debugger;
GMRadar.n = i;
$(".rad_li2 .ldPic").attr("src", Dayun_radar[GMRadar.n]);
var s = $span.eq(Radar.n);
$span.eq(GMRadar.n).siblings().removeClass("hover");
$span.eq(GMRadar.n).addClass("hover");
},
playStop: function () {
// debugger;
if (GMRadar.time2 != null)
clearInterval(GMRadar.time2);
$(".rad_li2 .ldplay").removeClass("stop").attr("src", "/images/ldNext.jpg").attr("title", "播放");
}
}