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("
" + 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("" + 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 + '