$(function () { //boxSize(0); //$(window).bind('resize', boxSize).resize(boxSize); xstq();//现时天气 day10();//预报 war();//预警 IndexNewImg();//最新图片调用 Index(); }) var foid_wea = { "晴": "Clear", "多云": "Cloudy", "阴": "Overcast", "阴天": "Overcast", "阵雨": "Shower", "雷阵雨": "Thundershower", "雷阵雨并伴有冰雹": "Thundershower with hail", "雨夹雪": "Sleet", "小雨": "Light rain", "中雨": "Moderate rain", "大雨": "Heavy rain", "暴雨": "Rainstorm", "大暴雨": "Heavy rainstorm", "特大暴雨": "Extraordinary rainstorm", "阵雪": "Snow shower", "小雪": "Light snow", "中雪": "Moderate snow", "大雪": "Heavy snow", "暴雪": "Blizzard", "雾": "Fog", "冻雨": "Freezing rain", "沙尘暴": "Sandstorm", "小到中雨": "Light to moderate rain", "中到大雨": "Moderate to heavy rain", "大到暴雨": "Heavy rain to rainstorm", "暴雨到大暴雨": "Rainstorm to heavy rainstorm", "大暴雨到特大暴雨": "Heavy rainstorm to extraordinary rainstorm", "小到中雪": "Light to moderate snow", "中到大雪": "Moderate to heavy snow", "大到暴雪": "Heavy snow to blizzard", "浮尘": "Floating dust", "扬沙": "Sand blowing", "强沙尘暴": "Strong sandstorm", "霾": "Haze" }; var foid_wea_val = { 0: "Clear", 1: "Cloudy", 2: "Overcast", 3: "Shower", 4: "Thundershower", 5: "Thundershower with hail", 6: "Sleet", 7: "Light rain", 8: "Moderate rain", 9: "Heavy rain", 10: "Rainstorm", 11: "Heavy rainstorm", 12: "Extraordinary rainstorm", 13: "Snow shower", 14: "Light snow", 15: "Moderate snow", 16: "Heavy snow", 17: "Blizzard", 18: "Fog", 19: "Freezing rain", 20: "Sandstorm", 21: "Light to moderate rain", 22: "Moderate to heavy rain", 23: "Heavy rain to rainstorm", 24: "Rainstorm to heavy rainstorm", 25: "Heavy rainstorm to extraordinary rainstorm", 26: "Light to moderate snow", 27: "Moderate to heavy snow", 28: "Heavy snow to blizzard", 29: "Floating dust", 30: "Sand blowing", 31: "Strong sandstorm", 53: "Haze" }; var tmax_9 = new Array(); var tmin_9 = new Array(); var time_9 = 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, "/")); //转换成Data(); 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, "/")); var datehour = datetime.getHours(); 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("Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"); for (var i = 1; i <= 10; i++) { var _tmax = json[0]["tmax" + i + ""]; var _tmin = json[0]["tmin" + i + ""]; strbtit.push("" + datetime.Format('MM/dd') + "
" + dayNames[datetime.getDay()] + "

\""
"); 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(); } }) } var _StationName = { "59480": ["顺德", 3], "59288": ["南海", 1], "59828": ["禅城", 0], "59279": ["三水", 2], "59829": ["高明", 4] };//站点名称 var _shikuangStation = { "G6808": ["Jihua road", "59828", "59828"], "G2288": ["Shishanliangxia", "59288", "59288"], "G2284": ["shundedaliang", "59480", "59480"], "G7045": ["gaomingyunyongforestry", "59829", "V7041"], "G2289": ["Sanshuiyundonghai", "59279", "59279"] };//站点名称 站点编号 能见度站点编号 //实况 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; $.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, "/")); //转换成Data(); var datetime = new Date(json[0].datetime.replace(/-/g, "/")); //转换成Data(); var yubao_day1 = new Array(); var showrval = ""; var r1hInt = r1h != "" ? r1h : 0; var r3hInt = r3h != "" ? r3h : 0; if (r1hInt > 0)//1小时有雨显示 { showrval = newdatetime.Format('MM/dd/yyyy hh:00') + " To now
" + r1hInt + "(mm)"; } else if (r3hInt > 0) {//3小时有雨显示 showrval = newdatetime.Format('MM/dd/yyyy hh:00') + " To now
" + r1hInt + "(mm)"; } else {//1、3都没有则取24小时 var r24h = 0; $.each(json, function (k, content) { var r = content.r1h; if (r != "") r24h += parseFloat(r); }); r24h = r24h.toFixed(1); showrval = datetime.Format('MM/dd/yyyy hh:00') + " To now
" + (r24h == 0 ? " No rainfall records" : 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) + "Km" : " No data"; yubao_day1.push("
"); yubao_day1.push("

The observation · " + value[0] + "

"); yubao_day1.push("
" + t + "℃
"); yubao_day1.push("
Comparing YTD:" + (calT >= 0 ? "+ " : "- ") + Math.abs(calT) + "℃
"); yubao_day1.push("
Wind Direction:" + wd8[wd2][1] + "
"); yubao_day1.push("
Wind Speed:" + wf2 + " m/s
"); yubao_day1.push("
Visibility:" + vis_lastVis + "
"); //本站信息 yubao_day1.push("
"); yubao_day1.push("
Station pressure:" + (p != "" ? p + "hPa" : "") + "
Relative humidity:" + u + "%
" + showrval + "
"); yubao_day1.push("
" + newdatetime.Format("MM/dd/yyyy hh:mm") + "
"); //天气图标 var curr_datetime = new Date(); var PeriodPath = "day"; if (curr_datetime.getHours() >= 19 || curr_datetime.getHours() < 7) PeriodPath = "night"; var w_code = content[3].w; w_code = ShikuanType(w_code); yubao_day1.push("
"); //背景图 var ybpic_bg = "/images/weather/index/bg/" + PeriodPath + "/" + w_code + ".jpg"; if (key == "G2201") {//佛山季华路 $(".ybpic:first").css("background", "url(" + ybpic_bg + ") no-repeat"); $("#yubao_day1").empty(); } yubao_day1.push("
"); yubao_day1.push("
"); $("#yubao_day1").append(yubao_day1.join('')); $('div.sk_zxs:first').show(); }); } }); //逐三小时预测 var yubao_sxs = new Array(); $.getJSON("/weather/data/fohours_" + value[1] + ".js?t=" + Math.random(), function (json) { yubao_sxs.push(""); $(".sxsfont").append(yubao_sxs.join('')); $(".sxsfont ul:first").show(); }) }) } //预警 function war() { var sContent01 = new Array(); $.getJSON("/weather/data/wa_fo_inforce.js?t=" + Math.random(), function (json) { if (json == "null") { $(".load").hide(); $(".yjqy").show(); return; } if (json) { $(".load").hide(); $(".warnInfo").show(); var wa_fo_area = { "BFFO": "Buddha town", "GDNH": "Namhoi", "GDSD": "Shuntak", "GDGM": "Koming", "GDSS": "Samsui" }; var wa_fo_type = { "A": ["台风", "Typhoon"], "B": ["暴雨", "Rainstorm"], "C": ["高温", "High temperature"], "D": ["寒冷", "Cold wave"], "E": ["大雾", "Heavy fog"], "F": ["灰霾", "Dust-haze"], "G": ["雷雨大风", "Thunderstorm gale"], "I": ["冰雹", "Hail"], "J": ["森林火险", "Forest fire danger"] }; $.each(wa_fo_type, function (type_key, type_val) {//遍历预警类型 var ddHead_html = "
"; sContent01.push(ddHead_html); } }) $(".tqyj dl").append(sContent01.join('')); // $(".tqyj dl dd:not(.yj_type):odd li:not(.areaName)").css("backgroundColor", "#F8E4AF"); } }); } //折线图-十天预报 function line_10day() { require.config({ paths: { echarts: '/Echarts/asset/js/echarts', 'echarts/chart/line': '/Echarts/asset/js/echarts-map' } }); option = { title: { text: '', subtext: '' }, tooltip: { trigger: 'axis', axisPointer: { type: 'none' } }, legend: { selectedMode: false, data: ['', ''] }, toolbox: { show: false }, calculable: false, color: ['#f9a700', '#6196ff'], grid: { x: 40, y: 15, x2: 40, y2: 10, borderWidth: 0 }, xAxis: [ { type: 'category', boundaryGap: false, axisTick: { show: false }, axisLine: false, splitArea: { show: false }, splitLine: { show: false }, axisLabel: { textStyle: { color: '#fff' } }, data: time_9 } ], yAxis: [ { type: 'value', axisLabel: { show: false, formatter: '{value} °C' }, scale: true, axisLine: false, splitArea: { show: false }, splitLine: { show: false } } ], series: [ { name: 'Maximum temperature', type: 'line', itemStyle: { normal: { lineStyle: { shadowColor: 'rgba(0,0,0,0.0)' } } }, symbol: "circle", symbolSize: "2", itemStyle: { normal: { label: { show: true, textStyle: { fontSize: '14', fontFamily: 'arial', color: '#7b7b7b', fontWeight: 'bold' } } } }, data: tmax_9, tooltip: { // Series config. trigger: 'item', formatter: "Maximum temperature:{c} ℃" } }, { name: 'Minimum temperature', type: 'line', itemStyle: { normal: { lineStyle: { shadowColor: 'rgba(0,0,0,0.0)' } } }, symbol: "circle", symbolSize: "2", itemStyle: { normal: { label: { show: true, textStyle: { fontSize: '14', fontFamily: 'arial', color: '#7b7b7b', fontWeight: 'bold' } } } }, data: tmin_9, tooltip: { // Series config. trigger: 'item', formatter: "Minimum temperature:{c} ℃" } } ] }; require( [ 'echarts', 'echarts/chart/line' ], function (ec) { var myChart = ec.init(document.getElementById('weather_10')); myChart.setOption(option); } ) } //本地交通预报 function jiaotong() { $.getJSON("/weather/data/foroad.js?t=" + Math.random(), function (json) { if (json) { var jt_right01 = new Array(); var jt_right02 = new Array(); jt_right01.push("

" + json[0]["s_time"] + "

"); jt_right01.push("

" + json[0]["situation"] + "

"); jt_right01.push("READ MORE"); jt_right02.push("

" + json[0]["f_time"] + "

"); jt_right02.push("

" + json[0]["forecast_content"] + "

"); jt_right02.push("READ MORE"); $("#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(); } ); 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) }); $(".nav_2 ul li").mouseover(function () { $(".nav_2 ul li").removeClass("hover"); $(this).addClass("hover"); var index = $(".nav_2 ul li").index(this); $(".cxyb .cxyb_con").stop(true, true).fadeOut(); $(".cxyb .cxyb_con").stop(true, true).eq(index).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(); }); $(".sjnav ul li").hover(function () { $(".sjnav ul li").removeClass("hover"); $(this).addClass("hover"); var index = $(".sjnav ul li").index(this); $(".sjt ul li.l2").stop(true, true).fadeOut(); $(".sjt ul li.l2").stop(true, true).eq(index).fadeIn(); }, function () { }); //短时预报切换 $(".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 () { $(this).children("ul").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(); }); } //获取最新图 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]); //$(".index_radar").attr("src", 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]; //"/Virtual/dat/" + img.pic $(".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) { //author: meizz 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; // : 13: 阵雪 //: 14: 小雪 //: 15: 中雪 //: 16: 大雪 //: 17: 暴雪 //: 19: 冻雨 //: 20: 沙尘暴 //: 26: 小到中雪 //: 27: 中到大雪 //: 28: 大到暴雪 //: 29: 浮尘 //: 30: 扬沙 //: 31: 强沙尘暴 }