var tmax_9 = new Array(); var tmin_9 = new Array(); var time_9 = new Array(); var date_week_9 = new Array(); $(function () { day10(); Foshorttime(); Titfodaily(); }); var _shikuangStation = { "G6808": ["禅城", "59828"], "G2288": ["南海", "59288"], "G2284": ["顺德", "59480"], "G7045": ["高明", "59829"], "G2289": ["三水", "59279"] };//站点名称 ///////////////////////////////////////////// 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("周日", "周一", "周二", "周三", "周四", "周五", "周六"); 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()] + "

\""
"); 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(); tenday(); } }) } function Foshorttime() { $.getJSON("/weather/data/wc_last.js?t=" + Math.random(), function (wc_lastJson) { $('.skNext').live('click', function () { var sk_zxs = $('.t_1 dl').hide(); var curr_sk_zxs = $(this).parents('dl.folo10d_sk').next('dl.folo10d_sk'); var index = curr_sk_zxs.index(); if (index == -1) { sk_zxs.stop(true, true).eq(0).fadeIn(); } else { curr_sk_zxs.stop(true, true).fadeIn(); } }) $.each(_shikuangStation, function (key, value) { $.getJSON("/weather/data/aws_inst_fo_" + key + ".js?t=" + Math.random(), function (json) { if (json) { var weaco = ""; var newJson = json[json.length - 1]; var firstJson = json[0]; var t = newJson.t; //气温 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 yubao_day1 = new Array(); var datetime = new Date(json[0].datetime.replace(/-/g, "/")); //转换成Data(); $.each(wc_lastJson, function (index, content) { if (key == content.sid) { weaco = content.wc; } }) var datetime = new Date(); var PeriodPath = "day"; if (datetime.getHours() >= 19 || datetime.getHours() < 7) PeriodPath = "night"; yubao_day1.push(""); $(".weather_2_c .t_1").append(yubao_day1.join('')); $("#foshorttime01:first").show(); } }); } }) }) }) return; $.getJSON("weather/data/foshorttime.js?t=" + Math.random(), function (json) { if (json) { $("#now_wd").html(json[0]["tmax"] + "°C"); $.each(_StationName, function (key, value) { var strcontent = ""; $.each(json, function (index, content) { var sid = content.stationid; if (key == sid) { var sname = value[0]; var valid_datetime = new Date(content.valid_datetime.replace(/-/g, "/")); //转换成Data(); //预报时间 var hoshInfo = "

" + content.efdate + ":" + content.ws + "," + content.wind + ",气温:" + Math.floor(content.tmin) + "-" + Math.floor(content.tmax) + "℃,相对湿度:" + content.hmin + "%-" + content.hmax + "%。

"; if (valid_datetime.getHours() == 20) { var issue_datetime = new Date(content.issue_datetime.replace(/-/g, "/")); //转换成Data(); //发布时间 strcontent += hoshInfo + "" + issue_datetime.Format("MM月dd日hh:mm") + " 分发布"; } else strcontent = hoshInfo + strcontent; } }) $("#foshorttime01 .weather_r").append(strcontent); }) } }) //old $.getJSON("/weather/data/aws_inst_fo_G2201.js?t=" + Math.random(), function (json) { if (json) { var newJson = json[json.length - 1]; var firstJson = json[0]; var t = newJson.t;//气温 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 yubao_day1 = new Array(); var datetime = new Date(json[0].datetime.replace(/-/g, "/")); //转换成Data(); yubao_day1.push("
气压:" + (p != "" ? p + "hPa" : "") + "
相对湿度:" + u + "%
"); yubao_day1.push("
风向:" + wd8[wd2][0] + "
"); yubao_day1.push("
风速:" + wf2 + " m/s
"); yubao_day1.push("
" + datetime.Format('dd日hh时') + "至今" + (r1h == "" ? "无雨量记录" : r1h + "(mm)") + "
"); $("#foshorttime01 .weather_l .gxcs").append(yubao_day1.join('')); } }) }; function Titfodaily() { $.getJSON("weather/data/fodaily.js?t=" + Math.random(), function (json) { if (json) { var datetime = new Date(json[0]["datetime"].replace(/-/g, "/")); //转换成Data(); $("#titfodaily").append("

" + json[0]["summary"] + "

" + json[0]["outlook"] + "

" + datetime.Format("MM月dd日hh时") + " 发布"); } }) }; //折线图-本地十天天气 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: 25, x2: 40, y2: 20, 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: '最高气温', type: 'line', itemStyle: { normal: { lineStyle: { shadowColor: 'rgba(0,0,0,0.0)' } } }, symbol: "circle", symbolSize: "2", itemStyle: { normal: { label: { show: true, textStyle: { fontSize: '12', fontFamily: '微软雅黑', color: '#7b7b7b' } } } }, data: tmax_9, tooltip: { // Series config. trigger: 'item', formatter: "最高气温:{c} ℃" } }, { name: '最低气温', type: 'line', itemStyle: { normal: { lineStyle: { shadowColor: 'rgba(0,0,0,0.0)' } } }, symbol: "circle", symbolSize: "2", itemStyle: { normal: { label: { show: true, textStyle: { fontSize: '12', fontFamily: '微软雅黑', color: '#7b7b7b' } } } }, data: tmin_9, tooltip: { // Series config. trigger: 'item', formatter: "最低气温:{c} ℃" } } ] }; require( [ 'echarts', 'echarts/chart/line' ], function (ec) { var myChart = ec.init(document.getElementById('weather_10')); myChart.setOption(option); } ) } //add by terry 20160106 function tenday() { var ten1 = []; var ten2 = []; for (var i = 0; i < tmax_9.length; i++) { ten1[i] = parseFloat(tmax_9[i]); ten2[i] = parseFloat(tmin_9[i]); } var chart; chart = new Highcharts.Chart({ chart: { renderTo: 'weather_10', //图表放置的容器,DIV defaultSeriesType: 'line', //图表类型line(折线图), zoomType: 'x', //x轴方向可以缩放 backgroundColor: 'rgba(0,0,0,0)' }, credits: { enabled: false //右下角不显示LOGO }, title: { text: '' //图表标题 }, tooltip: { //enabled: false, formatter: function () { return '' + this.series.name + '
' + this.y + '°C'; } }, subtitle: { text: '' //副标题 }, xAxis: { //x轴 title: { text: '' }, //标题 gridLineWidth: 0, //设置网格宽度为0 lineColor: 'rgba(0,0,0,0)', tickWidth: 0, labels: { enabled: false } }, yAxis: { //y轴 title: { text: '' }, //标题 gridLineWidth: 0, //设置网格宽度为0 labels: { enabled: false } }, colors: ['#f9a700'], plotOptions: { //设置数据点 line: { dataLabels: { enabled: true, //在数据点上显示对应的数据值 formatter: function () { return '' + this.y + ''; } } //enableMouseTracking: false //取消鼠标滑向触发提示框 } }, legend: { //图例 enabled: false }, exporting: { enabled: false //设置导出按钮不可用 }, series: [ { //数据列 name: '最高气温', data: ten1 } ] }); chart = new Highcharts.Chart({ chart: { renderTo: 'weather_101', //图表放置的容器,DIV defaultSeriesType: 'line', //图表类型line(折线图), zoomType: 'x', //x轴方向可以缩放 backgroundColor: 'rgba(0,0,0,0)' }, credits: { enabled: false //右下角不显示LOGO }, title: { text: '' //图表标题 }, tooltip: { //enabled: false, formatter: function () { return '' + this.series.name + '
' + this.y + '°C'; } }, subtitle: { text: '' //副标题 }, xAxis: { //x轴 title: { text: '' }, //标题 gridLineWidth: 0, //设置网格宽度为0 lineColor: 'rgba(0,0,0,0)', tickWidth: 0, labels: { enabled: false } }, yAxis: { //y轴 title: { text: '' }, //标题 gridLineWidth: 0, //设置网格宽度为0 labels: { enabled: false } }, colors: ['#6196ff'], plotOptions: { //设置数据点 line: { dataLabels: { enabled: true, //在数据点上显示对应的数据值 formatter: function () { return '' + this.y + ''; } } //enableMouseTracking: false //取消鼠标滑向触发提示框 } }, legend: { //图例 enabled: false }, exporting: { enabled: false //设置导出按钮不可用 }, series: [ { name: '最低气温', data: ten2 }] }); } //日期 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; }