$(function () { Awshour.TimeList(); Awshour.zdMenu(); tab_1(".ldTxt1 li p", ".ldTxt1 li span"); awsTypeChang(); }); var F = { 0: { name: "Foshan", longitude_min: 112.3319, latitude_min: 22.57414, longitude_max: 113.45495, latitude_max: 23.6471, width: 730, height: 740, img: "images/map/qwBg.jpg" }, 4: { name: "Chancheng", longitude_min: 112.938954, latitude_min: 22.893128, longitude_max: 113.196952, latitude_max: 23.09612, width: 700, height: 576, img: "images/map/cc.png" }, 5: { name: "Nanhai", longitude_min: 112.78719, latitude_min: 22.74813, longitude_max: 113.310775, latitude_max: 23.37886, width: 700, height: 860, img: "images/map/nh.png" }, 6: { name: "Shunde", longitude_min: 112.938954, latitude_min: 22.57414, longitude_max: 113.45495, latitude_max: 23.06712, width: 700, height: 700, img: "images/map/sd.png" }, 7: { name: "Sanshui", longitude_min: 112.69613, latitude_min: 22.89313, longitude_max: 113.12107, latitude_max: 23.6471, width: 485, height: 900, img: "images/map/ss.png" }, 8: { name: "Gaoming", longitude_min: 112.3, latitude_min: 22.57414, longitude_max: 112.99966, latitude_max: 23.06712, width: 700, height: 541, img: "images/map/gm.png" } }, position_left = function (w, index) { //图片内目标X坐标=取绝对值(目标经度-图片左边对应经度)/取绝对值(图片右边经度-图片左边对应经度)* (图片的宽度)-边距 var f = F["" + index + ""]; return (f.width * (w - f.longitude_min) / (f.longitude_max - f.longitude_min));//- 35 } , position_top = function (h, index) { //图片内目标Y坐标=取绝对值(目标纬度-图片上边对应纬度)/取绝对值(图片下边纬度-图片上边对应纬度)* (图片的高度)-边距 var f = F["" + index + ""]; return (f.height * (h - f.latitude_max) / (f.latitude_min - f.latitude_max));// - 20 }; var Awshour = { //postUrl:"Awshour/Handler.aspx", postUrl: "/Awshour/dat/", // stationreal: null, hoursList: new Array(),//时间段 mapShowImte: new Array('t', 'r', 'w'),//地图显示天气元素 温度、雨量、风 cityArray: { name: "0", index: "0" }, tiemList_P: "",//时间列表容器后缀 //绑定时间列表 TimeList: function () { $.getJSON("/Awshour/dat/Timelist.js?t=" + Math.random(), function (json) { if (json) { var timeList = $(".timeList") $.each(json, function (index, content) { var i = $(""); $("").attr({ href: "javascript:;", value: content, rel:"" }).text(content).click(function () { var currObj = $(this); timeList.find('a').removeClass("hover"); currObj.addClass("hover"); Awshour.TqList(currObj.attr("value")); }).appendTo(i) i.appendTo(timeList); }) } }); //日记录20-20;8-8时; var timingArray = ["twenty", "eight"]; $.each(timingArray, function (i, type) { $.getJSON(Awshour.postUrl + "Timelist" + type + ".js?t=" + Math.random(), function (json) { if (json) { var timeList_P = $(".timeList" + type) $.each(json, function (index, content) { var i = $(""); $("").attr({ href: "javascript:;", value: content.value, rel: type }).text(content.text).click(function () { var currObj = $(this); timeList_P.find('a').removeClass("hover"); currObj.addClass("hover"); Awshour.TqList(currObj.attr("value"), currObj.attr("rel")); }).appendTo(i); i.appendTo(timeList_P); }) } }); }); // 时最大阵风、雨量;时内5分钟雨量 var timingArray = ["MwMr", "fr"]; $.each(timingArray, function (i, type) { $.getJSON("Awshour/dat/Timelist" + type + ".js?t=" + Math.random(), function (json) { if (json) { var timeList_P = $(".timeList" + type) $.each(json, function (index, content) { var i = $(""); $("").attr({ href: "javascript:;", value: content[1], rel: type }).text(content[0]).click(function () { var currObj = $(this); timeList_P.find('a').removeClass("hover"); currObj.addClass("hover"); Awshour.TqList(currObj.attr("value"), currObj.attr("rel")); }).appendTo(i) i.appendTo(timeList_P); }) } }); }); $(window).load(function () { var aws_p = GetLocationHead("aws_p");//类型 if (aws_p == "") aws_p = 0; $(".Lmenu").children().eq(aws_p).click(); $(".Lmenu").children().eq(aws_p).next("p").find("a:first").click(); }) }, //天气数据 TQList_josn: null, //url选择参数记忆之天气要素 ShowItemUrl: function (mode) { if (mode == "1") {//图模式获取天气要素 气温 时雨量 风 var item = GetLocationHead("item");//天气要素 if (item) { Awshour.mapShowImte = new Array(); var _arraySItem = item.split(','); for (var sitemi = 0; sitemi < _arraySItem.length; sitemi++) { Awshour.mapShowImte.push(_arraySItem[sitemi]); } SetLocationHead("item", Awshour.mapShowItemStr()); } else if ("" == item) { SetLocationHead("item", Awshour.mapShowItemStr()); } else { Awshour.mapShowImte = new Array(); } } }, TqList: function (time, type) { //url记忆选择参数 $("#cluetip").hide(); var sid = GetLocationHead("sid");//区域筛选 sid = sid == "" ? "0" : sid; SetLocationHead("sid",sid); $(".zdsub li").removeClass("hover") var _area = $(".zdsub a:[rev='" + sid + "']") _area.parent().addClass("hover"); Awshour.cityArray.index = sid; Awshour.cityArray.name = _area.attr("val"); $(".type_1 span").html(Awshour.cityArray.name); var mode = GetLocationHead("mode");//展现模式 0表格 1 图 $(".type_3").eq(mode).click(); var tqList_div = $(".tqList"); type = type == undefined ? "" : type; Awshour.tiemList_P = type; var jsFileName = "TQList-" + new Date(time.replace(/\-/g, "\/")).format('yyyyMMdd-hhmm') + type + ".js";//"TQList-20140716-1100.js" if (type == "fr")//非时次记录 { jsFileName = "TQList-" + new Date(time.split("|")[0].replace(/\-/g, "\/")).format('yyyyMMdd-hhmm') + "-" + new Date(time.split("|")[1].replace(/\-/g, "\/")).format('yyyyMMdd-hhmm') + type + ".js"; } if (type == "twenty" || type == "eight")//非时次记录 { jsFileName = "TQList-" + new Date(time.split("|")[0].replace(/\-/g, "\/")).format('yyyyMMdd_')+type+".js"; } $.getJSON(this.postUrl + jsFileName+"?t="+Math.random(), function (json) { if (json) { TQList_josn = json; Awshour.createTable(); } }) if (time) { if (type == "fr")//非时次记录 { var sDate = new Date(time.split("|")[0].replace(/-/g, "/")); var eDate = new Date(time.split("|")[1].replace(/-/g, "/")); $(".zdcon .txt").text("Observation " + (sDate.getMonth() + 1) + "/" + sDate.getDate() + "/" + sDate.getFullYear() + " " + sDate.getHours() + ":00 ——" + (eDate.getMonth() + 1) + "/" + eDate.getDate() + "/" + eDate.getFullYear() + " " + eDate.getHours() + ":00"); } else if (type == "twenty" || type == "eight") { var txtDate = new Date(time.replace(/-/g, "/")); $(".zdcon .txt").text("Observation " + +(txtDate.getMonth() + 1) + "/" + txtDate.getDate() + "/" + txtDate.getFullYear()); } else { var txtDate = new Date(time.replace(/-/g, "/")); $(".zdcon .txt").text("Observation " + (txtDate.getMonth() + 1) + "/" + txtDate.getDate() + "/" + txtDate.getFullYear() + " " + txtDate.getHours() + ":00"); } } }, //加载数据至表格显示 createTable: function () { var tqList_div = $(".tqList") tqList_div.empty(); tqList_div.append(Awshour.listTable()); var tqContent = $(".tqContent")//表格容器 if (TQList_josn.length == 0) { if (Awshour.tiemList_P == "fr") { $(".rTime").html($(".timeListfr a[class='hover']").html()); tqContent.append("Currently no rainfall recorded in this period") } } switch (Awshour.tiemList_P) { case "eight": case "twenty": TQList_josn.sort(function (a, b) { return a[10] - b[10]; }); territory_idIndex = 10; break; case "MwMr": TQList_josn.sort(function (a, b) { return a[14] - b[14]; }); territory_idIndex = 14; break; case "fr": TQList_josn.sort(function (a, b) { return a.territory_id - b.territory_id; }); break; default: TQList_josn.sort(function (a, b) { return a[9] - b[9]; }); break; } $.each(TQList_josn, function (index, content) { switch (Awshour.tiemList_P) { case "fr"://5分钟时雨量 var name = content["sName_en"]; if (name.indexOf(Awshour.cityArray.name) == -1 && Awshour.cityArray.name != "Foshan") //地区筛选显示数据 0 全市 return true; var MinuteArray = ["05", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "00"] var tr = $(""); $("").html($("" + name + "")).appendTo(tr); var rlist = content["rlist"]; var rainHourCount = 0; for (var i = 0; i < MinuteArray.length; i++) { var raincount = rlist[MinuteArray[i]]; var rainStr = " "; if (raincount != "" || raincount != undefined) { var rainInt = 0; if (!isNaN(raincount)) { rainInt = parseFloat(raincount); rainStr = rainInt; rainHourCount += rainInt; } } $("").html(rainStr).appendTo(tr); } $("").html(rainHourCount.toFixed(1)).appendTo(tr); tr.appendTo(tqContent); $(".rTime").html($(".timeListfr a[class='hover']").html()); break; case "eight": case "twenty": var name = content[9]; if (name.indexOf(Awshour.cityArray.name) == -1 && Awshour.cityArray.name != "Foshan")//地区筛选显示数据 0 全市 return true; var tr = $(""); //地点 最低气温(℃) 最高气温(℃) 最大阵风(m/s) 累积降雨(mm) $("").html(name).appendTo(tr); $("").html(content[1]).appendTo(tr); $("").html(content[2]).appendTo(tr); $("").html(content[3]).appendTo(tr); $("").html(content[4]).appendTo(tr); tr.appendTo(tqContent); break; case "MwMr": var name = content[9]; if (name.indexOf(Awshour.cityArray.name) == -1 && Awshour.cityArray.name != "Foshan")//地区筛选显示数据 0 全市 return true; var tr = $(""); //地点 最低气温(℃) 最高气温(℃) 最大阵风(m/s) 累积降雨(mm) $("").html(name).appendTo(tr); $("").html(content[12]).appendTo(tr); $("").html(content[13]).appendTo(tr); $("").html(content[10]).appendTo(tr); $("").html(content[11]).appendTo(tr); $("").html(wd8[content[1]][1]).appendTo(tr); $("").html(content[2]).appendTo(tr); $("").html(content[3]).appendTo(tr); $("").html(content[4]).appendTo(tr); $("").html(content[8]).appendTo(tr); tr.appendTo(tqContent); break; default://自动站时次记录 //if (content[7] == "G6921")//顺德龙江水温站 // return true; var name = content[8]; if (name.indexOf(Awshour.cityArray.name) == -1 && Awshour.cityArray.name != "Foshan")//地区筛选显示数据 0 全市 return true; var tr = $(""); //地点 气温(℃) 时雨量(mm) 风 向 风速(m/s) $("").html(name).appendTo(tr); $("").html(content[1]).appendTo(tr); $("").html(content[2]).appendTo(tr); $("").html(wd8[content[3]][1]).appendTo(tr); $("").html(content[4]).appendTo(tr); tr.appendTo(tqContent); break; } }) //图型定位 Awshour.createMap(); Awshour.TableBgColor(); $(".sortTable").tablesorter(); $(".sortTable tr th").click(function () { setTimeout(function () { Awshour.TableBgColor(); }, 50); }); //最高red 最低bule Awshour.TdValColor(); if (Awshour.tiemList_P == "fr")//5分钟时雨量 查看24小时雨量汇总 $(".zoom").colorbox({ rel: 'group1', iframe: true, innerWidth: 760, innerHeight: 500, current: "{current} / {total}" }); }, //显示地图数据 //气温-t 时雨量-r 风-w createMap: function () { if (Awshour.tiemList_P == "fr") {//时雨量 图形式隐藏 $(".type_3:first").click(); $(".type_3:[rel='p']").hide(); return; } else { $(".type_3:[rel='p']").show(); } showItem = Awshour.mapShowItemStr(); var qwList = $(".qwList");//图型容器 qwList.find("span,img").remove(); var f = F["" + Awshour.cityArray.index + ""]; //地图-背景图设置 $(".zdcon .qwList").css({ width: f.width, height: f.height + 200, backgroundImage: "url(" + f.img + ")", position: "relative", zIndex: 80 }) switch (Awshour.tiemList_P) { case "twenty": case "eight"://日记录 20、8时 $.each(TQList_josn, function (index, content) { if (content[7] == "G6921")//顺德龙江水温站 return true; var name = content[9]; if (name.indexOf(Awshour.cityArray.name) != -1 || Awshour.cityArray.name == "Foshan") {//地区筛选显示数据 0 全市 var p_left = position_left(content[5], Awshour.cityArray.index); var p_top = position_top(content[6], Awshour.cityArray.index); var _span = $(""); _span.css({ left: p_left - 2, top: p_top + 27, position: "absolute", width: "8px", height: "8px", background: "url(images/Round.png) no-repeat", zIndex: 100 }).attr({ title: name, sid: content[7], rel: Awshour.postUrl + "line/" + Awshour.tiemList_P + "/" + content[7] + ".js?t=" + Math.random() }).addClass("stationName"); _span.appendTo(qwList) //气温 if (showItem.indexOf("t") != -1) { //最低气温 var _span_t = $(""); _span_t.css({ textAlign: "left", left: p_left - 33, top: p_top + 28, position: "absolute", color: "#6D3A6D", fontSize: "10px", fontFamily: "Arial", width: "30px", height: "12px", zIndex: 99 }).text(content[1]); _span_t.appendTo(qwList); //最高气温 var _span_max = $(""); _span_max.css({ textAlign: "left", left: p_left - 33, top: p_top + 13, position: "absolute", color: "#FF6C00", fontSize: "10px", fontFamily: "Arial", width: "30px", height: "12px", zIndex: 98 }).text(content[2]); _span_max.appendTo(qwList); } //时雨量 if (showItem.indexOf("r") != -1) { if (parseFloat(content[4]) > 0) { var _span_r = $(""); _span_r.css({ textAlign: "left", left: p_left + 3, top: p_top + 32, position: "absolute", color: "#7b7fed", fontSize: "10px", fontFamily: "Arial", width: "30px", height: "12px", zIndex: 97 }).text(content[4]); _span_r.appendTo(qwList) } } //风 if (showItem.indexOf("w") != -1) { var _wd = content[8]; var _wf = !isNaN(content[3]) ? parseInt(content[3]) : 2; if (_wf > 40) _wf = "40g" else { _wf = _wf % 2 == 0 ? _wf : _wf + 1; _wf = _wf == 0 ? 2 : _wf; } var _img_wf = $(""); _img_wf.attr({ angle: _wd, src: "images/wf/" + _wf + ".gif" }).css({ left: p_left - 12, top: p_top - 0, position: "absolute", width: "25px", height: "61px", zIndex: 96 }).addClass("wf_translate"); _img_wf.appendTo(qwList); } } }); break; case "MwMr"://时极值、雨量 $.each(TQList_josn, function (index, content) { if (content[7] == "G6921")//顺德龙江水温站 return true; var name = content[9]; if (name.indexOf(Awshour.cityArray.name) != -1 || Awshour.cityArray.name == "Foshan") {//地区筛选显示数据 0 全市 var p_left = position_left(content[5], Awshour.cityArray.index); var p_top = position_top(content[6], Awshour.cityArray.index); var _span = $(""); _span.css({ left: p_left - 2, top: p_top + 27, position: "absolute", width: "8px", height: "8px", background: "url(images/Round.png) no-repeat", zIndex: 100 }).attr({ title: name, sid: content[7], rel: Awshour.postUrl + "line/" + Awshour.tiemList_P + "/" + content[7] + ".js?t="+Math.random() }).addClass("stationName"); _span.appendTo(qwList) //气温 if (showItem.indexOf("t") != -1) { //最低气温 var _span_t = $(""); _span_t.css({ textAlign: "left", left: p_left - 33, top: p_top + 28, position: "absolute", color: "#6D3A6D", fontSize: "10px", fontFamily: "Arial", width: "30px", height: "12px", zIndex: 99 }).text(content[10]); _span_t.appendTo(qwList); //最高气温 var _span_max = $(""); _span_max.css({ textAlign: "left", left: p_left - 33, top: p_top + 13, position: "absolute", color: "#FF6C00", fontSize: "10px", fontFamily: "Arial", width: "30px", height: "12px", zIndex: 97 }).text(content[12]); _span_max.appendTo(qwList); } //时雨量 if (showItem.indexOf("r") != -1) { if (parseFloat(content[4]) > 0) { var _span_r = $(""); _span_r.css({ textAlign: "left", left: p_left + 3, top: p_top + 32, position: "absolute", color: "#7b7fed", fontSize: "10px", fontFamily: "Arial", width: "30px", height: "12px", zIndex: 96 }).text(content[4]); _span_r.appendTo(qwList) } } //风 if (showItem.indexOf("w") != -1) { var _wd = content[1]; var _wf = !isNaN(content[2]) ? parseInt(content[2]) : 2; if (_wf > 40) _wf = "40g" else { _wf = _wf % 2 == 0 ? _wf : _wf + 1; _wf = _wf == 0 ? 2 : _wf; } var _img_wf = $(""); _img_wf.attr({ angle: _wd, src: "images/wf/" + _wf + ".gif" }).css({ left: p_left - 12, top: p_top - 0, position: "absolute", width: "25px", height: "61px", zIndex: 95 }).addClass("wf_translate"); _img_wf.appendTo(qwList); } } }); break; default://时次记录 $.each(TQList_josn, function (index, content) { if (content[7] == "G6921")//顺德龙江水温站 return true; var name = content[8]; if (name.indexOf(Awshour.cityArray.name) != -1 || Awshour.cityArray.name == "Foshan") {//地区筛选显示数据 0 全市 var p_left = position_left(content[5], Awshour.cityArray.index); var p_top = position_top(content[6], Awshour.cityArray.index); var _span = $(""); _span.css({ left: p_left - 2, top: p_top + 27, position: "absolute", width: "8px", height: "8px", background: "url(images/Round.png) no-repeat", zIndex:100 }).attr({ title: name, sid: content[7], rel: Awshour.postUrl + "line-" + content[7] + ".js?t=" + Math.random() }).addClass("stationName"); _span.appendTo(qwList) //气温 if (showItem.indexOf("t") != -1) { var _span_t = $(""); _span_t.css({ textAlign: "left", left: p_left - 26, top: p_top + 13, position: "absolute", color: "#FF6C00", fontSize: "10px", fontFamily: "Arial", width: "30px", height: "12px", zIndex: 99 }).text(content[1]); _span_t.appendTo(qwList); } //时雨量 if (showItem.indexOf("r") != -1) { if (parseFloat(content[2]) > 0) { var _span_r = $(""); _span_r.css({ textAlign: "left", left: p_left + 3, top: p_top + 32, position: "absolute", color: "#7b7fed", fontSize: "10px", fontFamily: "Arial", width: "30px", height: "12px", zIndex: 98 }).text(content[2]); _span_r.appendTo(qwList) } } //风 if (showItem.indexOf("w") != -1) { var _wd = 0; switch (Awshour.tiemList_P) { case "eight": case "twenty": _wd = content[8]; break; case "MwMr": _wd = content[1]; break; default://自动站时次记录 _wd = content[3]; } var _wf = !isNaN(content[4]) ? parseInt(content[4]) : 2; if (_wf > 40) _wf = "40g" else { _wf = _wf % 2 == 0 ? _wf : _wf + 1; _wf = _wf == 0 ? 2 : _wf; } var _img_wf = $(""); _img_wf.attr({ angle: _wd, src: "images/wf/" + _wf + ".gif" }).css({ left: p_left - 12, top: p_top - 0, position: "absolute", width: "25px", height: "61px", zIndex: 97 }).addClass("wf_translate"); _img_wf.appendTo(qwList); } } }); break; } this.wf_translate(); Awshour.LineShow(); }, //处理风向图片旋转 wf_translate: function () { $(".wf_translate").each(function () { $(this).rotate(parseInt($(this).attr("angle"))) }) //setTimeout(function () { // $(".wf_translate").each(function () { // $(this).rotate(parseInt($(this).attr("angle"))) // }) //}, 0); }, //地区筛选表格数据 shaixuan: function () { Awshour.createTable(); }, //表头-时次记录 listTable: function () { var type = Awshour.tiemList_P; var table = ""; switch (type) { case "eight": case "twenty": table += ""; table += ""; table += ""; table += ""; table += ""; table += ""; table += ""; break; case "MwMr": table += ""; table += ""; table += ""; table += ""; table += ""; table += ""; table += ""; table += ""; table += ""; table += ""; table += ""; table += ""; break; case "fr"://时雨量 table = "
LocationMinimum temperature
(℃)
Maximum temperature
(℃)
The max wind gust(m/s)rainfall(mm)
LocationMaximum temperatureTimeMinimum temperatureTimeWind DirectionThe max wind gust(m/s)The max wind timeRainfall(mm)Updated
"; table += "
Station name51015202530354045505560Total
" table += "
" break; default: table += ""; table += "Location"; table += "Air Temperature(℃)"; table += "Hourly Rainfall(mm)"; table += "Wind Direction"; table += "Wind Speed(m/s)"; table += ""; break; } if (type != 'fr') table += ""; return table; }, //tab 事件 zdMenu: function () { if (!$(".zdMenu li.type_3:first").hasClass('hover'))//图片才绑定天气元素切换 Awshour.zdMenu_2(); $(".zdMenu li.type_3").bind("click", function () { $("#cluetip").hide(); var mode = $(this).index() - 4; SetLocationHead("mode", mode); Awshour.ShowItemUrl(mode) jQuery(this).addClass("hover").siblings(".type_3").removeClass("hover"); if (jQuery(this).attr("rel") == "t")//表格 { $(".zdMenu2 li.type_2,.zdMenu2").hide(); $(".zdMenu2 li.type_2").removeClass("hover").unbind("click").css({ cursor: "auto" }).addClass("bgGray"); } else { //地图模式 $(".zdMenu2 li.type_2,.zdMenu2").show(); Awshour.zdMenu_2(); } }); Awshour.zdMenu_area(); Awshour.TabChang(); }, //天气类型选择 zdMenu_2: function () { $(".zdMenu2 li.type_2").unbind("click").css({ cursor: "pointer" }) var showItme = Awshour.mapShowItemStr(); $(".zdMenu2 li.type_2").each(function () { if (showItme.indexOf($(this).attr("val")) != -1) $(this).removeClass("bgGray"); }) $(".zdMenu2 li.type_2").bind("click", function () { var thisVal = jQuery(this).attr("val"); if (jQuery(this).hasClass("bgGray"))//当前不显示 { Awshour.mapShowImte.push(thisVal); jQuery(this).removeClass("bgGray"); } else { Awshour.mapShowImte.remove(thisVal); jQuery(this).addClass("bgGray"); } SetLocationHead("item", Awshour.mapShowItemStr()); //jQuery(this).addClass("hover").siblings(".type_2").removeClass("hover"); //切换对应气象类型 Awshour.createMap(); }); }, mapShowItemStr: function () { var showItemStr = ""; for (var i = 0; i < Awshour.mapShowImte.length; i++) { showItemStr += "," + Awshour.mapShowImte[i]; } showItemStr = showItemStr.length > 0 ? showItemStr.substring(1) : showItemStr; //console.log(showItemStr); return showItemStr }, //地区选择 zdMenu_area: function () { $(".zdMenu li.type_1").bind("click", function () { var curr_li = jQuery(this); curr_li.addClass("hover").siblings(".type_1").removeClass("hover"); curr_li.find("div").slideDown(); }); $(".zdMenu li.type_1").hover( function () { //$(this).find("span").show() }, function () { $(this).find(".zdsub").hide(); } ); var zdsubDiv = $(".zdMenu li.type_1 div"); zdsubDiv.find("a").bind("click", function () { jQuery(this).parents('ol').find('li').removeClass('hover'); jQuery(this).parent('li').addClass("hover") $(".zdMenu li.type_1 span").text(jQuery(this).text()); zdsubDiv.hide(); Awshour.cityArray.name = jQuery(this).attr("val"); Awshour.cityArray.index = jQuery(this).attr("rev"); SetLocationHead("sid", Awshour.cityArray.index); Awshour.shaixuan(); return false; }) }, //表格、图展现形式切换 TabChang: function () { jQuery(".zdzd").each(function () { var t = jQuery(this); if (t.length < 1) return; Tab_click(t.find('.zdMenu ul li.type_3'), t.find(".zdcon .tqCont")); }); }, //天气气象折线图 LineShow: function () { showItem = Awshour.mapShowItemStr(); $('.qwList span.stationName').cluetip({ hoverIntent: false, cluetipClass: "jtip", width: 640, height: 280, positionBy: "mouse", dropShadow: false, showTitle: true, sticky: true,//自动关闭 mouseOutClose: true, closeText:"关闭", ajaxSettings: { dataType: "json" }, storeAjaxData: true, onShow: function (C, A) { var divContent = "
    "; var divFoot = "
"; divFoot += "
"; divFoot += "
"; switch (Awshour.tiemList_P) { case "twenty": case "eight"://日记录 20、8时 if (showItem.indexOf("r") != -1) divContent += "
  • Rainfall
  • "; if (showItem.indexOf("t") != -1) { divContent += "
  • Maximum temperature
  • "; divContent += "
  • Minimum temperature
  • "; } if (showItem.indexOf("w") != -1) { divContent += "
  • Gust wind speed
  • "; divContent += "
  • The max wind gust
  • "; } divContent += divFoot; A.append(divContent); //绘制折线图 Awshour.LinePic_day(C.storeAjaxData, showItem); break; case "MwMr"://时极值、雨量 if (showItem.indexOf("r") != -1) divContent += "
  • Rainfall
  • "; if (showItem.indexOf("t") != -1) { divContent += "
  • Maximum temperature
  • "; divContent += "
  • Minimum temperature
  • "; } if (showItem.indexOf("w") != -1) { divContent += "
  • Gust wind speed
  • "; divContent += "
  • The max wind gust
  • "; } divContent += divFoot; A.append(divContent); //绘制折线图 Awshour.LinePic_MwMr(C.storeAjaxData, showItem); break; default: if (showItem.indexOf("r") != -1) divContent += "
  • Hour rainfall
  • "; if (showItem.indexOf("t") != -1){ divContent += "
  • Temperature
  • "; } if (showItem.indexOf("w") != -1) { divContent += "
  • Wind speed
  • "; divContent += "
  • Wind
  • "; } divContent += divFoot; A.append(divContent); //绘制折线图 Awshour.LinePic_hour(C.storeAjaxData, showItem); break; } //console.log(C.storeAjaxData[0]) } }) }, //表格奇偶行背景色 TableBgColor: function () { $(".sortTable tr:odd:not('.first')").css("background", "#f6f6f6"); $(".sortTable tr:even:not('.first')").css("background", "#fff"); }, //折线图 时次记录 LinePic_hour: function (data_json, showItem) { var hoursList = new Array();//x lable 时间序列 var t_max_Array = new Array();//最高气温数据 //var t_min_Array = new Array();//最低气温数据 var r_Array = new Array();//时雨量数据 var wf_Array = new Array();//风速数据 var wd_Array = new Array();//风向数据 $.each(data_json, function (index, content) { if (showItem.indexOf("t") != -1) { t_max_Array.push(content[0]); //t_min_Array.push(content[1]); } if (showItem.indexOf("r") != -1) r_Array.push(content[2]); if (showItem.indexOf("w") != -1) { wf_Array.push(content[4]); // wd_Array.push(content[3]); var _wf = !isNaN(content[4]) ? parseInt(content[4]) : 2; if (_wf > 40) _wf = "40g" else { _wf = _wf % 2 == 0 ? _wf : _wf + 1; _wf = _wf == 0 ? 2 : _wf; } wd_Array.push({ value: content[4], symbol: "images/wf/" + _wf + ".gif", symbolRotate: content[3] }); } }) var xlableStar = SubHours(25); for (var i = xlableStar.getHours() ; i < 24; i++) { hoursList.push(i); //for (var j = 0; j < 55; j += 5) { // hoursList.push(j == 0 ? i : j); //} } var currDate = new Date(); for (var i = 0; i <= currDate.getHours() ; i++) { hoursList.push(i == 0 ? currDate.getDate() + "日" : i); //for (var j = 0; j < 55; j += 5) { // hoursList.push(j == 0 ? i == 0 ? currDate.getDate() + "日" : i : j); //} } require.config({ paths: { echarts: 'Echarts/asset/js/echarts', 'echarts/chart/line': 'Echarts/asset/js/echarts-map', 'echarts/chart/bar': 'Echarts/asset/js/echarts-map' } }); option = { animation: false, tooltip: { show: false, trigger: 'axis' }, grid: { x: 30, y: 10, x2: 10, y2: 30 }, xAxis: [ { type: 'category', boundaryGap: true, axisTick: { show: false }, data: hoursList, axisLabel: { show: true, interval: 0 // {number} } } ], yAxis: [ { type: 'value', scale: true, splitNumber: 4, precision: 1, axisLabel: { formatter: '{value}' }, splitArea: { show: true } } ], series: [ { name: 'Temperature', type: 'line', symbol: 'none', itemStyle: { normal: { color: '#FE0000', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: t_max_Array }, //{ // name: 'Minimum temperature', // type: 'line', // symbol: 'none', // itemStyle: { // normal: { // color: '#6D3A6D', // lineStyle: { // shadowColor: 'rgba(0,0,0,0.4)' // } // } // }, // data: t_min_Array //} //, { name: 'Wind Speed', type: 'line', symbol: 'none', itemStyle: { normal: { color: '#999999', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: wf_Array }, { name: 'Wind Direction', type: 'line', smooth: true, symbol: 'images/wf/2.gif', // 系列级个性化拐点图形 symbolSize: 18, data: wd_Array }, { name: 'Hour rainfall', type: 'bar', symbol: 'none', itemStyle: { normal: { color: '#0101FF', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: r_Array } ] }; require( [ 'echarts', 'echarts/chart/line', 'echarts/chart/bar', ], function (ec) { var myChart = ec.init(document.getElementById('Awshour_LineMain')); myChart.setOption(option); } ) }, //折线图 日记录 LinePic_day: function (data_json, showItem) { var hoursList = new Array();//x lable 时间序列 var t_min_Array = new Array();//气温数据 var t_max_Array = new Array();//气温数据 var r_Array = new Array();//时雨量数据 var wf_Array = new Array();//风速数据 var wd_Array = new Array();//风向数据 $.each(data_json, function (index, content) { if (showItem.indexOf("t") != -1) { t_min_Array.push(content[0]); t_max_Array.push(content[1]); } if (showItem.indexOf("r") != -1) r_Array.push(content[4]); if (showItem.indexOf("w") != -1) { wf_Array.push(content[3]); // wd_Array.push(content[3]); var _wf = !isNaN(content[3]) ? parseInt(content[3]) : 2; if (_wf > 40) _wf = "40g"; else { _wf = _wf % 2 == 0 ? _wf : _wf + 1; _wf = _wf == 0 ? 2 : _wf; } wd_Array.push({ value: content[3], symbol: "images/wf/" + _wf + ".gif", symbolRotate: content[2] }); } }) var xlableStar = new Date(); var pnerDay = DayNumOfMonth(xlableStar.getFullYear(), xlableStar.getMonth());; for (var i = xlableStar.getDate() - 14 ; i <= xlableStar.getDate() ; i++) { if(i<0)//前一个月 { hoursList.push(pnerDay-Math.abs(i)); } else if (i == 0) { hoursList.push(pnerDay); } else { hoursList.push(i); } //hoursList.push(i); } require.config({ paths: { echarts: 'Echarts/asset/js/echarts', 'echarts/chart/line': 'Echarts/asset/js/echarts-map', 'echarts/chart/bar': 'Echarts/asset/js/echarts-map' } }); option = { animation: false, tooltip: { show: true, trigger: 'axis' }, grid: { x: 30, y: 10, x2: 10, y2: 30 }, xAxis: [ { type: 'category', boundaryGap: false, axisTick: { show: false }, data: hoursList, axisLabel: { show: true, interval: 0 // {number} } } ], yAxis: [ { type: 'value', scale: true, splitNumber: 4, precision: 1, axisLabel: { formatter: '{value}' }, splitArea: { show: true } } ], series: [ { name: 'Maximum temperature', type: 'line', symbol: 'none', itemStyle: { normal: { color: '#FE0000', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: t_max_Array }, { name: 'Minimum temperature', type: 'line', symbol: 'none', itemStyle: { normal: { color: '#6D3A6D', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: t_min_Array } , { name: 'Gust wind speed', type: 'line', symbol: 'none', itemStyle: { normal: { color: '#999999', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: wf_Array }, { name: 'The max wind gust', type: 'line', smooth: true, symbol: 'images/wf/2.gif', // 系列级个性化拐点图形 symbolSize: 18, data: wd_Array }, { name: 'Rainfall', type: 'bar', symbol: 'none', itemStyle: { normal: { color: '#0101FF', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: r_Array } ] }; require( [ 'echarts', 'echarts/chart/line', 'echarts/chart/bar', ], function (ec) { var myChart = ec.init(document.getElementById('Awshour_LineMain')); myChart.setOption(option); } ) }, //折线图 时极值、雨量 LinePic_MwMr: function (data_json, showItem) { var hoursList = new Array();//x lable 时间序列 var t_min_Array = new Array();//气温数据 var t_max_Array = new Array();//气温数据 var r_Array = new Array();//时雨量数据 var wf_Array = new Array();//风速数据 var wd_Array = new Array();//风向数据 $.each(data_json, function (index, content) { if (showItem.indexOf("t") != -1) { t_min_Array.push(content[0]); t_max_Array.push(content[1]); } if (showItem.indexOf("r") != -1) r_Array.push(content[4]); if (showItem.indexOf("w") != -1) { wf_Array.push(content[3]); // wd_Array.push(content[3]); var _wf = !isNaN(content[3]) ? parseInt(content[3]) : 2; if (_wf > 40) _wf = "40g" else { _wf = _wf % 2 == 0 ? _wf : _wf + 1; _wf = _wf == 0 ? 2 : _wf; } wd_Array.push({ value: content[3], symbol: "images/wf/" + _wf + ".gif", symbolRotate: content[2] }); } }) var xlableStar = new Date(); var tydHour=xlableStar.getHours(); for (var i = xlableStar.getHours() - 24 ; i <= xlableStar.getHours() ; i++) { if (i == 0) { hoursList.push(xlableStar.getDate() + "th"); xlableStar.setDate(xlableStar.getDate() - 1); } else if (i < 0) { hoursList.push(tydHour++); } else { hoursList.push(i); } } require.config({ paths: { echarts: 'Echarts/asset/js/echarts', 'echarts/chart/line': 'Echarts/asset/js/echarts-map', 'echarts/chart/bar': 'Echarts/asset/js/echarts-map' } }); option = { animation: false, tooltip: { show: true, trigger: 'axis' }, grid: { x: 30, y: 10, x2: 10, y2: 30 }, xAxis: [ { type: 'category', boundaryGap: true, axisTick: { show: false }, data: hoursList, axisLabel: { show: true, interval: 0 // {number} } } ], yAxis: [ { type: 'value', scale: true, splitNumber: 4, precision: 1, axisLabel: { formatter: '{value}' }, splitArea: { show: true } } ], series: [ { name: 'Maximum temperature', type: 'line', symbol: 'none', itemStyle: { normal: { color: '#FE0000', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: t_max_Array }, { name: 'Minimum temperature', type: 'line', symbol: 'none', itemStyle: { normal: { color: '#6D3A6D', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: t_min_Array } , { name: 'The max wind gust', type: 'line', symbol: 'none', itemStyle: { normal: { color: '#999999', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: wf_Array }, { name: 'Wind Direction', type: 'line', smooth: true, symbol: 'images/wf/2.gif', // 系列级个性化拐点图形 symbolSize: 18, data: wd_Array }, { name: 'rainfall', type: 'bar', symbol: 'none', itemStyle: { normal: { color: '#0101FF', lineStyle: { shadowColor: 'rgba(0,0,0,0.4)' } } }, data: r_Array } ] }; require( [ 'echarts', 'echarts/chart/line', 'echarts/chart/bar', ], function (ec) { var myChart = ec.init(document.getElementById('Awshour_LineMain')); myChart.setOption(option); } ) }, //遍历容器标识高低值颜色 TdValColor: function () { var type = Awshour.tiemList_P; switch (type) { case "eight": case "twenty": Awshour.TableMaxMinColor(".tqContent td.tmin", "red", "blue"); Awshour.TableMaxMinColor(".tqContent td.tmax", "red", "blue"); Awshour.TableMaxMinColor(".tqContent td.wfmax", "red", "blue"); Awshour.TableMaxMinColor(".tqContent td.rh", "red", "blue"); break; case "fr"://时雨量 for (var i = 0; i < 12; i++) { Awshour.TableMaxMinColor(".tqContent td.r"+i+"", "red", "blue"); } Awshour.TableMaxMinColor(".tqContent td.r_sum", "red", "blue"); break; case "MwMr": Awshour.TableMaxMinColor(".tqContent td.wfmax", "red", "blue"); Awshour.TableMaxMinColor(".tqContent td.rh", "red", "blue"); break; default://自动站时次记录 Awshour.TableMaxMinColor(".tqContent td.temp", "red", "blue"); Awshour.TableMaxMinColor(".tqContent td.rh", "red", "blue"); Awshour.TableMaxMinColor(".tqContent td.wf", "red", "blue"); } }, //标识最高最低值颜色 TableMaxMinColor: function (tdCtrl, maxColor, minColor) { var max = 0; var min = 1000; $(tdCtrl).each(function () { var t = parseFloat($(this).text()); if (t > max) { $(tdCtrl + ":[style='color: " + maxColor + ";']").css("color", "black") max = t; $(this).css("color", maxColor); } if (t < min) { $(tdCtrl + ":[style='color: " + minColor + ";']").css("color", "black") min = t; $(this).css("color", minColor); } }) } } var tab_1 = function (a, b) { var tab_1_p = $(a); var tab_1_s = $(b); tab_1_p.click(function () { if (!$(this).find("span").is(":visible")) { tab_1_s.hide(); $(this).find("span").slideDown(); } else { tab_1_s.hide(); } }) tab_1_s.children("a").click(function () { var text = $(this).text(); $(this).parent().prev("i").html(text); tab_1_s.hide(); return false; }) } //自动站类型切换 var awsTypeChang = function () { var lmenu_h2 = $(".Lmenu h2"); var lmenu_p = $(".Lmenu p"); lmenu_h2.live('click', function () { var curr_h2 = $(this); var next_p = curr_h2.next("p"); SetLocationHead("aws_p", curr_h2.index()); if (next_p.is(":visible")) {//显示状态 curr_h2.removeClass("down") next_p.hide(); } else { lmenu_p.hide(); lmenu_h2.removeClass("down") curr_h2.addClass("down") next_p.show(); } }) } function SubHours(hours) { //date = date.replace(/-/g, "/"); //更改日期格式 var nd = new Date(); nd = nd.valueOf(); nd = nd - hours * 60 * 60 * 1000; nd = new Date(nd); return nd; //alert(nd.getFullYear() + "年" + (nd.getMonth() + 1) + "月" + nd.getDate() + "日"); var y = nd.getFullYear(); var m = nd.getMonth() + 1; var d = nd.getDate(); var h = nd.getHours(); var mm = nd.getMinutes(); var ss = nd.getSeconds(); m = m <= 9 ? m = "0" + m : m; d = d <= 9 ? d = "0" + d : d; h = h <= 9 ? h = "0" + h : h; mm = mm <= 9 ? mm = "0" + mm : mm; ss = ss <= 9 ? ss = "0" + ss : ss; //var cdate = y + "-" + m + "-" + d +" "+h+":"+mm+":"+ss; var cdate = y + "/" + m + "/" + d + " " + h + ":00:00"; return cdate; //调用方法 (注意日期格式) //console.log(SubHours("2014/4/30 16:40:00",25)) } //获取月份天数 function DayNumOfMonth(Year, Month) { var d = new Date(Year, Month, 0); return d.getDate(); } Array.prototype.indexOf = function (val) { for (var i = 0; i < this.length; i++) { if (this[i] == val) return i; } return -1; }; Array.prototype.remove = function (val) { var index = this.indexOf(val); if (index > -1) { this.splice(index, 1); } };