$(function () { $(window).bind('resize', boxSize).resize(boxSize); jQuery(".tianqxx_gd").slide({ mainCell: ".bd ul", autoPlay: true, effect: "topMarquee", interTime: 80, trigger: "click" }); xstq(); war(); dsyb(); artYubao(); day10(); day15(); jiaotong(); IndexNewImg(); Index(); hdjlVldForm(); });
var tmax_9 = new Array();
var tmin_9 = new Array();
var time_9 = new Array();
var tmax_15 = new Array();
var tmin_15 = new Array();
var time_15 = new Array();
function day10() {
$.getJSON("weather/data/10day.js?t=" + Math.random(), function (json) {
if (json) {
var strbtit = new Array();
var datetime = new Date(json[0]["datetime"].replace(/-/g, "/"));
var datehour = datetime.getHours();
var create_date = json[0]["create_date"].substring(0, (json[0]["create_date"].length - 10));
var create_datetime = new Date(create_date.replace(/-/g, "/"));
if (datehour >= 6 && datehour <= 11) {
if ($("#date_fb").length > 0) { $("#date_fb").append(create_datetime.Format('yyyy-MM-dd hh:mm')) };
datetime.setDate(datetime.getDate());
} else {
if ($("#date_fb").length > 0) { $("#date_fb").append(create_datetime.Format('yyyy-MM-dd hh:mm')) };
datetime.setDate(datetime.getDate() + 1);
}
var dayNames = new Array("周日", "周一", "周二", "周三", "周四", "周五", "周六");
for (var i = 1; i <= 10; i++) {
var _tmax = json[0]["tmax" + i + ""]; var _tmin = json[0]["tmin" + i + ""];
var _week = dayNames[datetime.getDay()];
strbtit.push("" + datetime.Format('MM/dd') + "
" + _week + "
");
time_9.push(datetime.Format('MM/dd'));
tmax_9.push(_tmax);
tmin_9.push(_tmin);
datetime.setDate(datetime.getDate() + 1)
}; $("#littit_10").append(strbtit.join(""));
$("#littit_10 span:last").css("background", "none");
//line_10day();
tenday();
}
})
};
function day15() {
$.getJSON("weather/data/15day.js?t=" + Math.random(), function (json) {
if (json) {
var strbtit = new Array();
var datetime = new Date(json[0]["valid_datetime"].replace(/-/g, "/"));
var datehour = datetime.getHours();
//var create_date = json[0]["create_date"].substring(0, (json[0]["create_date"].length - 6));
if (datehour >= 6 && datehour <= 11) {
//if ($("#date_fb").length > 0) { $("#date_fb").append(datetime.Format('yyyy-MM-dd 6:00')) };
datetime.setDate(datetime.getDate());
}else{
//if ($("#date_fb").length > 0) { $("#date_fb").append(datetime.Format('yyyy-MM-dd 17:00')) };
datetime.setDate(datetime.getDate()+1);
}
var dayNames = new Array("周日", "周一", "周二", "周三", "周四", "周五", "周六");
for (var i = 1; i <= 15; i++) {
var _tmax = json[0]["tmax" + i + ""]; var _tmin = json[0]["tmin" + i + ""];
var _week = dayNames[datetime.getDay()];
strbtit.push("" + datetime.Format('MM/dd') + "
" + _week + "
");
time_15.push(datetime.Format('MM/dd'));
tmax_15.push(_tmax);
tmin_15.push(_tmin);
datetime.setDate(datetime.getDate() + 1)
}; $("#littit_15").append(strbtit.join(""));
$("#littit_15 span:last").css("background", "none");
//line_10day();
fifday();
}
})
};
var _StationName = { "59828": ["禅城", 0], "59288": ["南海", 1], "59480": ["顺德", 2], "59829": ["高明", 3], "59279": ["三水", 4] };
var _shikuangStation = {"G6808": ["禅城", "59828", "59828"], "G2288": ["南海", "59288", "59288"], "G2284": ["顺德", "59480", "59480"], "G7045": ["高明", "59829", "V7045"], "G2289": ["三水", "59279", "59279"]};
function dsyb() {
$.getJSON("weather/data/foshorttime.js?t=" + Math.random(), function (json) {
$("#duanshi_s_cc").empty();
if (json) {
$.each(_StationName, function (key, value) {
var foshorHtml_am = ""; var foshorHtml_am_time = "";
var foshorHtml_pm = ""; var foshorHtml_pm_time = "";
var issue_datetime_html = ""; $.each(json, function (index, content) {
var sid = content.stationid; if (key == sid) {
var valid_datetime = new Date(content.valid_datetime.replace(/-/g, "/"));
if (foshorHtml_am == "") {
foshorHtml_am_time = valid_datetime;
foshorHtml_am = "
" + content.efdate + ":" + content.ws + "," + content.wind + ",气温:" + Math.floor(content.tmin) + "-" + Math.floor(content.tmax) + "℃,相对湿度:" + Math.floor(content.hmin) + "%-" + Math.ceil(content.hmax) + "%"; } else { foshorHtml_pm_time = valid_datetime; foshorHtml_pm = "
" + content.efdate + ":" + content.ws + "," + content.wind + ",气温:" + Math.floor(content.tmin) + "-" + Math.floor(content.tmax) + "℃,相对湿度:" + Math.floor(content.hmin) + "%-" + Math.ceil(content.hmax) + "%"; var issue_datetime = new Date(content.issue_datetime.replace(/-/g, "/")); issue_datetime_html += "" + issue_datetime.Format("MM月dd日hh时mm") + "分发布"; } } }); if (foshorHtml_pm_time < foshorHtml_am_time) { var pm_t = foshorHtml_am; foshorHtml_am = foshorHtml_pm; foshorHtml_pm = pm_t; }; foshorHtml_am += ";
" + json[0]["summary"].replace("。", ";") + "
" + json[0]["outlook"] + "" + datetime.Format("MM月dd日hh时mm") + "分发布
") } }) }; function artYubao() { $.ajax({ type: "POST", dataType: "jsonp", url: "http://219.130.221.166:8080/huanbao/newaoybData.action", timeout: 6000, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log("数据获取失败!" + "XMLHttpRequest.status:" + XMLHttpRequest.status + " XMLHttpRequest.readyState:" + XMLHttpRequest.readyState + " textStatus:" + textStatus) }, success: function (json) { var date1 = $("#airdate1"); var date2 = $("#airdate2"); var date3 = $("#airdate3"); var acontent1 = $("#acontent1"); var bcontent1 = $("#bcontent1"); var ccontent1 = $("#ccontent1"); var acontent2 = $("#acontent2"); var bcontent2 = $("#bcontent2"); var ccontent2 = $("#ccontent2"); var airtime = $("#airtime"); date1.html(json[0].H24.substring(5, 10).replace("-", "/")); date2.html(json[0].H48.substring(5, 10).replace("-", "/")); date3.html(json[0].H72.substring(5, 10).replace("-", "/")); acontent1.html(json[0].AUTO_COM24); bcontent1.html(json[0].AUTO_COM48); ccontent1.html(json[0].AUTO_COM72); acontent2.html(json[0].MANAUAL_COM24); bcontent2.html(json[0].MANAUAL_COM48); ccontent2.html(json[0].MANAUAL_COM72); var airupdate = new Date(Date.parse(json[0].RESULT_TIME.replace(/-/g, "/"))); airtime.html(airupdate.format("yyyy年MM月dd日hh时")); } }) }; function xstq() { $('.ybpic .skNext').live('click', function () { var sk_zxs = $('div.sk_zxs').hide(); $(".sxsfont ul").hide(); var curr_sk_zxs = $(this).parents('div.sk_zxs').next('div.sk_zxs'); var bgImg = curr_sk_zxs.find("div.bg img").attr("src"); var index = curr_sk_zxs.index(); if (index == -1) { sk_zxs.stop(true, true).eq(0).fadeIn(); $(".sxs_" + sk_zxs.eq(0).attr("rel")).stop(true, true).fadeIn(); bgImg = sk_zxs.eq(0).find("div.bg img").attr("src") } else { curr_sk_zxs.stop(true, true).fadeIn(); $(".sxs_" + curr_sk_zxs.attr("rel")).stop(true, true).fadeIn() }; $(".ybpic:first").css("background", "url(" + bgImg + ") no-repeat") }); var vis_lastJson = null; $.ajaxSettings.async= false; $.getJSON("weather/data/vis_last.js?t=" + Math.random(), function (json) { vis_lastJson = json }); $.each(_shikuangStation, function (key, value) { $.getJSON("weather/data/aws_inst_fo_" + key + ".js?t=" + Math.random(), function (json) { if (json) { $.getJSON("weather/data/fohours_" + value[1] + ".js?t=" + Math.random(), function (content) { var newJson = json[json.length - 1]; var firstJson = json[0]; var t = parseFloat(newJson.t).toFixed(1); var calT = parseFloat(t - firstJson.t).toFixed(1); var p = newJson.p; var u = newJson.u; var wd2 = newJson.wd2; var wf2 = newJson.wf2; var r1h = newJson.r1h; var r3h = newJson.r3h; var newdatetime = new Date(newJson.datetime.replace(/-/g, "/")); var datetime = new Date(json[0].datetime.replace(/-/g, "/")); var yubao_day1 = new Array(); var showrval = ""; var r1hInt = r1h != "" ? r1h : 0; var r3hInt = r3h != "" ? r3h : 0; if (r1hInt > 0) { showrval = newdatetime.Format('dd日hh时') + "至今" + r1hInt + "(mm)"; } else if (r3hInt > 0) { showrval = newdatetime.Format('dd日hh时') + "至今" + r1hInt + "(mm)" } else { var r24h = 0; $.each(json, function (k, content) { var r = content.r1h; if (r != "") r24h += parseFloat(r); }); r24h = r24h.toFixed(1); showrval = datetime.Format('dd日hh时') + "至今" + (r24h == 0 ? "无雨量记录" : r24h + "(mm)"); }; var vis_lastVis = 0; $.each(vis_lastJson, function ( k, vis_lastcontent) { if (vis_lastcontent.stationid == value[2]) { vis_lastVis = vis_lastcontent.vis; return false; } }); vis_lastVis = vis_lastVis > 0 ? (vis_lastVis / 1000).toFixed(1) + "公里" : "无数据"; yubao_day1.push("现在 · " + value[0] + "
" + json[i]["ws"] + "
" + Math.floor(json[i]["tmin"]) + "~" + Math.ceil(json[i]["tmax"]) + "℃
" + json[0]["situation"] + "
"); jt_right01.push("更多"); jt_right02.push("" + json[0]["forecast_content"] + "
"); jt_right02.push("更多"); $("#jt_right01").append(jt_right01.join('')); $("#jt_right02").append(jt_right02.join('')) } }) }; function Index() { $(".tqzs ul li").hover(function () { $(this).find(".nav_5").show() }, function () { $(this).find(".nav_5").hide() }); $(".link_ti li.title:last").css("marginRight", 0); var sk_time = null; $(".nav_1 ul li").hover(function () { var curr = $(this); sk_time = setTimeout(function () { $(".nav_1 ul li").removeClass("hover"); curr.addClass("hover"); var index = $(".nav_1 ul li").index(curr); if (!$(".ybpic").eq(index).is(":visible")) { $(".ybpic").stop(true, true).fadeOut(); $(".ybpic").stop(true, true).eq(index).fadeIn() } }, 500) }, function () { clearTimeout(sk_time) }); $(".local_scenery ul li").mouseover(function () { $(".local_scenery ul li").removeClass("hover"); $(this).addClass("hover"); var index = $(".local_scenery ul li").index(this); $(".local_scenery_con .cxyb_con").stop(true, true).fadeOut(); $(".local_scenery_con .cxyb_con").stop(true, true).eq(index).fadeIn() }); $(".nav_6 ul li").click(function () { $(this).siblings().removeClass("hover"); $(this).addClass("hover"); var index = $(this).index(); $(".daytq0,.daytq1").stop(true, true).hide(); $(".daytq" + index + "").stop(true, true).fadeIn() }); $(".nav_7 ul li").mouseover(function () { $(".nav_7 ul li").removeClass("hover"); $(this).addClass("hover"); var index = $(".nav_7 ul li").index(this); $(".tfmap").stop(true, true).fadeOut(); $(".tfmap").stop(true, true).eq(index).fadeIn() }); $(".nav_8 ul li").mouseover(function () { $(".nav_8 ul li").removeClass("hover"); $(this).addClass("hover"); var index = $(".nav_8 ul li").index(this); $(".qhpg ul.u1").stop(true, true).fadeOut(); $(".qhpg ul.u1").stop(true, true).eq(index).fadeIn() }); $(".dsfont_area li").hover(function () { $(this).siblings().removeClass("hover"); $(this).addClass("hover"); var index = $(this).index(); $(".dsfont div").stop(true, true).hide(); $(".dsfont div.shtime_" + index + "").stop(true, true).fadeIn() }, function () { }); $(".linknav").click(function () { var childrenUl = $(this).children("ul"); var li_count = childrenUl.children("li").size(); var ultop = li_count * -39; childrenUl.css("top", ultop + (li_count - 1)); childrenUl.show() }); $(".linknav .list li").click(function () { window.open($(this).attr("rel")) }); $(".linknav").hover(function () { }, function () { $(this).find("ul").hide() }); $(".nav_ygzw ul li").mouseover(function () { $(".nav_ygzw ul li").removeClass("hover"); $(this).addClass("hover"); var index = $(".nav_ygzw ul li").index(this); $(".con_ygzw").stop(true, true).fadeOut(); $(".con_ygzw").stop(true, true).eq(index).fadeIn() }); $(".nav_ggda ul li").mouseover(function () { $(".nav_ggda ul li").removeClass("hover"); $(this).addClass("hover"); var index = $(".nav_ggda ul li").index(this); $(".con_ggda").stop(true, true).fadeOut(); $(".con_ggda").stop(true, true).eq(index).fadeIn() }) }; function hdjlVldForm() { $(".hdjl_form").Validform({ tiptype: function (msg, o, cssctl) { var objtip = $("#errcc"); cssctl(objtip, o.type); objtip.text(msg) }, ajaxPost: true, callback: function (data) { if (data.status == "y") { $("#errcc").html(data.info); $("#uname").val(""); $("#umail").val(""); $("#content").val(""); $("#txtCode").val("") } } }) }; function IndexNewImg() { $.ajax({ url: "Radar/RadarList.js?t=" + Math.random(), success: function (imgList) { $(".index_radar").attr("src", "/tools/Http_ImgLoad.ashx?w=352&h=211&m=Cut&gurl=/" + eval(imgList)[0]); } }); $.ajax({ url: "Cloud/CloudList-fy2e.js?t=" + Math.random(), success: function (imgList) { if (imgList == "[]") { $.ajax({ type: "GET", url: "/Cloud/CloudList-fy2d.js?t=" + Math.random(), success: function (imgList) { var img = eval(imgList)[0]; var imgsavrPath = img.substr(0, 12); var imgName = img.substr(12); var year = img.substr(17, 4); var month = img.substr(22, 2); var day = img.substr(25, 2); var cloudImg = imgsavrPath + year + "/" + month + "/" + day + "/" + imgName; $(".index_cloud").attr("src", "/tools/Http_ImgLoad.ashx?w=352&h=211&m=Cut&gurl=" + img) } }) } else { var img = eval(imgList)[0]; var imgsavrPath = img.substr(0, 12); var imgName = img.substr(12); var year = img.substr(17, 4); var month = img.substr(22, 2); var day = img.substr(25, 2); var cloudImg = imgsavrPath + year + "/" + month + "/" + day + "/" + imgName; $(".index_cloud").attr("src", "/tools/Http_ImgLoad.ashx?w=352&h=211&m=Cut&gurl=" + img) } } }); $.ajax({ url: "Virtual/VirtualList.js?t=" + Math.random(), success: function (imgList) { var img = eval(imgList)[0]; $(".index_virtual").attr("src", "/tools/Http_ImgLoad.ashx?w=352&h=264&m=Cut&gurl=/pub/picture/rpt/sj/" + img.pic) } }); $(".index_dz").attr("src", "/tools/Http_ImgLoad.ashx?w=352&h=211&m=Cut&gurl=" + pic) };Date.prototype.Format = function (fmt) { var o = { "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds(), "q+": Math.floor((this.getMonth() + 3) / 3), "S": this.getMilliseconds() }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt }; function ShikuanType(code) { var type = ""; switch (code) { case "0": type = "sunny"; break; case "1": case "53": type = "partly-cloudy"; break; case "2": case "18": type = "cloudy"; break; case "3": case "4": type = "shower"; break; case "5": case "6": case "7": case "8": case "9": case "10": case "11": case "12": case "21": case "22": case "23": case "24": case "25": type = "rainy"; break }; return type; }