<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="siteReview.aspx.cs" Inherits="WebApp.Wpdcc.siteReview" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>栏目活跃度</title>
    <meta name="description" content="栏目活跃度" />

	<!--#include file = "../assets/head.htm" -->
	<link rel="stylesheet" href="../assets/css/datepicker.css" />
	
</head>
<body class="no-skin">
    <form id="form1" runat="server">
    <div class="main-content-inner">
        <div class="page-content">
						<!-- /section:settings.box -->
                        <div class="page-header">
                            <h1>
								<asp:HyperLink ID="hlSite" runat="server" Target="_blank" ></asp:HyperLink>
								<small>
									<i class="ace-icon fa fa-angle-double-right"></i>
									查看信息
								</small>
							</h1>
						</div>
							
                        <div class="row">
							<div class="col-xs-12">
							    <div><h4>管理员密码安全度分析</h4></div>
							    <div id="chart2">
							    </div>
							</div>
					    </div>
					    
					    <div class="hr hr22 hr-dotted"></div>
					    
						<div class="row">
					        <div class="col-xs-4">
						            <div class="input-daterange input-group">
								        <input type="text" id="stime" class="input-sm form-control" name="start" />
								        <span class="input-group-addon">
									        <i class="fa fa-exchange"></i>
								        </span>
								        <input type="text" id="etime" class="input-sm form-control" name="end" />
							        </div>
							        <!-- /section:plugins/date-time.datepicker -->
					        </div>
					        <div>
						        <input type="button" id="btnSelect" class="btn btn-sm btn-primary" value="查询" />
                                <asp:HiddenField ID="HFak" runat="server" />
						    </div>
						</div>
					    
					    <div class="hr hr22 hr-dotted"></div>
					    
						<div class="row">
							<div class="col-xs-12">
								<!-- PAGE CONTENT BEGINS -->
								
								<div id="chart1" ></div>

								<!-- PAGE CONTENT ENDS -->
							</div><!-- /.row -->
						</div>
		</div><!-- /.page-content -->
		
	</div>
	<asp:HiddenField ID="HfFWCycle" runat="server" />
    </form>
    <!--#include file = "../assets/foot.htm" -->
    
    <!-- page js 图形化柱状图脚本 -->
    <script type="text/javascript" src="../assets/js/echarts.min.js"></script>
    
    <script type="text/javascript">
    
    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "/";
        
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate;
        return currentdate;
    }
    //根据当前的时间，获取某个周期之前的时间。
    function getCycleFormatDate(wcycle) {
        var today = new Date();
        var date = new Date(today.getTime()-wcycle * 24 * 3600 * 1000);
        var seperator1 = "/";
        
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate;
        return currentdate;
    }
    
    jQuery(function($) {
        
        //or change it into a date range picker 日历脚本
		$('.input-daterange').datepicker({autoclose:true});
		
		//加载运行监控图
	    function loadSiteBoard(stime,etime)
	    {
	         var a = $('#hlSite').attr("href");
	         var hfak = $('#HFak').val();
	         var sitename=$('#hlSite').text();//获取站点名称
             $.ajax({
                 type: "GET",
                 url: a+"/service/sitedataex.ashx",
                 data: {ak:hfak, code:"coltotal",dt1:stime, dt2:etime},
                 dataType: "json",
                 success: function(data){
                             $('#chart1').empty();   //清空Div1里面的所有内容
                             if(data.ret>0)
                             {
                                $('#chart1').html("code："+data.ret+" error："+data.msg);
                             }
                             else
                             {
                                if(data.coltotal == null )
                                {
                                    $('#chart1').html("没有查询到相关数据");
                                    return ;
                                }
                                
                                var i=1;//开始计数，用于计算图标高度
                                var h1="[";
                                var h2="[";
                                $.each(data.coltotal, function(index, content)
                                { 
                                    //hh=hh+"["+content.classnum+",'"+content.classname+"'],";
                                    i++;
                                    h1=h1+content.classnum+",";
                                    h2=h2+"'"+content.classname+"',";
                                });
                                
                                h1=h1.substring(0,h1.length-1);//去掉最后一个,字符
                                h1=h1+"]";
                                h2=h2.substring(0,h2.length-1);//去掉最后一个,字符
                                h2=h2+"]";
                                if(i==2)
                                {
                                    $("#chart1").height(120);
                                }
                                else
                                {
                                    //设置图表显示高度
                                    var h = parseInt( i * 50 , 10);
                                    $("#chart1").height(h);
                                }
                                
                                var hh1= eval("(" + h1 + ")");//由JSON字符串转换为JSON对象 
                                var hh2= eval("(" + h2 + ")");//由JSON字符串转换为JSON对象 
                                //$('#chart3').html("<object type=\"application/x-shockwave-flash\" style=\"outline:none;\" data=\"http://cdn.abowman.com/widgets/hamster/hamster.swf?\" width=\"210\" height=\"225\"><param name=\"movie\" value=\"http://cdn.abowman.com/widgets/hamster/hamster.swf?\"><param name=\"AllowScriptAccess\" value=\"always\"><param name=\"wmode\" value=\"opaque\"></object>");

                                //开始加载图表
                                
                                // 基于准备好的dom，初始化echarts实例
                                var myChart = echarts.init(document.getElementById('chart1'));
                                // 指定图表的配置项和数据
                                
                                var option = {
                                    title: {
                                        text: '栏目活跃度'
                                    },
                                    tooltip: {
                                        trigger: 'axis',
                                        axisPointer: {
                                            type: 'shadow'
                                        }
                                    },
                                    
                                    grid: {
                                        left: '3%',
                                        right: '4%',
                                        bottom: '3%',
                                        containLabel: true
                                    },
                                    xAxis: {
                                        type: 'value',
                                        boundaryGap: [0, 0.01]
                                    },
                                    yAxis: {
                                        type: 'category',
                                        data: hh2
                                    },
                                    series: [
                                        {
                                            name: '发文数',
                                            type: 'bar',
                                            data: hh1,
                                            itemStyle:{
                                                  normal:{color:'#1B6AAA'}
                                              }
                                        }
                                    ]
                                    
                                };
                                // 使用刚指定的配置项和数据显示图表。
                                myChart.setOption(option);                           
                             }
                          },
                  error: function ()
                  {
                     $('#chart1').empty();   //清空chart1里面的所有内容
                     $('#chart1').html("加载数据失败，请检查网络。");
                  }
             });
             
             //获取密码强弱等级
                    $.ajax({
                         type: "GET",
                         url: a+"/service/sitedataex.ashx",
                         data: {ak:hfak,code:"pwdlevel"},
                         dataType: "json",
                         success: function(data){
                                    $('#chart2').empty();   //清空Div1里面的所有内容
                                     
                                     if(data.ret>0)
                                     {
                                        $('#chart2').html("code："+data.ret+" error："+data.msg);
                                     }
                                     else
                                     {
                                        $('#chart2').html("<table class=\"table table-striped table-bordered table-hover\" style=\" width:500px;\"><thead><tr><th></th><th>高强度</th><th>中强度</th><th>低强度</th><th>无强度</th></tr></thead><tbody><tr><td>超级管理员</td><td>"+data.pwdlevel[0].admin_high+"</td><td>"+data.pwdlevel[0].admin_middle+"</td><td>"+data.pwdlevel[0].admin_low+"</td><td>"+data.pwdlevel[0].admin_unknown+"</td></tr><tr><td>普通管理员</td><td>"+data.pwdlevel[0].user_high+"</td><td>"+data.pwdlevel[0].user_middle+"</td><td>"+data.pwdlevel[0].user_low+"</td><td>"+data.pwdlevel[0].user_unknown+"</td></tr></tbody><tfoot></tfoot></table>");
                                     }
                                  },
                          error: function ()
                          {
                                $('#chart2').empty();   //清空chart1里面的所有内容
                                $('#chart2').html("加载数据失败，请检查网络。");
                          }
                     });
                     
    	}
	    
	    var wcycle = $('#HfFWCycle').val();//获取周期值。
		//加载运行监控图
		$("#stime").val(getCycleFormatDate(wcycle));
		$("#etime").val(getNowFormatDate());
		loadSiteBoard($("#stime").val(),$("#etime").val());
		
        $('#btnSelect').click(function(){
            loadSiteBoard($("#stime").val(),$("#etime").val());
        });
	});
	
    </script>
</body>
</html>