<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page import="java.lang.Integer"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<%
    com.cesgroup.cesmonitor.service.LoginUser user = com.cesgroup.cesmonitor.common.Util.getLoginUser();
			Integer myUserId = null;
			if (null != user) {
				myUserId = user.getUserid();
			}
%>
<script>var userId = "<%=myUserId%>"</script>


<div class="header-title-nobg table com-head">
	<div>
		<h1>资源监控</h1>
		<ul>
			<li>
				<button type="button" title="全屏" class="btnMaxMin btn-max"
					onclick="chartMaxScreen();">&nbsp;</button>
			</li>
		</ul>
	</div>
	<div class="borderClass"></div>
</div>



<div class="widget-placeholder" style="width: 100%;">
	<div class="table  widget-placeholder" style="width: 100%;">
		<div class="row">
			<div class="cell" id="resource-cell" style="width: 280px">
				<div class="dashbrd-widget" id="resourcebox_widget">
					<div class="dashbrd-widget-head cursor-move">
						<h4 id="resourcetabs_header">主机列表</h4>
					</div>

					<div class="body" id="resourcebox">
						<div class="ui-tabs" id="resourcetabs">
							<ul class="tabs-nav ui-tabs-nav">
								<li role="tab" id="tabcom"><a href="#computerList">按主机组</a></li>
								<li role="tab"><a href="#resourceList">按设备类型</a></li>
							</ul>

							<div id="computerList" class="ui-tabs-panel">
								<table class="list-table">
									<tbody id="testComputer">
										<c:choose>
											<c:when test="${!empty groups}">
												<c:forEach items="${groups}" var="groups">
													<tr data-id="p${groups.groupid}">
														<td><span class="tree-parent"><button
																	type="button" class="treeview">
																	<span id="arrow${groups.groupid}" class="arrow-right"></span>
																</button> <label>${groups.name}</label> <span class='sizeOutCls'></span>
														</span></td>
													</tr>
													<c:forEach items="${hostTypes}" var="hostTypes">
														<tr class="p${groups.groupid}"
															data-id="p${hostTypes.id}_${groups.groupid}"
															style="display: none;">
															<td><span
																class="tree-child hostBg hostBg${hostTypes.id}">
																	<button type="button" class="treeview ">
																		<span id="arrow${hostTypes.id}" class="arrow-right"></span>
																	</button> <label>${hostTypes.name}</label> <span class='sizeCls'></span>
															</span></td>
														</tr>
														<c:forEach items="${groups.hosts}" var="host">
															<c:choose>
																<c:when test="${host.host_type eq hostTypes.id}">
																	<tr class="p${hostTypes.id}_${groups.groupid}"
																		style="display: none;">
																		<td title="${host.name}"><span
																			class="tree-child2"> <a href="#"
																				onClick=hostDtailFun(this) id="${host.hostid}"
																				data-groupid="${groups.groupid}"> <c:choose>


																						<c:when test="${host.status eq 1}">
																							<span class="pot-grey"></span>
																							<label>${host.name}</label>
																						</c:when>

																						<%-- <c:when test="${host.highestAlarm eq 0}">
																								<span class="pot-grey"></span>
																								<label>${host.name}</label>
																							</c:when> --%>
																						<c:when test="${host.highestAlarm eq 1}">
																							<span class="pot-blue"></span>
																							<label>${host.name}</label>
																						</c:when>
																						<c:when test="${host.highestAlarm eq 2}">
																							<span class="pot-yellow"></span>
																							<label>${host.name}</label>
																						</c:when>
																						<c:when test="${host.highestAlarm eq 3}">
																							<span class="pot-saffron"></span>
																							<label>${host.name}</label>
																						</c:when>
																						<c:when test="${host.highestAlarm eq 4}">
																							<span class="pot-orange"></span>
																							<label>${host.name}</label>
																						</c:when>
																						<c:when test="${host.highestAlarm eq 5}">
																							<span class="pot-red"></span>
																							<label>${host.name}</label>
																						</c:when>

																						<%-- <c:when test="${host.state gt 0}">
																							<span class="pot-red"></span>
																							<label>${host.name}</label>
																						</c:when> --%>

																						<c:otherwise>
																							<span class="pot-green"></span>
																							<label>${host.name}</label>
																						</c:otherwise>


																					</c:choose>
																			</a>
																		</span></td>
																	</tr>
																</c:when>
															</c:choose>

														</c:forEach>
													</c:forEach>
												</c:forEach>
											</c:when>
											<c:otherwise>
												<tr>
													<td>请审查该用户对主机组的访问权限</td>
												</tr>
											</c:otherwise>
										</c:choose>
									</tbody>
								</table>
							</div>

							<div id="resourceList" class="ui-tabs-panel">
								<table class="list-table">
									<tbody id="testCpu">
										<c:choose>
											<c:when test="${!empty groups}">
												<c:forEach items="${hostTypes}" var="hostTypes">
													<tr data-id="p${hostTypes.id}">
														<td><span
															class="tree-parent hostBg hostBg${hostTypes.id}">
																<button type="button" class="treeview ">
																	<span id="arrow${hostTypes.id}" class="arrow-right"></span>
																</button> <label>${hostTypes.name}</label> <span
																class='sizeOutCls'></span>
														</span></td>
													</tr>
													<c:forEach items="${groups}" var="groups">
														<tr class="p${hostTypes.id}"
															data-id="p${groups.groupid}_${hostTypes.id}"
															style="display: none;">
															<td><span class="tree-child"><button
																		type="button" class="treeview">
																		<span id="arrow${groups.groupid}" class="arrow-right"></span>
																	</button> <label>${groups.name}</label> <span class='sizeCls'></span>
															</span></td>
														</tr>
														<c:forEach items="${groups.hosts}" var="host">
															<c:choose>
																<c:when test="${host.host_type eq hostTypes.id}">
																	<tr class="p${groups.groupid}_${hostTypes.id}"
																		style="display: none;">
																		<td title="${host.name}"><span
																			class="tree-child2"> <a href="#"
																				onClick=hostDtailFun(this)
																				data-groupid="${groups.groupid}" id="${host.hostid}">
																					<c:choose>
																						<c:when test="${host.status eq 1}">
																							<span class="pot-grey"></span>
																							<label>${host.name}</label>
																						</c:when>

																						<%-- <c:when test="${host.highestAlarm eq 0}">
																								<span class="pot-grey"></span>
																								<label>${host.name}</label>
																							</c:when> --%>
																						<c:when test="${host.highestAlarm eq 1}">
																							<span class="pot-blue"></span>
																							<label>${host.name}</label>
																						</c:when>
																						<c:when test="${host.highestAlarm eq 2}">
																							<span class="pot-yellow"></span>
																							<label>${host.name}</label>
																						</c:when>
																						<c:when test="${host.highestAlarm eq 3}">
																							<span class="pot-saffron"></span>
																							<label>${host.name}</label>
																						</c:when>
																						<c:when test="${host.highestAlarm eq 4}">
																							<span class="pot-orange"></span>
																							<label>${host.name}</label>
																						</c:when>
																						<c:when test="${host.highestAlarm eq 5}">
																							<span class="pot-red"></span>
																							<label>${host.name}</label>
																						</c:when>

																						<%-- <c:when test="${host.state gt 0}">
																							<span class="pot-red"></span>
																							<label>${host.name}</label>
																						</c:when> --%>

																						<c:otherwise>
																							<span class="pot-green"></span>
																							<label>${host.name}</label>
																						</c:otherwise>
																					</c:choose>
																			</a>
																		</span></td>
																	</tr>
																</c:when>
															</c:choose>

														</c:forEach>
													</c:forEach>
												</c:forEach>
											</c:when>
											<c:otherwise>
												<tr>
													<td>请审查该用户对主机组的访问权限</td>
												</tr>
											</c:otherwise>
										</c:choose>
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- 单个主机详细情况 -->
			<div class="cell .fadeRes" id="hostSide">
				<div class="overlay"></div>
				<div class="article article-main">
					<div class="header-title-nobg table">
						<div class="cell">
							<h1></h1>
						</div>
					</div>
					<div class="table widget-placeholder" style="width: 100%;">
						<div class="row">
							<div class="cell" style="width: 50%;">
								<div class="dashbrd-widget  dashbrd-widget-new"
									id="responseAndIcmppingLoss_widget">
									<div class="dashbrd-widget-head cursor-move">
										<h4>响应时间及丢包率</h4>
										<ul>
											<li>
												<button type="button" id="responseAndIcmppingLoss_icon"
													onclick='changeWidgetState(this, "responseAndIcmppingLoss", "");'
													class="btn-widget-collapse" title="宕机"></button>
											</li>
										</ul>
									</div>
									<div class="body" id="responseAndIcmppingLoss">
										<div class="loaddiv clearfix">
											<div id="container-responseTime"
												style="float: left; height: 200px; width: 50%"></div>
											<div id="container-icmppingLoss"
												style="float: left; height: 200px; width: 50%;"></div>
										</div>
									</div>
								</div>
							</div>

							<div class="cell" style="width: 50%;">
								<div class="dashbrd-widget  dashbrd-widget-new"
									id="cpuOnly_widget">
									<div class="dashbrd-widget-head">
										<h4>CPU使用率及内存使用率</h4>
										<ul>
											<li>
												<button type="button" id="cpuOnly_icon"
													onclick='changeWidgetState(this, "cpuOnly", "");'
													class="btn-widget-collapse" title="宕机"></button>
											</li>
										</ul>
									</div>
									<div class="body" id="cpuOnly">
										<div class="loaddiv clearfix">
											<div id="container-cpuOnly"></div>
											<div id="container-memoryOnly"></div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="table widget-placeholder" style="width: 100%;">
						<div class="row">
							<div class="cell">
								<div class="dashbrd-widget  dashbrd-widget-new"
									id="cpuUseRate_widget">
									<div class="dashbrd-widget-head">
										<h4>CPU使用率</h4>
										<ul>
											<li>
												<button type="button" id="cpuList_icon"
													onclick='changeWidgetState(this, "cpuUseRate", "");'
													class="btn-widget-collapse" title="宕机"></button>
											</li>
										</ul>
									</div>
									<div class="body" id="cpuList">
										<div class="iframeContent">
											<!-- <iframe src="" class="iframe" onload="loadIframe()"></iframe> -->
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="table widget-placeholder" style="width: 100%;">
						<div class="row">
							<div class="cell">
								<div class="dashbrd-widget  dashbrd-widget-new"
									id="memoryUseRate_widget">
									<div class="dashbrd-widget-head">
										<h4>內存使用率</h4>
										<ul>
											<li>
												<button type="button" id="memoryList_icon"
													onclick='changeWidgetState(this, "memoryUseRate", "");'
													class="btn-widget-collapse" title="宕机"></button>
											</li>
										</ul>
									</div>
									<div class="body" id="memoryList">
										<div class="iframeContentM">
											<!-- <iframe src="" class="iframe" onload="loadIframe()"></iframe> -->
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="table widget-placeholder" style="width: 100%;">
						<div class="row">
							<div class="cell">

								<div class="dashbrd-widget  dashbrd-widget-new"
									id="diskOnly_widget">
									<div class="dashbrd-widget-head">
										<h4>磁盘使用量</h4>
										<ul>
											<li>
												<button type="button" id="diskOnly_icon"
													onclick='changeWidgetState(this, "diskOnly", "");'
													class="btn-widget-collapse" title="宕机"></button>
											</li>
										</ul>
									</div>
									<div class="body" id="diskOnly">
										<table class="list-table2">
											<thead>
												<tr>
													<th>盘符</th>
													<th>总容量</th>
													<th>使用量</th>
													<th>空闲量</th>
													<th>&nbsp;</th>
													<th>操作</th>
												</tr>
											</thead>
											<tbody id="diskUsageInfo" class="ce-tbody">
											</tbody>
										</table>
									</div>
								</div>


								<div class="dashbrd-widget  dashbrd-widget-new"
									id="resourceAlarm_widget">
									<div class="dashbrd-widget-head">
										<h4>资源报警信息</h4>
										<ul>
											<li>
												<button type="button" id="resourceAlarm_icon"
													onclick='changeWidgetState(this, "resourceAlarm", "");'
													class="btn-widget-collapse" title="宕机"></button>
											</li>
										</ul>
									</div>
									<div class="body" id="resourceAlarm">
										<table class="list-table2" id="">
											<thead>
												<tr>
													<th>主机</th>
													<th width="30%">问题</th>
													<th>上次修改于</th>
													<th>历时</th>
													<th>信息</th>
													<!-- 			<th>确认</th> -->
													<th>动作</th>
													<!-- <th>状态</th> -->
												</tr>
											</thead>
											<tbody id="resourceAlarmInfo" class="ce-tbody">
											</tbody>
										</table>
									</div>
								</div>

								<div class="dashbrd-widget  dashbrd-widget-new"
									id="interfaceMessage_widget">
									<div class="dashbrd-widget-head">
										<h4>接口信息</h4>
										<ul>
											<li>
												<button type="button" id="interfaceMessage_icon"
													onclick='changeWidgetState(this, "interfaceMessage", "");'
													class="btn-widget-collapse" title="宕机"></button>
											</li>
										</ul>
									</div>
									<div class="body" id="interfaceMessage">
										<!-- 测试排序 -->
										<table class="list-table2" id="tb">
											<thead>
												<tr>
													<th width="10%">状态</th>
													<th width="30%">接口</th>
													<th class="thi1">进流量<span id="inSpan"></span></th>
													<th class="thi2">出流量<span id="outSpan"></span></th>

													<th>状态变更时间</th>
													<th>操作</th>

												</tr>
											</thead>
											<tbody id="interfaceInfo" class="ce-tbody">
											</tbody>
										</table>
									</div>
								</div>




							</div>
						</div>
					</div>

					<div class="table widget-placeholder last" style="width: 100%;">
						<div class="row">
							<div class="cell">
								<div class="dashbrd-widget dashbrd-widget-new"
									id="computerMessage_widget">
									<div class="dashbrd-widget-head">
										<h4>主机详细信息</h4>
										<ul>
											<li>
												<button type="button" id="computerMessage_icon"
													onclick='changeWidgetState(this, "computerMessage", "");'
													class="btn-widget-collapse" title="宕机"></button>
											</li>
										</ul>
									</div>
									<div class="body" id="computerMessage">
										<table class="list-table2">
											<tbody>
												<tr>
													<td><span>主机状态</span></td>
													<td>正常</td>
												</tr>
												<tr>
													<td><span>IP地址</span></td>
													<td>192.168.122.20</td>
												</tr>
												<tr>
													<td><span>操作系统</span></td>
													<td>win7</td>
												</tr>
												<tr>
													<td><span>主机名称</span></td>
													<td>&nbsp;</td>
												</tr>
												<tr>
													<td><span>描述</span></td>
													<td>micdir</td>
												</tr>

												<tr>
													<td><span>启动时间</span></td>
													<td>2017-06-02</td>
												</tr>
												<tr>
													<td><span>持续时间</span></td>
													<td>13</td>
												</tr>
											</tbody>
										</table>
									</div>
								</div>

							</div>
							<div class="cell">

								<div class="dashbrd-widget  dashbrd-widget-new"
									id="webmonitorOnly_widget">
									<div class="dashbrd-widget-head">
										<h4>web监控状态</h4>
										<ul>
											<li>
												<button type="button" id="webmonitorOnly_icon"
													onclick='changeWidgetState(this, "webmonitorOnly", "");'
													class="btn-widget-collapse" title="宕机"></button>
											</li>
										</ul>
									</div>
									<div class="body" id="webmonitorOnly">
										<table class="list-table2">
											<thead>
												<tr>
													<th>名称</th>
													<th>监测步骤</th>
													<th>最近检查时间</th>
													<th>状态</th>
													<th>操作</th>
												</tr>
											</thead>
											<tbody id="webMonitorInfo" class="ce-tbody">
											</tbody>
										</table>
									</div>
								</div>


							</div>

						</div>
					</div>

				</div>
			</div>
		</div>
	</div>
	<input type="hidden" id="hostid"
		value="<%=request.getParameter("hostid")%>" /> <input type="hidden"
		id="groupid" value="<%=request.getParameter("groupid")%>" /> <input
		type="hidden" id="dataId" value="<%=request.getParameter("dataId")%>" />
</div>
<script src="${ctx}/js/jquery.draggable.js"></script>
<script>
var open;
var isFilter;
getMenu();


function getMenu(){
	jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/getMenu.json",
		  async: false,
		  success:function(data) {
			 open = data;
			 isFilter=parseInt(data[0]);
			 
		  }
	});

} 
//var isFilter=1;
var timer,hideArry = [];
var localPosition;
var plug = true;
var refreshTime = getUserRefresh();
MMenu.def_label = 'cm';
/* refreshTime = getUserRefresh(); */

//三种跳转到监控总览的方式，全部修改为默认按主机展示
jQuery(document).ready(function() {
	jQuery("#sub_cm",".top-subnav-container").css("display","block");
	jQuery("#cm",".top-nav").addClass("selected");
	jQuery(".top-subnav li a").removeClass("selected");
	jQuery("#sub_cm>li:first-child>a").addClass("selected");
	var id=getUrl();
	if(id.urlId!="null" && id.dataId!="null" ){
		//从index 主页跳转过来 
		var flug=id.groupId.substr(0,1);
		if(flug=='p'){
			/* hostDtailFun(jQuery('#'+id.urlId));	
			jQuery("#resourceList").find("."+id.dataId).show();
			jQuery("#resourceList").find(".p"+id.groupId).show();
			jQuery("tr[data-id='p"+id.groupId+"']").find("button span").removeClass('arrow-right').addClass('arrow-down');
			jQuery("tr[data-id="+id.dataId+"]").find("button span").removeClass('arrow-right').addClass('arrow-down'); */
		    	jQuery("#tabcom").addClass('ui-tabs-active  ui-state-active');
	 			hostDtailFun(jQuery('#'+id.urlId));	
				jQuery("#computerList").find("."+id.dataId).show();
				jQuery("#computerList").find(".p"+id.groupId).show();
				jQuery("tr[data-id='p"+id.groupId+"']").find("button span").removeClass('arrow-right').addClass('arrow-down');
				jQuery("tr[data-id="+id.dataId+"]").find("button span").removeClass('arrow-right').addClass('arrow-down'); 
			
		}else{
		    jQuery("a[href='#resourceList']").parent('li').removeClass('ui-tabs-active');
		    jQuery("a[href='#computerList']").parent('li').addClass('ui-tabs-active');
			jQuery("#resourceList").hide();
			var computerList=jQuery("#computerList");
			computerList.show();
			computerList.css("display","block")
			computerList.find("."+id.groupId).show();
			computerList.find("."+id.dataId).show();
			var nowClick=jQuery("."+id.dataId,"#computerList").find("#"+id.urlId).parents("tr");
			nowClick.addClass('current');
			hostDtailFun(jQuery('#'+id.urlId)  );
			jQuery("tr[data-id="+id.groupId+"]").find("button span").removeClass('arrow-right').addClass('arrow-down');
			jQuery("tr[data-id="+id.dataId+"]").find("button span").removeClass('arrow-right').addClass('arrow-down');
			jQuery("#resourcetabs").tabs({
				create: function() { jQuery.cookie("tab", 0); },
				disabled: [],
				active: 1,
				activate: function(event, ui) {
					jQuery.cookie("tab", ui.newTab.index().toString());
				}
			})
			.css("visibility", "visible");
		}
		
	}else if(id.hostId!=undefined && id.hostId!=1){
		//从拓扑图跳转过来 
			var currentHost= jQuery('#'+id.hostId);
			hostDtailFun(currentHost);
			var currentHostClass=currentHost.parents('tr').attr('class');
			if(currentHostClass){
				var currentTree3=currentHost.parents('tr').attr('class').split(" ")[0];
				 jQuery("."+currentTree3).show();
				 var currentTree2=jQuery('tr[data-id='+currentTree3+']');
				 currentTree2.show();
				 currentTree2.find("button span").removeClass('arrow-right').addClass('arrow-down');
				 var allTree2=currentTree2.attr('class');
				 jQuery("."+allTree2).show();
				 jQuery("tr[data-id="+allTree2+"]").find("button span").removeClass('arrow-right').addClass('arrow-down');
		    }else{
		    	alert("未发现此主机状态数据")
		    }
			
		
	}else{
		//从其他页面跳转过来 
/* 		setTimeout(function(){
			var initEle=jQuery('#testCpu').find('tr');
			jQuery('#testCpu').find('tr:first-child button span').removeClass('arrow-right').addClass('arrow-down');
			var initId=initEle.find('a')[0];
			hostDtailFun(initId);
			var firstTr=jQuery('#testCpu').find('tr:first-child').attr('data-id').substr(1);
			var currentTree=jQuery("#resourceList").find(".current");
			currentTree.show();
			var currentBro=currentTree.attr("class").split(" ")[0];
			jQuery("#resourceList").find("."+currentBro).show();
			jQuery("#resourceList").find(".p"+firstTr).show();
			jQuery("tr[data-id="+currentBro+"]").find("button span").removeClass('arrow-right').addClass('arrow-down');
		    if(isFilter){
				addSum("resourceList");
			}
			
		},600);  */
		setTimeout(function(){
			var initEle=jQuery('#testComputer').find('tr');
			jQuery('#testComputer').find('tr:first-child button span').removeClass('arrow-right').addClass('arrow-down');
			var initId=initEle.find('a')[0];
			hostDtailFun(initId);
			var firstTr=jQuery('#testComputer').find('tr:first-child').attr('data-id').substr(1);
			var currentTree=jQuery("#computerList").find(".current");
			currentTree.show();
			var currentBro=currentTree.attr("class").split(" ")[0];
			jQuery("#computerList").find("."+currentBro).show();
			jQuery("#computerList").find(".p"+firstTr).show();
			jQuery("tr[data-id="+currentBro+"]").find("button span").removeClass('arrow-right').addClass('arrow-down');
		    if(isFilter){
				addSum("computerList");
			}
			
		},300);
	}
	
	localPosition = localStorage.getItem("localPosition");
	if(localPosition!=null){
		jQuery(".cellDrag").html("");
		initDragEle();
	}
	initMessages({});
	//读取全局设置
	getPageConfig();

	//收缩展开修改border-radius
	jQuery(".btn-widget-collapse").click(function(e) {
		var parents = jQuery(e.target).parents(".dashbrd-widget");
		if (jQuery(e.target).hasClass("btn-widget-expand")) {
			parents.css("border-bottom-left-radius",0)
			parents.css("border-bottom-right-radius",0)
		} else {
			parents.css("border-bottom-left-radius",'9px')
			parents.css("border-bottom-right-radius",'9px')
		}
	})
	addSize("resourceList");
	addSize("computerList");
	addSum("resourceList");
	addSum("computerList");
	addDot1("resourceList");
	addDot("computerList");
	var columnObj = jQuery('.cellDrag');
	if (columnObj.length > 0) {
		var widthOld;
		columnObj
			.sortable({
				connectWith: '.cellDrag',
				handle: 'div.dashbrd-widget-head',
				forcePlaceholderSize: true,
				placeholder: 'widgetDrag',
				tolerance: 'pointer',
				start: function(e, ui) {
					jQuery(ui.placeholder).addClass('dashbrd-widget-placeholder');
					jQuery(ui.item).addClass('dashbrd-widget-draggable');
					jQuery('.widget-placeholder .cell').css('min-width', '250px');
					columnObj.sortable('refreshPositions');
					widthOld = jQuery("#abnormalalarmstabox_widget ").parent().siblings().eq(1).outerWidth();
				},
				stop: function(e, ui) {
					jQuery(ui.placeholder).removeClass('dashbrd-widget-placeholder');
					jQuery(ui.item).removeClass('dashbrd-widget-draggable');
					jQuery('.widget-placeholder .cell').css('min-width', '');
					jQuery('.widget-placeholder .cell[style=""]').removeAttr('style');
					var groupname =localStorage.getItem("localAbnormalalarm");
					if(!groupname){
						groupname = jQuery("#groupsName li").children('.selected').attr('value');
					}
					//groupname = jQuery("#groupsName li").children('.selected').attr('value'); 
					if (ui.item.hasClass("abnormalalarmstabox_widget")) {
						loadpriorityCount(groupname);//饼图
						/* jQuery("#abnormalalarmstabox_widget ").width(widthOld); */
						initAlarmComparMonth(); //折线
					} else {
						initAlarmComparMonth();
						/* jQuery("#abnormalalarmstabox_widget ").width(widthOld); */
						loadpriorityCount(groupname);
					} 
				},
				update: function(e, ui) {
					if (!ui.sender) {
						var widgetPositions = {};
						jQuery('.cellDrag').each(function(colNum, column) {
							widgetPositions[colNum] = {};

							jQuery('.dashbrd-widget', column).each(function(rowNum, widget) {
								widgetPositions[colNum][rowNum] = widget.id;
							});
						});
						localStorage.setItem("localPosition",Object.toJSON(widgetPositions));
					}
				}
			});
	}

});
 /* function addSize(obj){
	//父节点加 数量 按设备类型 
	var parentTr = jQuery(".tree-parent", "#"+obj).parents("tr");
	//console.log(parentTr)
	jQuery(parentTr).each(function(i) {
		var classId = jQuery(parentTr[i]).attr("data-id");
		var treeChild= jQuery('.'+classId,"#"+obj);
		for(var k=0;k<treeChild.length;k++){
			var size=0;
			var class3 = jQuery(treeChild[k]).attr("data-id");
			var children=jQuery('.'+class3);
			for(var j=0;j<children.length;j++) {
				size++;
			}
			jQuery(treeChild[k]).find(".sizeCls").attr("data-size",size);
			jQuery(treeChild[k]).find(".sizeCls").html("("+size+")");
		} 
	})
}  */
 function addSize(obj){
	//列表中间层添加数量 
	var parentTr = jQuery(".tree-parent", "#"+obj).parents("tr");
	//console.log(parentTr)
	jQuery(parentTr).each(function(i) {
		var num=0;
		var classId = jQuery(parentTr[i]).attr("data-id");
		var treeChild= jQuery('.'+classId,"#"+obj);
		for(var k=0;k<treeChild.length;k++){
			var size=0;
			var redNum=0;
			var class3 = jQuery(treeChild[k]).attr("data-id");
			var children=jQuery('.'+class3,"#"+obj);
			for(var j=0;j<children.length;j++) {
				
				
				size++;
				var isRed1=jQuery(children[j],"#"+obj).find('a span').hasClass('pot-red');
				
				var isOrange=jQuery(children[j],"#"+obj).find('a span').hasClass('pot-orange');
				
				var isSaffron=jQuery(children[j],"#"+obj).find('a span').hasClass('pot-saffron');
				
				var isYelow=jQuery(children[j],"#"+obj).find('a span').hasClass('pot-yellow');
				
				var isBlue=jQuery(children[j],"#"+obj).find('a span').hasClass('pot-blue');
				
				if(isRed1 || isOrange||isSaffron ||isYelow || isBlue){
					redNum++;
				}
				
				
/* 				
				size++;
				var isRed1=jQuery(children[j],"#"+obj).find('a span').hasClass('pot-red'); */
				
				/* if(isRed1){
					redNum++;
				} */
			}
			
			if(isFilter){
				if(children.length==0){
					jQuery(treeChild[k]).css('display',"none");
					if(jQuery(treeChild[k])[0].style.display == "none"){
		                     num++
	                      }
					
				}else{
					jQuery(treeChild[k]).find(".sizeCls").html("("+redNum+"/"+size+")");
				}
			}else{
				jQuery(treeChild[k]).find(".sizeCls").html("("+redNum+"/"+size+")");
			}
			
			jQuery(treeChild[k]).find(".sizeCls").attr("data-size",size);
		} 
	})
} 
function addDot1(obj){
	//父节点加pot-red
	var parentTr = jQuery(".tree-child", "#"+obj).parents("tr");
	jQuery(parentTr).each(function(i) {
		var classId = jQuery(parentTr[i]).attr("data-id");
		var subId = classId.substr(1,classId.length);
		var	children = jQuery("#"+obj).find("."+classId);
		var colors=0;
		for(var j=0;j<children.length;j++) {
			//debugger
			
			if (jQuery(children[j]).find(".pot-red").length) {
				colors="red";
			}
			if (jQuery(children[j]).find(".pot-orange").length && colors !="red") {
				colors="orange";
			}
			if (jQuery(children[j]).find(".pot-saffron").length && colors !="orange" && colors !="red") {
				colors="saffron";
			}
			if (jQuery(children[j]).find(".pot-yellow").length && colors !="orange" && colors !="saffron" && colors !="red") {
				colors="yellow";
			}
			if (jQuery(children[j]).find(".pot-green").length && colors !="orange" && colors !="saffron" && colors !="yellow" && colors !="red") {
				colors="green";
			}
			
			
		
			/* if (jQuery(children[j]).find(".pot-red").length) {
				jQuery(parentTr[i]).find("label").prepend("<span class='pot-red parentPot'></span>")
				break;
			} */
			
		}
		jQuery(parentTr[i]).find("label").prepend("<span class='pot-"+colors+" parentPot'></span>");
		
		
/* 		if (jQuery(parentTr[i]).find(".pot-red").length < 1) {
			jQuery(parentTr[i]).find("label").prepend("<span class='pot-green parentPot'></span>")
		} */
	})
	
}
function addDot(obj){
	
	//父节点加pot-red 按主机组类型
	var parentTr = jQuery(".tree-parent", "#"+obj).parents("tr");
	jQuery(parentTr).each(function(i) {
		var classId = jQuery(parentTr[i]).attr("data-id");
		var treeChild= jQuery('.'+classId);
		var isRedIcon;
		var colors=0;
		for(var k=0;k<treeChild.length;k++){	
			var class3 = jQuery(treeChild[k]).attr("data-id");
			var children=jQuery('.'+class3);
			for(var j=0;j<children.length;j++) {
				
				if (jQuery(children[j]).find(".pot-red").length) {
					colors="red";
				}
				if (jQuery(children[j]).find(".pot-orange").length && colors !="red") {
					colors="orange";
				}
				if (jQuery(children[j]).find(".pot-saffron").length && colors !="orange" && colors !="red") {
					colors="saffron";
				}
				if (jQuery(children[j]).find(".pot-yellow").length && colors !="orange" && colors !="saffron" && colors !="red") {
					colors="yellow";
				}
				if (jQuery(children[j]).find(".pot-green").length && colors !="orange" && colors !="saffron" && colors !="yellow" && colors !="red") {
					colors="green";
				}
			}
		} 
		jQuery(parentTr[i]).find("label").prepend("<span class='pot-"+colors+" parentPot'></span>");
	})
}
function addSum(obj){
	var parentTr = jQuery(".tree-parent", "#"+obj).parents("tr");
	jQuery(parentTr).each(function(i) {
		var classId = jQuery(parentTr[i]).attr("data-id"),redNum = 0;
		var children = jQuery("."+classId,"#"+obj),sum = 0;
		jQuery(children).each(function(k){
			var number = Number(jQuery(".sizeCls",jQuery(children[k])).attr("data-size"));
			if(isFilter){
				if(number == 0){
					jQuery(children[k]).css("display","none");
				}
			}
			sum += number;
			var cls = jQuery(children[k]).attr("data-id");
			var arryChildren = jQuery("."+cls,"#"+obj);
			jQuery(arryChildren).each(function(m){
				
				

				var isRed=jQuery(arryChildren[m]).find("a>span").hasClass("pot-red")
				
				var isOrange=jQuery(arryChildren[m]).find("a>span").hasClass("pot-orange")
				
				var isSaffron=jQuery(arryChildren[m]).find("a>span").hasClass("pot-saffron")
				
				var isYelow=jQuery(arryChildren[m]).find("a>span").hasClass("pot-yelow")
				
				var isBlue=jQuery(arryChildren[m]).find("a>span").hasClass("pot-blue")
				
				
				if(isRed || isOrange || isSaffron|| isYelow || isBlue){
					redNum++
				} 
				
/* 				
				if(jQuery(arryChildren[m]).find("a>span").hasClass("pot-red")){
					redNum++;
				} */
				
			})
		})
		if(isFilter){
			if(sum==0){
				jQuery(parentTr[i]).find('span[class=arrow-right]').css('opacity',"0");
			}
		}
		jQuery(".sizeOutCls",jQuery(parentTr[i])).html("("+redNum+"/"+sum+")");
	})
}
function expandList(obj){
	var localExpand;
	var nowId=jQuery('#hostSide').find('h1').attr('data-id');
	var nowCenterClass=jQuery('#'+nowId,'#'+obj).parents('tr').attr('class').split(' ')[0];
	var nowCenterId=jQuery('tr[data-id='+nowCenterClass+']','#'+obj).attr('class');
	return localExpand = nowCenterId;
}
//手动打开cpu 内存 当前关注 磁盘 响应时间 设置弹框
function showDialog(obj){
	jQuery('#'+obj).modal('show');
	readlocalstorage(obj);
}

function resizeCharts(){
	var $alarm = jQuery('#alarmcomparisonbox_widget');
	var $Stati = jQuery('#abnormalalarmstabox_widget');

	if($alarm.css('display')=='block'){
		jQuery('#alarmComparison').hide()
		.css('width', $alarm.width() - 14 + 'px')
		.show().highcharts().reflow();
	}
	if($Stati.css('display')=='block'){
		jQuery('#abnormalAlarmStatistics').hide()
		.css('width', $Stati.width() + 'px')
		.show().highcharts().reflow();
	}
}
 jQuery(window).resize(function(){
	//resizeCharts();
	resizeModal();
}); 
function resizeModal(){
	var width = jQuery("header").width() - jQuery("#resource-cell").width() - 30;
	if(!jQuery("#hostSide").hasClass("modal-hide")){
		jQuery("#hostSide").find(".article").width(width);
	}
}
//定时任务
var time =  setInterval(function(){
	isLoaddata();
	refreshResourceList(); 
},refreshTime);


//切换拓扑图
function mapRefresh(event){
	event.stopPropagation();
	jQuery('.action-menu').hide();
	var $sysmap = jQuery('#sysmap');
	var $mapbox = jQuery("#mapbox_widget");
	var position = $mapbox.position();
	var width = $mapbox.width() - 60 - 150;
	if($sysmap.length >= 1){
		$sysmap.css({"left":(position.left + width)+"px","top":(position.top+30)+"px"});
		$sysmap.show();
		
	}else {
		loadSysmapInfo();
	}
	
};
//拓扑图最大化
function mapMax(event){
	event.stopPropagation();
	jQuery(".mainViewContent").css({
		"top":"5px",
		"right":0,
		"bottom":0
	})
	var height = jQuery(".mainViewContent").height()-60;
	var width = jQuery(".mainViewContent .row").innerWidth()-15;
	if(jQuery(event.target).hasClass("btn-widget-max")){
		jQuery('.cellDrag').sortable("option","disabled",true);
		jQuery("header").hide();
		jQuery(".footer").hide();
		jQuery("#mapbox_widget").parent().siblings().hide();
		jQuery("#mapbox_widget").siblings().hide();
	 	jQuery("#mapbox_widget").parent().css({
			"padding-bottom":0,
		}) 
		jQuery("#mapbox_widget").css("margin",0); 
	 	jQuery('.iframe').css("height",height); 
		jQuery("#mapbox_widget").find(".btn-widget-max").removeClass("btn-widget-max").addClass("btn-widget-min"); 
		jQuery("#mapbox_widget").data("type","max");
	}else{
		jQuery('.cellDrag').sortable("option","disabled",false);
		if(jQuery(".btnMaxMin").hasClass("btn-min")){
			jQuery(".mainViewContent").css({
				"top":"62px",
			    "bottom":0
			});
		}else{
			jQuery(".mainViewContent").css({
				"top":"170px",
				"right":"5px",
				"bottom":"30px"
			})
		}
		jQuery("header").show();
		jQuery(".footer").show();
		jQuery("#mapbox_widget").css({
			"margin-top":0,
			"margin-left":0,
			"margin-right":"10px",
			"margin-bottom":"10px"
		});
	 	jQuery('.iframe').css("height","550px"); 
		jQuery("#mapbox_widget").parent().siblings().show();
		jQuery("#mapbox_widget").siblings().show();
		jQuery("#mapbox_widget").find(".btn-widget-min").removeClass("btn-widget-min").addClass("btn-widget-max");
	}
}
jQuery('body').on('click','#sysmap li',function(event){
	event.stopPropagation();
	jQuery(this).children('a').addClass('selected');
	jQuery(this).siblings().children('a').removeClass('selected');
	var tempId = jQuery(this).children('.selected').attr('value');
	var change = jQuery("#mapbox_widget").data("type");
	jQuery.ajax({
		  method: "POST",
		  data:{
			sysmapId:tempId
		  },
		  url: "${ctx}/overview/saveSysmapId.json",
		  success:function(data) {
		
		  }
	  });
	mapInit(tempId,change);
	jQuery('.action-menu').hide();
});

jQuery('body').click(function(event){
	event.stopPropagation();
	jQuery('.action-menu').hide();
});
//pc
function abnormalalarmsRefresh(event){
	if(event != null){event.stopPropagation()};
	jQuery('.action-menu').hide();
	var $groupsName = jQuery('#groupsName'),groupname;
	var $abnormalalarmstabox = jQuery("#abnormalalarmstabox_widget");
	var position = $abnormalalarmstabox.position();
	var width = $abnormalalarmstabox.width() - 60 - 150;
	if($groupsName.length >= 1){
		$groupsName.css({"left":(position.left + width)+"px","top":(position.top+30)+"px"});
		groupname =localStorage.getItem("localAbnormalalarm");
		if(groupname){
			var $target = jQuery("#groupsName li a[value='"+groupname+"']");
			$target.addClass('selected');
			$target.parent().siblings().children('a').removeClass('selected');
		}else{
			groupname = jQuery("#groupsName li").children('.selected').attr('value');
		}
		$groupsName.show();
	}else {
		var groupname =localStorage.getItem("localAbnormalalarm");
		if(groupname){
			var $target = jQuery("#groupsName li a[value='"+groupname+"']");
			$target.addClass('selected');
			$target.parent().siblings().children('a').removeClass('selected');
		}else{
			groupname = jQuery("#groupsName li").children('.selected').attr('value');
		}
		loadpriorityCount(groupname);
	}
}
var localAbnormalalarm;
var localcputype,localcpulimit,localcpubignum,localcpusmallnum;
var localdisktype,localdisklimit,localdiskbignum,localdisksmallnum;
var localmemorytype,localmemorylimit,localmemorybignum,localmemorysmallnum;
var localresponsetimetype,localresponsetimelimit;
jQuery('#testCpu tr').bind('click',function(event){
	event.stopPropagation();
	var groupId = jQuery(event.target).parents("tr").data("id");
	if (groupId) {
		groupId = groupId.substring(1,groupId.length);
		var obj = jQuery(event.target).parents("tr").find(".treeview");
		arrowClick(obj,groupId);
	}
})
jQuery('#computerList tr').bind('click',function(event){
	event.stopPropagation();
	var groupId = jQuery(event.target).parents("tr").data("id");
	if (groupId) {
		groupId = groupId.substring(1,groupId.length);
		var obj = jQuery(event.target).parents("tr").find(".treeview");
		arrowClick(obj,groupId);
	}
})
jQuery('body').on('click','#groupsName li',function(event){
	event.stopPropagation();
	jQuery(this).children('a').addClass('selected');
	jQuery(this).siblings().children('a').removeClass('selected');
	var groupname = jQuery(this).children('.selected').attr('value');
	loadpriorityCount(groupname);
	localAbnormalalarm =localStorage.setItem("localAbnormalalarm",groupname);
	jQuery('.action-menu').hide();
});
function isLoaddata() {
	//localstorage cpu
	localcputype = localStorage.getItem("localcputype");
	localcpulimit = localStorage.getItem("localcpulimit");
	localcpubignum = localStorage.getItem("localcpubignum");
	localcpusmallnum = localStorage.getItem("localcpusmallnum");
	if(localcputype != null){
		jQuery('#cpuorder').val(localcputype);
	}
	if(localcpulimit != null){
		jQuery('#cpulimit').val(localcpulimit);
	}
	if(localcpubignum != null){
		jQuery('#cpubignum').val(localcpubignum);
	}
	if(localcpusmallnum != null){
		jQuery('#cpusmallnum').val(localcpusmallnum);
	}
	//localstorage memory
	localmemorytype = localStorage.getItem("localmemorytype");
	localmemorylimit = localStorage.getItem("localmemorylimit");
	localmemorybignum = localStorage.getItem("localmemorybignum");
	localmemorysmallnum = localStorage.getItem("localmemorysmallnum");
	if(localmemorytype != null){
		jQuery('#memoryorder').val(localmemorytype);
	}
	if(localmemorylimit != null){
		jQuery('#memorylimit').val(localmemorylimit);
	}
	if(localmemorybignum != null){
		jQuery('#memorybignum').val(localmemorybignum);
	}
	if(localmemorysmallnum != null){
		jQuery('#memorysmallnum').val(localmemorysmallnum);
	}
	//localstorage disk
	localdisktype = localStorage.getItem("localdisktype");
	localdisklimit = localStorage.getItem("localdisklimit");
	localdiskbignum = localStorage.getItem("localdiskbignum");
	localdisksmallnum = localStorage.getItem("localdisksmallnum");
	if(localdisktype != null){
		jQuery('#diskorder').val(localdisktype);
	}
	if(localdisklimit != null){
		jQuery('#disklimit').val(localdisklimit);
	}
	if(localdiskbignum != null){
		jQuery('#diskbignum').val(localdiskbignum);
	}
	if(localdisksmallnum != null){
		jQuery('#disksmallnum').val(localdisksmallnum);
	}
	//localstorage responsetime
	localresponsetimetype = localStorage.getItem("localresponsetimetype");
	localresponsetimelimit = localStorage.getItem("localresponsetimelimit");
	if(localresponsetimetype != null){
		jQuery('#responsetimeorder').val(localresponsetimetype);
	}
	if(localresponsetimelimit != null){
		jQuery('#responsetimelimit').val(localresponsetimelimit);
	}
	if(jQuery('#mapbox_widget').css('display') == "block"){
		loadSysmapInfo();
	}
	if(jQuery('#abnormalalarmstabox_widget').css('display') == "block"){
		//初始异常告警统计数据
		abAlarmChoose();
	/* 	setTimeout(function(){
			var groupname = jQuery("#groupsName li").children('.selected').attr('value');
			loadpriorityCount(groupname);
		},1500) */
		//jQuery("#abnormalalarmstabox").change(function(){loadpriorityCount();})
	}
	if(jQuery('#cpubodybox_widget').css('display') == "block"){
		loadCpuRate();
	}
	if(jQuery('#memorybodybox_widget').css('display') == "block"){
		 loadMemoryRate();
	} 
	if(jQuery('#diskbodybox_widget').css('display') == "block"){
		loadDiskRate();
	}
		
	if(jQuery('#responsetimebodybox_widget').css('display') == "block"){
		loadResponseTime();
	}
		
	if(jQuery('#currentNoticeBox_widget').css('display') == "block"){
		if(!jQuery("#currentNoticeSetting_Dialog").hasClass("in")){
			var info_obj = getstringofcurrent();
			debugger;
			loadcurrentFocus(objOfValueToArr(info_obj)); 
		}
		//将对象转换为数组
	}
	if(jQuery('#alarmcomparisonbox_widget').css('display') == "block"){
		loadMonthAlarmNum();
	}
}

//兑换转换数组
function objOfValueToArr(object) {
	var arr = [];
	var i = 0;
	if(object == ''){
		arr = '';
	}else{
		for (var item in object) {
	    	arr[i] = object[item];
	    	i++;
		}
	}    
	return arr;
}


function loadCpuRate(value){
	var type=jQuery("#cpuorder").val();
	var limit=jQuery("#cpulimit").val();	
	var bignum = jQuery("#cpubignum").val();
	var smallnum = jQuery("#cpusmallnum").val();
	validate('cpuSetting_Dialog');
	
	if(parseInt(bignum) <= parseInt(smallnum) || bignum == "" || smallnum == ""){
		$.MsgBox.Alert("消息","请输入正确区间范围");
		return false;
	}
	if(type=='desc'){
		jQuery("#cpubodybox_header").html('TOP'+limit+' CPU使用率-前'+limit+'位排行');
	}else{
		jQuery("#cpubodybox_header").html('TOP'+limit+' CPU使用率-后'+limit+'位排行');
	}
	jQuery("#cputbody").html('<tr><td colspan="2"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>');
	
	//localstorage
	localStorage.setItem("localcputype", type);
	localStorage.setItem("localcpulimit", limit);
	localStorage.setItem("localcpubignum", bignum);
	localStorage.setItem("localcpusmallnum", smallnum);
	if (value) {
	jQuery('#cpuSetting_Dialog').modal('hide');
	}
	jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/hostsCpu.json",
		  data: {
				order:type,
			  	limit:limit
		  },
		  success:function(data) {
			  jQuery('.loadingindex').hide();
			  if(data.length<=0){
				  jQuery("#cputbody").html('<tr><td>未发现任何数据</td></tr>');
			  }else{
					  var temp=[];
					  if(type=='desc'){
						  for(var i=data.length-1;i>=0;i--){
							  var j=data[i];
							  var host=j.hostName;
							  var rate=j.cpuRate;
							  temp.push( '<tr><td>'+host+'</td><td><span class="'+(rate>bignum?'red':rate>smallnum?'green':'grey')+'">'+(rate+'%')+'</span></td></tr>')
						  }
					  }else{
						  for(var i=0;i<data.length;i++){
							  var j=data[i];
							  var host=j.hostName;
							  var rate=j.cpuRate;
							  temp.push( '<tr><td>'+host+'</td><td><span class="'+(rate>bignum?'red':rate>smallnum?'green':'grey')+'">'+(rate+'%')+'</span></td></tr>')
						   }
					  }
					  temp=temp.join("");
					  jQuery("#cputbody").html(temp);
			  }
		  }
	  });
}

function loadDiskRate(value){
	type=jQuery("#diskorder").val();
	limit=jQuery("#disklimit").val();
	bignum=jQuery("#diskbignum").val();
	smallnum=jQuery("#disksmallnum").val();
	validate('diskSetting_Dialog');
	if(parseInt(bignum) <= parseInt(smallnum) || bignum == "" || smallnum == ""){
		$.MsgBox.Alert("消息","请输入正确区间范围");
		return false;
	}
	
	if(type=='desc'){
		jQuery("#diskbodybox_header").html('TOP'+limit+' 磁盘使用率-后'+limit+'位排行');
	}else{
		jQuery("#diskbodybox_header").html('TOP'+limit+' 磁盘使用率-前'+limit+'位排行');
	}
	
	jQuery("#disktbody").html('<tr><td colspan="2"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>');
	//localstorage
	localStorage.setItem("localdisktype", type);
	localStorage.setItem("localdisklimit", limit);
	localStorage.setItem("localdiskbignum", bignum);
	localStorage.setItem("localdisksmallnum", smallnum);
	if(value) {
		jQuery('#diskSetting_Dialog').modal('hide');
	}
	 jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/hostsDisk.json",
		  data: {
				order:type,
			  	limit:limit
		  },
		  success:function(data) {
			  //jQuery('.loadingindex').hide();
			  if(data.length<=0){
				  jQuery("#disktbody").html('<tr><td>未发现任何数据</td></tr>');
			  }else{
			      	var temp=[];
			      	if(type=='desc'){//降序
			      		for(var i=data.length-1;i>=0;i--){
			      		  var j=data[i];
						  var host=j.hostName;
						  var rate=j.diskRate;
						  var driver = j.itemName;
						  //temp.push('<tr><td>'+host+'</td><td>'+'<span class="'+(rate>bignum?'red':rate>smallnum?'green':'grey')+'">'+(rate+'%')+'</span></td></tr>')
						  temp.push('<tr><td>'+host +'(' + driver + ')' +'</td><td>'+'<span class="'+(rate>bignum?'red':rate>smallnum?'green':'grey')+'">'+(rate+'%')+'</span></td></tr>')
			      		}
			      	}else{//升序 
			      		 for(var i=0;i<data.length;i++){
							  var j=data[i];
							  var host=j.hostName;
							  var rate=j.diskRate;
						      var driver = j.itemName;
							  //temp.push('<tr><td>'+host+'</td><td>'+'<span class="'+(rate>bignum?'red':rate>smallnum?'green':'grey')+'">'+(rate+'%')+'</span></td></tr>')
							  temp.push('<tr><td>'+host+'(' + driver + ')'+'</td><td>'+'<span class="'+(rate>bignum?'red':rate>smallnum?'green':'grey')+'">'+(rate+'%')+'</span></td></tr>')
						   }
			      	}
					  temp=temp.join("");
					  jQuery("#disktbody").html(temp);
					  jQuery('.loadingindex').hide();
			  }
		  }
	  });
}


function loadResponseTime(){
	jQuery("#responsetimetbody").html('<tr><td colspan="2"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>');
	type=jQuery("#responsetimeorder").val();
	limit=jQuery("#responsetimelimit").val();
	if(type=='desc'){
		jQuery("#responsetimebodybox_header").html('TOP'+limit+' 响应时间-前'+limit+'位排行');
	}else{
		jQuery("#responsetimebodybox_header").html('TOP'+limit+' 响应时间-后'+limit+'位排行');
	}
	//localstorage
	localStorage.setItem("localresponsetimetype", type);
	localStorage.setItem("localresponsetimelimit", limit);
	
	  jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/responseTime.json",
		  data: {
			  	order:type,
			  	limit:limit
		  },
		  success:function(data) {
			  //jQuery('.loadingindex').hide();
			  if(data.length<=0){
				  jQuery("#responsetimetbody").html('<tr><td>未发现任何数据</td></tr>');
			  }else{
				      var temp=[];
				      if(type=='desc'){
				    	  for(var i=data.length-1;i>=0;i--){
				    		  var j=data[i];
							  var hostName=j.hostName;
							  var responseTime= (parseFloat(j.responseTime * 1000)).toFixed(2);
							   temp.push('<tr><td>'+hostName+'</td><td>'+'<span class="green">'+responseTime+'ms</span></td></tr>')
				    	  }
				      }else{
				    	  for(var i=0;i<data.length;i++){
						     var j=data[i];
							 var hostName=j.hostName;
							 var responseTime= (parseFloat(j.responseTime * 1000)).toFixed(2);
							 temp.push('<tr><td>'+hostName+'</td><td>'+'<span class="green">'+responseTime+'ms</span></td></tr>')
						  }  
				      }
					  temp=temp.join("");
					  jQuery("#responsetimetbody").html(temp);
					  jQuery('.loadingindex').hide();
			  }
		  }
	  });
} 
	function refreshResourceList(){
		var isResource = true,dataId;
		if(jQuery("#resourceList").css("display") == "block"){
			var localResourceExpand = expandList("resourceList");
			var children = jQuery("#resourceList").find("."+localResourceExpand);
			for(var j=0;j<children.length;j++) {
				
				var childId=jQuery(children[j]).attr("data-id");
				var tree3=jQuery("#resourceList").find("."+childId);
				for(var k=0;k<tree3.length;k++){
					if(jQuery(tree3[k]).hasClass("current")){
						dataId = jQuery(tree3[k]).find("a").attr("id");
					}else{
						dataId=jQuery('#hostSide').find('h1').attr('data-id');
					}
				 }
				
			}
			isResource = true;
		}
		if(jQuery("#computerList").css("display") == "block"){
			var localCompExpand = expandList("computerList");
			var children = jQuery("#computerList").find("."+localCompExpand);
			for(var j=0;j<children.length;j++) {
				var childId=jQuery(children[j]).attr("data-id");
				var tree3=jQuery("#computerList").find("."+childId);
				for(var k=0;k<tree3.length;k++){
					if(jQuery(tree3[k]).hasClass("current")){
						dataId = jQuery(tree3[k]).find("a").attr("id");
					}else{
						dataId=jQuery('#hostSide').find('h1').attr('data-id');
					}
				 }
			}
			isResource = false;
		}
		//jQuery("#testCpu").html("");
		//jQuery("#testComputer").html("");
		var listHtml = "",computerListHtml="";
		jQuery.ajax({
			method:"POST",
			url:"${ctx}/formview/index.json",
			success:function(data){
			 	var listHosts = data.listHosts; 
				var groups = data.groups;
				var hostTypes=data.hostTypes;
				if(hostTypes){//按资源类型数据渲染 
					for(var i = 0;i<= hostTypes.length - 1;i++){
						listHtml +="<tr data-id='p"+hostTypes[i].id+"'><td><span class='tree-parent hostBg hostBg"+hostTypes[i].id+"'><button type='button' class='treeview '>";
						listHtml +="<span id='arrow"+hostTypes[i].id+"' class='arrow-right'></span></button>";
						if(hostTypes[i].id == null){
							listHtml +="<label>"+hostTypes[i].name+"</label>";
						}else{
							listHtml +="<label>"+hostTypes[i].name +"</label>";
						}
						listHtml +="<span class='sizeOutCls'></span>";//增加父节点數量  
						listHtml += "</span></td></tr>";
						if(groups!=null){
							for(var j = 0; j <= groups.length - 1;j++){
								var host = groups[j].hosts;
								listHtml +="<tr class='p"+hostTypes[i].id+"' data-id='p"+groups[j].groupid+"_"+hostTypes[i].id+"' style='display:none'><td><span class='tree-child'><button type='button' class='treeview'>";
								listHtml +="<span id='arrow"+groups[j].groupid+"' class='arrow-right'></span></button>";
								if(hostTypes[i].id == null){
									listHtml +="<label>"+groups[j].name+"</label>";
								}else{
									listHtml +="<label>"+groups[j].name +"</label>";
								}
								listHtml += "<span class='sizeCls'></span>";
								listHtml += "</span></td></tr>";
								for(var k = 0; k <= host.length - 1;k++){
									if(host[k].host_type == hostTypes[i].id){
										listHtml +=  "<tr class='p"+groups[j].groupid+"_"+hostTypes[i].id+"' style='display:none'><td title='"+host[k].name+"'><span class='tree-child2'>";
										listHtml +="<a href='#' data-groupid="+groups[j].groupid+" onClick='hostDtailFun(this);' id='"+host[k].hostid+"'>";
										if(host[k].status == 1){
											listHtml +="<span class='pot-grey'></span><label>"+host[k].name+"</label>";
										}else if(host[k].state > 0){
											//debugger
											if(host[k].highestAlarm == 0){
												listHtml +="<span class='pot-red'></span><label>"+host[k].name+"</label>"
											}else if(host[k].highestAlarm == 1){
												listHtml +="<span class='pot-blue'></span><label>"+host[k].name+"</label>"
											}else if(host[k].highestAlarm == 2){
												listHtml +="<span class='pot-yellow'></span><label>"+host[k].name+"</label>";
											}else if(host[k].highestAlarm == 3){
												listHtml +="<span class='pot-saffron'></span><label>"+host[k].name+"</label>";
											}else if(host[k].highestAlarm == 4){
												listHtml +="<span class='pot-orange'></span><label>"+host[k].name+"</label>";
											}else if(host[k].highestAlarm == 5){
												listHtml +="<span class='pot-red'></span><label>"+host[k].name+"</label>";
											}
											
											
											//listHtml +="<span class='pot-red'></span><label>"+host[k].name+"</label>"
										}else{
											listHtml +="<span class='pot-green'></span><label>"+host[k].name+"</label>";
										}
									}
									listHtml +="</a></span></td></tr>";
								}
							}
						}
					}
				}else{
					listHtml +="<tr><td>请审查该用户对主机组的访问权限</td></tr>";
				}
				if(groups){
					for(var i = 0;i<= groups.length - 1;i++){
						var groupsId=groups[i].groupid;
						computerListHtml +="<tr data-id='p"+groupsId+"'><td><span class='tree-parent'><button type='button' class='treeview'>";
						computerListHtml +="<span id='arrow"+groupsId+"' class='arrow-right'></span></button>";
						computerListHtml +="<label>"+groups[i].name+"</label>";
						computerListHtml +="<span class='sizeOutCls'></span>";//增加父节点數量  
						computerListHtml +="</span></td></tr>";
						if(hostTypes!=null){
							for(var j = 0; j <= hostTypes.length - 1;j++){
								var host = groups[i].hosts;
								computerListHtml +="<tr class='p"+groupsId+"' data-id='p"+hostTypes[j].id+"_"+groupsId+"' style='display:none'><td><span class='tree-child hostBg hostBg"+hostTypes[j].id+"'><button type='button' class='treeview '>";
								computerListHtml +="<span id='arrow"+hostTypes[j].id+"' class='arrow-right'></span></button>";
								computerListHtml +="<label>"+hostTypes[j].name+"</label>";
								computerListHtml += "<span class='sizeCls'></span>";
								computerListHtml += "</span></td></tr>";
								for(var k = 0; k <= host.length - 1;k++){
									if(host[k].host_type == hostTypes[j].id){
										computerListHtml +="<tr class='p"+hostTypes[j].id+"_"+groupsId+"' style='display:none'><td title='"+host[k].name+"'><span class='tree-child2'>";
										computerListHtml +="<a href='#' data-groupid="+groupsId+" onClick='hostDtailFun(this);' id='"+host[k].hostid+"'>";
										if(host[k].status == 1){
											computerListHtml +="<span class='pot-grey'></span><label>"+host[k].name+"</label>";
										}else if(host[k].state > 0){
											//debugger
											if(host[k].highestAlarm == 0){
												computerListHtml +="<span class='pot-red'></span><label>"+host[k].name+"</label>"
											}else if(host[k].highestAlarm == 1){
												computerListHtml +="<span class='pot-blue'></span><label>"+host[k].name+"</label>"
											}else if(host[k].highestAlarm == 2){
												computerListHtml +="<span class='pot-yellow'></span><label>"+host[k].name+"</label>";
											}else if(host[k].highestAlarm == 3){
												computerListHtml +="<span class='pot-saffron'></span><label>"+host[k].name+"</label>";
											}else if(host[k].highestAlarm == 4){
												computerListHtml +="<span class='pot-orange'></span><label>"+host[k].name+"</label>";
											}else if(host[k].highestAlarm == 5){
												computerListHtml +="<span class='pot-red'></span><label>"+host[k].name+"</label>";
											}
											
											//computerListHtml +="<span class='pot-red'></span><label>"+host[k].name+"</label>"
										}else{
											computerListHtml +="<span class='pot-green'></span><label>"+host[k].name+"</label>";
										}
									}
									computerListHtml +="</a></span></td></tr>";
								}
							}
						}
					}
					
				}else{
					computerListHtml +="<tr><td>请审查该用户对主机组的访问权限</td></tr>";
				}
				jQuery("#testCpu").html(listHtml);
				jQuery("#testComputer").html(computerListHtml);
				if(isResource){
					var groupId = localResourceExpand;
					if (groupId) {
						jQuery("#resourceList").find("."+groupId).show();
						var tree3Current=jQuery("#resourceList").find("#"+dataId).parents("tr");
						tree3Current.show();
						//tree3Current.addClass("current")
						var currentClass=tree3Current.attr('class');
						jQuery('tr[data-id='+currentClass+']').find('button span').removeClass("arrow-right").addClass("arrow-down");
						jQuery("#resourceList").find("."+currentClass).show();
						var childId=jQuery("#resourceList").find("."+groupId).attr('data-id');
						var parentTr = jQuery(".tree-parent", "#resourceList").parents("tr");
						jQuery(parentTr).each(function(index,item) {
							if(jQuery(item).attr("data-id") == groupId){
								jQuery(item).find(".tree-parent .arrow-right").removeClass("arrow-right").addClass("arrow-down");
								jQuery(item).find(".tree-child .arrow-right").removeClass("arrow-right").addClass("arrow-down");
							}
						})
						jQuery("#resourceList").find("#"+dataId).parents("tr").addClass("current");
					}
				}else{
					jQuery("#resourceList").hide();
					jQuery("#computerList").show();
					var groupId = localCompExpand;
					if (groupId) {
						var tree3Current=jQuery("#computerList").find("#"+dataId).parents("tr");
						tree3Current.show();
						var currentClass=tree3Current.attr('class');
						jQuery('tr[data-id='+currentClass+']').find('button span').removeClass("arrow-right").addClass("arrow-down");
						jQuery("#computerList").find("."+currentClass).show();
						var childId=jQuery("#computerList").find("."+groupId).attr('data-id');
						jQuery("#computerList").find("."+groupId).show();
						var parentTr = jQuery(".tree-parent", "#computerList").parents("tr");
						jQuery(parentTr).each(function(index,item) {
							if(jQuery(item).attr("data-id") == groupId){
								jQuery(item).find(".tree-parent .arrow-right").removeClass("arrow-right").addClass("arrow-down");
							}
						})
						jQuery("."+groupId,"#computerList").find("#"+dataId).parents("tr").addClass("current");
					} 
				}
				addDot1("resourceList");
				addDot("computerList");
				addSize("resourceList");
				addSize("computerList");
				addSum("resourceList");
				addSum("computerList");
        		var id = jQuery('#hostSide').attr('data-id');
        		jQuery('#'+id,"#resourcebox").addClass("selectedLi");
        		var groupid = jQuery("#resourcebox").find(".selectedLi").attr("data-groupid");
            	loadUsedRateInfo(id,groupid); 
            	loadBaseInfo(id);
            	loadDiskUsageMsg(id,groupid);
            	loadResourceAlarmInfo(id);
            	loadInterfaceMsg(id,groupid);
            	laodWebMonitorMsg(id,groupid);
            	loadHostDetailMsg(id);
		        
				jQuery('#testCpu tr').bind('click',function(event){
					event.stopPropagation();
					var groupId = jQuery(event.target).parents("tr").data("id");
					if (groupId) {
						groupId = groupId.substring(1,groupId.length);
						var obj = jQuery(event.target).parents("tr").find(".treeview");
						arrowClick(obj,groupId);
					}
				})
				jQuery('#computerList tr').bind('click',function(event){
					event.stopPropagation();
					var groupId = jQuery(event.target).parents("tr").data("id");
					if (groupId) {
						groupId = groupId.substring(1,groupId.length);
						var obj = jQuery(event.target).parents("tr").find(".treeview");
						arrowClick(obj,groupId);
					}
				})
			}
		});
	}
function loadGroupHosts(){
	jQuery("#perparingpc").html('<tr><td colspan="2"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>');
	var name=jQuery("#equipment").val();
	var ip=jQuery("#search2").val();
	jQuery.ajax({
		method:"POST",
		url:"${ctx}/formview/hostByGroup.json",
		data:{
			groupName:name,
			hostIp:ip
		},
		success:function(data){
			var temp=[];
			for(var i=0;i<data.length;i++){
				var j=data[i];
				var group=j.groupName;
				var ip=j.hostName;
				var id=j.hostid;
				temp.push('<tr><td>'+group+'</td><td>'+ip+'</td><td hidden="true" data-id="'+id+'">'+id+'</td></tr>')
			}
			temp=temp.join("");
			jQuery("#perparingpc").html(temp);
		}
	});
}


//保存页面组件显示设置
function savePageConfig(){
	var array={};
	var append='';
	jQuery("#showlistul").each(function(item){
	   	var a=jQuery(this).find("li");
	   	var classstyle='';
	   	var text='';
		for(var i=0;i<a.length;i++){
			classstyle=a.eq(i).attr('data-class');
			text=a.eq(i).text();
			append +=classstyle+","+text+";";
		}
	});
	jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/savepageconfig.json",
		  data:{
			  str:append,
		  }
	  });
}

function chartOverviewConfig(){
	getPageConfigView();
	jQuery('#chartOverviewSetting_Dialog').modal('show');
};
function chartMaxScreen(){
	if(jQuery(".btnMaxMin").hasClass("btn-max")){
		jQuery(".nav").hide();
		jQuery(".article", ".fadeformodal").css("top", "62px");
		jQuery(".overlay", ".fadeformodal").css("top", "62px");
		jQuery(".mainViewContent").css({
			"top":"62px",
		    "bottom":0
		});
		jQuery(".footer").hide();
		
		var id = jQuery('#hostSide').attr('data-id');
		var groupid = jQuery("#resourcebox").find(".selectedLi").attr("data-groupid");
		/* loadIframeMem();
		loadIframeCpu(); */
    	loadUsedRateInfo(id,groupid); 
		jQuery(".btnMaxMin").removeClass("btn-max").addClass("btn-min");
	}else{
		jQuery(".mainViewContent").css({
			"top":"170px",
		    "bottom":"30px"
		});
		jQuery(".footer").show();
		jQuery(".nav").show();
		jQuery(".article", ".fadeformodal").css("top", "170px");
		jQuery(".overlay", ".fadeformodal").css("top", "170px");
		jQuery(".btnMaxMin").removeClass("btn-min").addClass("btn-max");
	}
	return false;
};
function getPageConfig(){
	var temp=[];
    var allCfg = [ 
    				{'datacls':'mapbox_widget','name':'拓扑图'},
					{'datacls':'abnormalalarmstabox_widget','name':'异常告警统计'}, 
					{'datacls':'alarmcomparisonbox_widget','name':'告警环比图'},
					{'datacls':'cpubodybox_widget','name':'CPU使用率'}, 
					{'datacls':'memorybodybox_widget','name':'内存利用率'}, 
					{'datacls':'diskbodybox_widget','name':'磁盘使用率'},
					{'datacls':'responsetimebodybox_widget','name':'响应时间排行'},
					{'datacls':'currentNoticeBox_widget','name':'当前关注页'} 
				];
    
	var tempHidden=[],tempShow=[];
	var hidden=[];
	jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/getpageconfig.json",
		  success:function(data){
			  if(!data){
				  jQuery("#hiddenlistul").html('');
				  for(var i=0;i<allCfg.length;i++){
					  tempShow.push('<li data-class="'+allCfg[i].datacls+'">'+allCfg[i].name+'</li>');
				  }				  
				  jQuery("#showlistul").html(tempShow.join(''));
			  }else{
					  for(var i=0;i<allCfg.length;i++){
						  var flagArray = [];
						  for(var j in data){							  
							  if(allCfg[i].datacls == data[j][0]){
								  flagArray.push('false');
							  }else {
								  flagArray.push('true');
							  }							  
						  }
						  if (!flagArray.contains('false')) {
							  hidden.push(allCfg[i]);
						  }
						  
					  }
					  
					  for(var i =0;i<hidden.length;i++){
						  tempHidden.push('<li data-class="'+hidden[i].datacls+'">'+hidden[i].name+'</li>');
					  }
					  jQuery("#hiddenlistul").html(tempHidden.join(''));
					  
					  for(var i in data){
						  temp.push('<li data-class="'+data[i][0]+'">'+data[i][1]+'</li>') 
					  }
					  temp=temp.join('');
					  jQuery("#showlistul").html(temp);
			  }
			  chartOverviewShow();
			//加载数据
			isLoaddata();
		  }
	  });
}
function initDragEle(){
	var jsonHtml = {};
	var mapbox_widget = proMapbox_widget();
	var alarmcomparisonbox_widget = proAlarmcomparisonbox_widget();
	var currentNoticeBox_widget = proCurrentNoticeBox_widget();
	var abnormalalarmstabox_widget = proAbnormalalarmstabox_widget();
	var cpubodybox_widget = proCpubodybox_widget();
	var memorybodybox_widget = proMemorybodybox_widget();
	var diskbodybox_widget = proDiskbodybox_widget();
	var responsetimebodybox_widget = proResponsetimebodybox_widget(); 
	var jsonData = JSON.parse(localPosition);
 	for(var key in jsonData){
		for(var item in jsonData[key]){
			var num = parseInt(key),itemInt = parseInt(item);
			jQuery(".cellDrag ").eq(num).append(eval(jsonData[key][item]));
		}
	}
}
function proMapbox_widget(){
	var domArry = [];
	domArry.push('<div class="dashbrd-widget mapbox_widget" id="mapbox_widget"><div class="dashbrd-widget-head cursor-move headDrag" id="index-cell-head-1">');
	domArry.push('<h4 id="resourcetabs_header">拓扑图</h4><ul><li><button type="button" class="btn-widget-MaxMin btn-widget-max" title="最大化" id="mapMax" onClick=\'mapMax(event);\'>'+
			'</button><button type="button" class="btn-widget-action" title="动作" id="mapChooseList" onClick="mapRefresh(event);"></button>');
	domArry.push('<button type="button" id="mapbox_icon" onclick=\'changeWidgetState(this, "mapbox", "")\' class="btn-widget-collapse" title="宕机"></button>');
	domArry.push('</li></ul></div><div class="body" id="mapbox" style="min-Width:450px;"></div></div>');
	return domArry.join("");
}
function proAlarmcomparisonbox_widget(){
	var domArry = [];
	domArry.push('<div class="dashbrd-widget alarmcomparisonbox_widget" id="alarmcomparisonbox_widget"><div class="dashbrd-widget-head cursor-move headDrag">');
	domArry.push('<h4 id="alarmcomparisonbox_header">告警环比图</h4><ul><li>');
	domArry.push('<span class="btn-month current" style="margin-top: 4px;" onclick="loadMonthAlarmNum(this)">月</span>');
	domArry.push('<span class="btn-week" style="margin-top: 4px;margin-left:-4px;" onclick="loadWeekAlarmNum(this)">周</span>');
	domArry.push('</li><li><button type="button" id="alarmcomparisonbox_icon" onclick=\'changeWidgetState(this, "alarmcomparisonbox", "");\'class="btn-widget-collapse" title="宕机"></button>');
	domArry.push('</li></ul></div><div class="body" id="alarmcomparisonbox"><div class="loaddiv"><div id="alarmComparison" style="height: 344px;min-width:350px;"></div></div></div></div>');
	return domArry.join("");
}
function proCurrentNoticeBox_widget(){
	var domArry = [];
	domArry.push('<div class="dashbrd-widget currentNoticeBox_widget" id="currentNoticeBox_widget"><div class="dashbrd-widget-head cursor-move headDrag">');
	domArry.push('<h4 id="currentNoticeBox_header">当前关注</h4><ul><li>');
	domArry.push('<button type="button" class="btn-conf" title="配置" data-toggle="modal"  onclick="currentcfg()">&nbsp;</button>');
	domArry.push('</li><li><button type="button" id="currentNoticeBox_icon" onclick=\'changeWidgetState(this, "currentNoticeBox", "");\'class="btn-widget-collapse" title="宕机"></button>');
	domArry.push('</li></ul></div><div class="body" id="currentNoticeBox"></div></div>');
	return domArry.join("");
}
function proAbnormalalarmstabox_widget(){
	var domArry = [];
	domArry.push('<div class="dashbrd-widget abnormalalarmstabox_widget" id="abnormalalarmstabox_widget"><div class="dashbrd-widget-head cursor-move headDrag">');
	domArry.push('<h4 id="abnormalalarmstabox_header">异常告警统计</h4><ul><li>');
	domArry.push('<button type="button" class="btn-widget-action" title="动作" id="abnormalalarmsChooseList" onClick="abnormalalarmsRefresh(event);"></button>');
	domArry.push('<button type="button" id="abnormalalarmstabox_icon" onclick=\'changeWidgetState(this, "abnormalalarmstabox", "");\'class="btn-widget-collapse" title="宕机"></button>');
	domArry.push('</li></ul></div>');
	domArry.push('<div class="body" id="abnormalalarmstabox"><div class="loaddiv"><div id="abnormalAlarmStatistics" style="height: 360px;width:100%;margin:0 auto;max-width:920px;;min-width:350px;"></div>');
	domArry.push('</div></div></div>');
	return domArry.join("");
}
function proCpubodybox_widget(){
	var domArry = [];
	domArry.push('<div class="dashbrd-widget cpubodybox_widget" id="cpubodybox_widget"><div class="dashbrd-widget-head cursor-move headDrag">');
	domArry.push('<h4 id="cpubodybox_header">CPU使用率</h4><ul><li><button type="button" class="btn-conf" title="配置" data-toggle="modal" onclick=\'showDialog("cpuSetting_Dialog")\'>&nbsp;</button></li>');
	domArry.push('<li><button type="button" id="cpubodybox_icon" onclick=\'changeWidgetState(this, "cpubodybox", "");\'class="btn-widget-collapse" title="宕机"></button></li></ul></div>');
	domArry.push('<div class="body" id="cpubodybox"><div><table class="list-table"><thead><tr><th>主机</th><th>CPU使用率</th></tr></thead><tbody id="cputbody"></tbody></table></div></div></div>');
	return domArry.join("");
}
function proMemorybodybox_widget(){
	var domArry = [];
	domArry.push('<div class="dashbrd-widget memorybodybox_widget" id="memorybodybox_widget"><div class="dashbrd-widget-head cursor-move headDrag">');
	domArry.push('<h4 id="memorybodybox_header">内存使用率</h4><ul><li>');
	domArry.push('<button type="button" class="btn-conf" title="配置" data-toggle="modal" onClick=\'showDialog("memorySetting_Dialog")\'>&nbsp;</button></li><li>');
	domArry.push('<button type="button" id="memorybodybox_icon" onclick=\'changeWidgetState(this, "memorybodybox", "");\'class="btn-widget-collapse" title="宕机"></button></li></ul></div>');
	domArry.push('<div class="body" id="memorybodybox"><div><table class="list-table"><thead><tr><th>主机</th><th>内存使用率</th></tr></thead>');
	domArry.push('<tbody id="memorytbody"></tbody></table></div></div></div>');
	return domArry.join("");
}
function proDiskbodybox_widget(){
	var domArry = [];
	domArry.push('<div class="dashbrd-widget diskbodybox_widget" id="diskbodybox_widget"><div class="dashbrd-widget-head cursor-move headDrag">');
	domArry.push('<h4 id="diskbodybox_header">磁盘利用率</h4>');
	domArry.push('<ul><li><button type="button" class="btn-conf" title="配置" data-toggle="modal" onClick=\'showDialog("diskSetting_Dialog")\'>&nbsp;</button></li>');
	domArry.push('<li><button type="button" id="diskbodybox_icon" onclick=\'changeWidgetState(this, "diskbodybox", "");\'class="btn-widget-collapse" title="宕机"></button></li></ul></div>');
	domArry.push('<div class="body" id="diskbodybox"><div><table class="list-table"><thead><tr><th>主机</th><th>磁盘利用率</th></tr></thead><tbody id="disktbody"></tbody>');
	domArry.push('</table></div></div></div>');
	return domArry.join("");
}
function proResponsetimebodybox_widget(){
	var domArry = [];
	domArry.push('<div class="dashbrd-widget responsetimebodybox_widget" id="responsetimebodybox_widget"><div class="dashbrd-widget-head cursor-move headDrag">');
	domArry.push('<h4 id="responsetimebodybox_header">响应时间排行</h4><ul><li><button type="button" class="btn-conf" title="配置" data-toggle="modal" onClick=\'showDialog("responsetimeSetting_Dialog")\'>&nbsp;</button></li>');
	domArry.push('<li><button type="button" id="responsetimebodybox_icon"onclick=\'changeWidgetState(this, "responsetimebodybox", "");\'class="btn-widget-collapse" title="宕机"></button></li></ul></div>');
	domArry.push('<div class="body" id="responsetimebodybox"><div><table class="list-table"><thead><tr><th>主机</th><th>响应时间</th></tr></thead><tbody id="responsetimetbody"></tbody>');
	domArry.push('</table></div></div></div>');
	return domArry.join("");
}
function getPageConfigView(){
	var temp=[];
    var allCfg = [ 
    				{'datacls':'mapbox_widget','name':'拓扑图'},
					{'datacls':'abnormalalarmstabox_widget','name':'异常告警统计'}, 
					{'datacls':'alarmcomparisonbox_widget','name':'告警环比图'},
					{'datacls':'cpubodybox_widget','name':'CPU使用率'}, 
					{'datacls':'memorybodybox_widget','name':'内存利用率'}, 
					{'datacls':'diskbodybox_widget','name':'磁盘使用率'},
					{'datacls':'responsetimebodybox_widget','name':'响应时间排行'},
					{'datacls':'currentNoticeBox_widget','name':'当前关注页'} 
				];
    
	var tempHidden=[],tempShow=[];
	var hidden=[];
	jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/getpageconfig.json",
		  success:function(data){
			  if(!data){
				  jQuery("#hiddenlistul").html('');
				  for(var i=0;i<allCfg.length;i++){
					  tempShow.push('<li data-class="'+allCfg[i].datacls+'">'+allCfg[i].name+'</li>');
				  }				  
				  jQuery("#showlistul").html(tempShow.join(''));
			  }else{
					  for(var i=0;i<allCfg.length;i++){
						  var flagArray = [];
						  for(var j in data){							  
							  if(allCfg[i].datacls == data[j][0]){
								  flagArray.push('false');
							  }else {
								  flagArray.push('true');
							  }							  
						  }
						  if (!flagArray.contains('false')) {
							  hidden.push(allCfg[i]);
						  }
						  
					  }
					  
					  for(var i =0;i<hidden.length;i++){
						  tempHidden.push('<li data-class="'+hidden[i].datacls+'">'+hidden[i].name+'</li>');
					  }
					  jQuery("#hiddenlistul").html(tempHidden.join(''));
					  
					  for(var i in data){
						  temp.push('<li data-class="'+data[i][0]+'">'+data[i][1]+'</li>') 
					  }
					  temp=temp.join('');
					  jQuery("#showlistul").html(temp);
			  }
		  }
	  });
}
function  loadcurrentFocus(info){
	jQuery("#currentNoticeBox").html('<tr><td colspan="5"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>');
		  if(!info || info == ''){
			jQuery('.loadingindex').hide();
			jQuery("#currentNoticeBox").html('<tr><td>未添加任何数据</td></tr>');
			return 
		  }
		  var temp={},groupname;
		  var ids=[];
		  for(var i = 0; i< info.length; i++){
			  var name= info[i].name;
			  var ip= info[i].ip;
			  var id= info[i].id;
			  ids.push(id);
			  if(temp[name]){
					temp[name].vals.push(ip);
				}else{
					temp[name]={
						vals:[ip]	
					};
				}
		  }
	   if(ids.length>0){
		ids=ids.join(',');
			var b=[];
		  jQuery.ajax({
			  method: "POST",
			  url: "${ctx}/formview/currentFocus.json",
			  data: {
				  	hosts:ids
			  },
			  success:function(data) {
				  jQuery('.loadingindex').hide();
				  for(var i in data){
					   var f = data[i];
					   b.push(f);
				   }
				for(var i=0;i<b.length;i++){
					for(var k in temp){
						if(temp[k].vals.indexOf(b[i].name)!=-1){
							if(temp[k].objs){
								temp[k].objs.push(b[i])
							}else{
								temp[k].objs=[b[i]]
							}
						}
					}	
				}
				var tempdata=[];
				for(var pp in temp){
					tempdata.push('<h4 class="body-title">'+pp+'</h4>'
							+'<div><table class="list-table">'
							+'<thead><tr><th>名称</th><th>协议可用性</th><th>响应时间</th><th>CPU使用率</th><th>内存利用率</th><th>当前最高异常</th><th>异常数</th></tr></thead>'
							+'<tbody>');
						var objArray=temp[pp].objs;
					for(var ii=0;ii<objArray.length;ii++){
						var oo=temp[pp].objs[ii];
						var host=oo.name;
						var available=oo.available;
						var snmpAvailable=oo.snmpAvailable;
						var jmxAvailable=oo.jmxAvailable;
						var ipmiAvailable=oo.ipmiAvailable;
						var cpu=oo.cpuRate;
						if(cpu==-1){
							cpu="---";
						}else{
							cpu=cpu+"%";
						}
						var memory=oo.memoryRate;
						if(memory==-1){
							memory="---";
						}else{
							memory=(memory * 100).toFixed(2) + "%";
						}
						/* var disk=oo.diskRate;
						if(disk==-1){
							disk="---";
						}else{
							disk=disk+"%";
						} */
						var maxPriority=oo.maxPriority;
						if(maxPriority==0){
							maxPriority="未分类";
						}else if(maxPriority==1){
							maxPriority="信息";
						}else if(maxPriority==2){
							maxPriority="警告";
						}else if(maxPriority==3){
							maxPriority="一般严重";
						}else if(maxPriority==4){
							maxPriority="严重";
						}else if(maxPriority==5){
							maxPriority="灾难";
						}else{
							maxPriority="---";
						}
						var totalInterFace=oo.totalInterFace;
						if(totalInterFace==-1){
							totalInterFace="---";
						}else{
							totalInterFace=(totalInterFace*1000).toFixed(2)+'ms';
						}
						var totalException=oo.totalException;
						if(totalException==-1){
							totalException="---";
						}
						tempdata.push('<tr><td>'+host+'</td>'
								+'<td><span class="status-container"><span class="'+(available==0?'status-grey':available==1?'status-green':'status-red')+'">'+'ZBX'+'</span><span class="'+(snmpAvailable==0?'status-grey':snmpAvailable==1?'status-green':'status-red')+'">'+'SNMP'+'</span><span class="'+(jmxAvailable==0?'status-grey':jmxAvailable==1?'status-green':'status-red')+'">'+'JMX'+'</span><span class="'+(ipmiAvailable==0?'status-grey':ipmiAvailable==1?'status-green':'status-red')+'">'+'IPMI'+'</span></span></td>'
								+'<td>'+totalInterFace+'</td><td>'+cpu+'</td><td>'+memory+'</td><td>'+maxPriority+'</td><td>'+totalException+'</td></tr>');
						
					}
					tempdata.push('</tbody></table></div>');
				}
				tempdata=tempdata.join("");
				jQuery("#currentNoticeBox").html(tempdata);
				initAlarmComparMonth();
				/* var groupname =localStorage.getItem("localAbnormalalarm");
				if(groupname){
					var $target = jQuery("#groupsName li a[value='"+groupname+"']");
					$target.addClass('selected');
					$target.parent().siblings().children('a').removeClass('selected');
				}else{
					groupname = jQuery("#groupsName li").children('.selected').attr('value');
				}
			    loadpriorityCount(groupname);
				initAlarmComparMonth(); */
			}
		  });
		}
}

function loadcurrentFocusBySave(){
	var perparedpcArray = [];
	var trlength = jQuery('#perparedpc').find('tr');
	for(var i = 0;i < trlength.length; i++){
		var name = trlength.eq(i).find('td').eq(0).text();
		var ip = trlength.eq(i).find('td').eq(1).text();
		var id = trlength.eq(i).find('td').eq(2).text();
		perparedpcArray.push({name:name, ip:ip, id:id});	
	}
	//加载
	debugger;
	loadcurrentFocus(perparedpcArray);
	//保存
	savestringofcurrent(perparedpcArray);
}


function abAlarmChoose(){
	jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/index.json",
		  success:function(data) {
			 var dataArray = data.groups;
			 var htmlLi= '';
			 var left = jQuery('#abnormalalarmsChooseList').offset().left + 12 - 150;
			 var top = jQuery('#abnormalalarmsChooseList').offset().top + 12;
			 var html = '<ul class="action-menu action-menu-top" style="left:'+left+'px;top:'+top+'px;display:none;" id="groupsName">'
				+ '</ul>';
			jQuery('body').append(html);
			htmlLi += '<li><a class="action-menu-item selected" value="全部">全部</a></li>';
			for (var k=0;k<dataArray.length;k++){
				htmlLi += '<li><a class="action-menu-item" value="'+dataArray[k].name+'">'+dataArray[k].name+'</a></li>';
			}
			jQuery("#groupsName").html(htmlLi);
			var groupname =localStorage.getItem("localAbnormalalarm");
			if(!groupname){
				groupname = jQuery("#groupsName li").children('.selected').attr('value');
			}
			loadpriorityCount(groupname);
		  }
	});
}
function initAbnormalAlarm(sData,groupname){
	var chart = new Highcharts.Chart('abnormalAlarmStatistics', {
	    chart: {
	        type: 'pie',
	        options3d: {
	          enabled: true,
	          alpha: 45
	        },
	    },
	    title: {
	        text: sData.length? '' : '未发现任何数据'
	    },
	    credits: {
	    	enabled:false
	    },
	    tooltip: {
	      	 pointFormat: ''
	    },
	    legend : {
	    	   /* layout: 'vertical',  */
	           backgroundColor: '#FFFFFF',
	           floating: true, 
	           align: 'left',
	           verticalAlign: 'top',
	           x: -5,
	           y: -17
	          
	    },
	    plotOptions: {
         pie: {
             innerSize: 100,
             depth: 45,
             dataLabels: {
                 enabled: false
             },
             showInLegend:true
         },
         series: {
             cursor: 'pointer',
             events: {
                 click: function (event) {
                	 jQuery("#alarmtbody").html('<tr><td colspan="5"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍后……</label></div></td></tr>');
                 	//获取点击的块的name
                 	var name = event.point.name;
                 	var number = event.point.y;
                 	if(name=="未分类: "+number){
                 		name=0;
 				   }else if(name=="信息: "+number){
 					  name=1;
 				   }else if(name=="警告: "+number){
 					  name=2;
 				   }else if(name=="一般严重: "+number){
 					  name=3;
 				   }else if(name=="严重: "+number){
 					  name=4;
 				   }else{
 					   name=5;
 				   }
                 	//根据点击的快 加入具体内容
                 	jQuery.ajax({
                 		method:"POST",
                 		url:"${ctx}/formview/messageByPriority.json",
                 		data:{
                 			priority:name,
                 			name:groupname
                 		},
                 		success:function(data){
                 			for(var j=0;j<data.length;j++){
	                 			if(data[j].description==null){
	                 				jQuery("#alarmtbody").html('<tr><td>请审查该用户是否对主机群组有访问权限</td></tr>');
	                 				return
	                 			}
                 			}
                 			temp=[];
                 			for(var j=0;j<data.length;j++){
                 				var host=data[j].name;
                 				var description=data[j].description;
                 				var acknowledged=data[j].acknowledged;
                 				var color='';
                 				if(acknowledged==0){
                 					acknowledged='不';
                 					color="red";
                 				}else{
                 					acknowledged='是';
                 					color="green";
                 				}
                 				var startClock=data[j].startClock;
                 				//获得本地时间
                 				    startClock=getLocalTime(startClock);
                 				var subClock=data[j].subClock;
                 				temp.push('<tr><td>'+host+'</td><td><span class="red">'+description+'</span></td>'
            							+'<td>'+startClock+'</td><td>'+subClock+'</td><td><span class="'+color+'">'+acknowledged+'</span></td></tr>')
                 			}
                 			temp=temp.join('');
                 			jQuery("#alarmtbody").html(temp);
                 		}
                 	});
                 	//弹出框的对象
                 	var alermDialog = jQuery('#alarm_Dialog');
                 	//弹框显示
                 	alermDialog.modal('show');
                 }
             }
         }
     },
	    series: [{
	        name: '',
	        data: sData
	    }],
	    navigation: {
         buttonOptions: {
             enabled: false
         }
     }
	}); 
}
function loadpriorityCount(groupname){
	var sData=[];
	 jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/priorityCount.json",
		  async:false,
		  data:{
			  name:groupname
		  },
		  success:function(data) {
			  jQuery('.loadingindex').hide();
			  for(var i=0;i<data.length;i++){
				  p = new Object();
				   p.name = data[i].priority;
				   num = data[i].countNum;
					if(p.name==1){
					   p.name="信息: "+num;
					   p.color='#7499FF';
				   }else if(p.name==2){
					   p.name="警告: "+num;
					   p.color='#FFC859';
				   }else if(p.name==4){
					   p.name="严重: "+num;
					   p.color='#e07808';
				   }else if(p.name==0){
					   p.name="未分类: "+num;
					   p.color='#97AAB3';
				   }else if(p.name==3){
					   p.name="一般严重: "+num;  
					   p.color='#FFA059';
				   }else{
					   p.name="灾难: "+num;
					   p.color='#E45959';
				   }
				   p.y = num;
				   sData.push(p);
			   }
			  
		  }
	  });
	  Highcharts.getOptions().plotOptions.pie.colors = (function () {
	    //var colors = ['#063050','#0e61a1','#3da5d9','#ea7317','#f0e67b','#5ac2ee'];
	    var colors = ['#063050','#0e61a1','#3da5d9','#ea7317','#f0e67b','#5ac2ee'];
	    return colors;
	}());
	// Build the chart
	  initAbnormalAlarm(sData,groupname);
}


function loadMemoryRate(value){
		type=jQuery("#memoryorder").val();
		limit=jQuery("#memorylimit").val();
		bignum=jQuery("#memorybignum").val();
		smallnum=jQuery("#memorysmallnum").val();
		validate('memorySetting_Dialog');
		if(parseInt(bignum) <= parseInt(smallnum) || bignum == "" || smallnum == ""){
			$.MsgBox.Alert("消息","请输入正确区间范围");
			return false;
		}
		if(type=='asc'){
			jQuery("#memorybodybox_header").html('TOP'+limit+' 内存利用率-后'+limit+'位排行');
		}else{
			jQuery("#memorybodybox_header").html('TOP'+limit+' 内存利用率-前'+limit+'位排行');
		}
	jQuery("#memorytbody").html('<tr><td colspan="2"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>');
		//localstorage
		localStorage.setItem("localmemorytype", type);
		localStorage.setItem("localmemorylimit", limit);
		localStorage.setItem("localmemorybignum", bignum);
		localStorage.setItem("localmemorysmallnum", smallnum);
		if (value) {
			jQuery('#memorySetting_Dialog').modal('hide');
		}
	  jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/hostsMemory.json",
		  data: {
				order:type,
			  	limit:limit
		  },
		  success:function(data) {
			  jQuery('.loadingindex').hide();
			var  temp=[];
			if(type=='asc'){
				  for(var i=0;i<data.length;i++){
					  var j=data[i];
					  var host=j.hostName;
					  var rate=j.memoryRate;
					  var rateclone=rate;
					  if(-1==rate){
						 rate='---'; 
					  }else{
						 rate=rate+'%';
					  }
					 temp.push( '<tr><td>'+host+'</td><td>'+'<span class="'+(rateclone>bignum?'red':rateclone>smallnum?'green':'grey')+'">'+rate+'</span></td></tr>' ) 
				   }
			}else{
				 for(var i=data.length-1;i>=0;i--){
					  var j=data[i];
					  var host=j.hostName;
					  var rate=j.memoryRate;
					  var rateclone=rate;
					  if(-1==rate){
						 rate='---'; 
					  }else{
						 rate=rate+'%';
					  }
					 temp.push( '<tr><td>'+host+'</td><td>'+'<span class="'+(rateclone>bignum?'red':rateclone>smallnum?'green':'grey')+'">'+rate+'</span></td></tr>' ) 
				   }
			}
			
			  temp=temp.join("");
			  jQuery("#memorytbody").html(temp);
		  }
	  });
}

//当月每天异常数
function currentMonthmap(){
	  var sData=[];
	  jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/currentMonth.json",
		  async:false,
		  success:function(data) {
			  for(var i in data){
				  sData.push(data[i]);
			   }
		  }
	  });
	  return sData
}

//上月每天异常数	
function lastMonthmap(){
	var sData=[];
	  jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/lastMonth.json",
		  async:false,
		  success:function(data) {
			  for(var i in data){
				  sData.push(data[i]);
			   }
		  }
	  });
	  return sData
}
function initAlarmComparMonth(){
	var currentMonth=currentMonthmap();
	
	var lastMon=lastMonthmap();
	//告警环比图
	var chart = new Highcharts.Chart('alarmComparison', {
	    title: {
	        text: '',
	        x: -20
	    },
	    credits:{
	    	enabled:false
	    },
	    subtitle: {
	        text: '',
	        x: -20
	    },
	    credits:{
	    	enabled: false
	    	},
	    xAxis: {
	        categories: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30','31']
	    },
	    yAxis: {
	        title: {
	            text: '数量'
	        },
	        plotLines: [{
	            value: 0,
	            width: 1,
	            color: '#808080'
	        }]
	    },
	    tooltip: {
	        valueSuffix: '次'
	    },
	    legend: {
	        layout: 'vertical',
	        align: 'right',
	        verticalAlign: 'middle',
	        borderWidth: 0
	    },
	    plotOptions: {
            series: {
            	events: {
                	legendItemClick: function() {
                        return false;
                	}
            	}
        	}
        },
	    series: [{
	        name: '本月',
	        data: currentMonth,
	        color:'#e37d29'
	    }, {
	        name: '上月',
	        data: lastMon,
	        color:'#14b4ab'
	    }],
	    navigation: {
            buttonOptions: {
                enabled: false
            }
        }
	});
}
function loadMonthAlarmNum(obj){
	if(obj == null){obj = ".btn-month";}
	jQuery(obj).addClass('current').siblings().removeClass('current');
	jQuery('.loadingindex').hide();
	initAlarmComparMonth();
}

//上星期每天异常数
function lastWeekmap(){
	var sData=[];
	  jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/lastWeek.json",
		  async:false,
		  success:function(data) {
			  for(var i in data){
				  sData.push(data[i]);
			   }
		  }
	  });
	  return sData
}
		
//本周每天异常数		
function currentWeekmap(){
	var sData=[];
	  jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/currentWeek.json",
		  async:false,
		  success:function(data) {
			  for(var i in data){
				  sData.push(data[i]);
			   }
		  }
	  });
	  return sData
}

function loadWeekAlarmNum(obj){
	jQuery(obj).addClass('current').siblings().removeClass('current');
	var lastWeek=lastWeekmap();
	var currentWeek=currentWeekmap();
	//告警环比图
	var chart = new Highcharts.Chart('alarmComparison', {
	    title: {
	        text: '',
	        x: -20
	    }, 
	    credits:{
	    	enabled:false
	    },
	    credits:{
	    	enabled: false
	    	},
	    subtitle: {
	        text: '',
	        x: -20
	    },
	    xAxis: {
	        categories: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
	    },
	    yAxis: {
	        title: {
	            text: '数量'
	        },
	        plotLines: [{
	            value: 0,
	            width: 1,
	            color: '#808080'
	        }]
	    },
	    tooltip: {
	        valueSuffix: '次'
	    },
	    plotOptions: {
            series: {
            	events: {
                	legendItemClick: function() {
                        return false;
                	}
            	}
        	}
        },
	    legend: {
	        layout: 'vertical',
	        align: 'right',
	        verticalAlign: 'middle',
	        borderWidth: 0
	    },
	    series: [{
	        name: '本周',
	        data: currentWeek,
	        color:'#e37d29'
	    }, {
	        name: '上周',
	        data: lastWeek,
	        color:'#14b4ab'
	    }],
	    navigation: {
            buttonOptions: {
                enabled: false
            }
        }
	});
}
//存字符串到文件
function savestringofcurrent(data){
	var stringdata = "";	
	for (var i = 0; i < data.length; i++){
		stringdata += data[i].name + ',' + data[i].ip + ',' + data[i].id + ';'
	}
	jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/savecurrentfocusconfig.json",
		  data:{
			  str:stringdata,
		  }
	  });
}



function currentcfg(){
	getstringofcurrent();
	showDialog('currentNoticeSetting_Dialog');
}
//从文件取字符串
function getstringofcurrent(){
	/* jQuery("#perparingpc").empty(); */
	jQuery("#perparedpc").html('<tr><td colspan="2"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>');
	var datames={};
	jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/getcurrentfocusconfig.json",
		  async:false,
		  success:function(data) {
			  if(!data){
				  datames='';
				  jQuery("#perparedpc").empty();
				  return
			  };
			  var  temp=[];
			  datames=data;
			  for(var i in data){
				  if(data!=null && data[i]!=""){
					 var name=data[i].name;
					 var ip=data[i].ip;
					 var id=data[i].id;
					 temp.push('<tr><td>'+name+'</td><td>'+ip+'</td><td hidden="true" data-id="'+id+'">'+id+'</td></tr>');
				  }
			  }
			 temp=temp.join(""); 
			 jQuery("#perparedpc").html(temp);
			  
		  }
	  });
	return datames;
}
		
		
		jQuery("#resourcetabs").tabs({
			create: function() { jQuery.cookie("tab", 0); },
			disabled: [],
			active: 0,
			activate: function(event, ui) {
				jQuery.cookie("tab", ui.newTab.index().toString());
			}
		})
		.css("visibility", "visible");
		

		
		//tree 收缩事件
		function arrowClick(obj,groupId){
			var object = jQuery(obj).children('span');
			if(object.hasClass("arrow-right")){
				object.parents('table').find(".p"+groupId).show();
				//jQuery(".p"+groupId).prop({"style":"display:block"});
				object.removeClass('arrow-right').addClass('arrow-down');
			}else{
				//jQuery(".p"+groupId).prop({"style":"display:none"});
				var dataClass=object.parents('span').hasClass('tree-parent');
				if(dataClass==false){
					object.parents('table').find(".p"+groupId).hide();
					//jQuery('.'+dataId).hide();
				}else if(dataClass==true){
						var treeChild=jQuery('.tree-child').find('button span');
						treeChild.removeClass('arrow-down').addClass('arrow-right');
						//中间一层 
						var centerTree=object.parents('table').find(".p"+groupId);
						centerTree.hide();
						var itemId;
						 for(var i=0;i<centerTree.length;i++){
							itemId=jQuery(centerTree[i]).attr('data-id');
							jQuery('.'+itemId).hide();
						} 
				}
				   object.removeClass('arrow-down').addClass('arrow-right');
			}
			addSize("resourceList");
			addSize("computerList");
			addSum("resourceList");
			addSum("computerList");
			
			
		}
		
		
		jQuery('body').on('click','.ce-ul li',function(){
			if(jQuery(this).hasClass('current')){
				jQuery(this).removeClass('current')
			}else {
				jQuery(this).addClass('current')
			}
		});
		
		jQuery('body').on('click','.ce-tbody tr',function(){
			if(jQuery(this).hasClass('current')){
				jQuery(this).removeClass('current')
			}else {
				jQuery(this).addClass('current')
			}
		});
		
		//图表总览设置 左移 右移
		function overviewmove(obj) {
			var objId = jQuery(obj).attr('id');
			var rightArea = jQuery('#showlistul');
			var leftArea = jQuery('#hiddenlistul');
			var rightAreaLength = rightArea.find('.current').length;
			var leftAreaLength = leftArea.find('.current').length;
			
			if(objId == 'overviewmoveleft'){
				//左移
				//获取右侧选中的目标				
				
				for(var i = 0; i < rightAreaLength; i ++){
					var className = rightArea.find('.current:eq('+i+')').attr('data-class');
					var name = rightArea.find('.current:eq('+i+')').text();
					leftArea.append('<li data-class='+className+'>'+name+'</li>');
				}
				rightArea.find('.current').remove();
			}
			if(objId == 'overviewmoveright'){
				//右移
				
				for(var i = 0; i < leftAreaLength; i ++){
					var className = leftArea.find('.current:eq('+i+')').attr('data-class');
					var name = leftArea.find('.current:eq('+i+')').text();
					rightArea.append('<li data-class='+className+'>'+name+'</li>');
				}
				leftArea.find('.current').remove();
			}
			if (objId == 'moveAllRight') {
				//全部右移
				var leftNodes = leftArea.find("li");
				for (var i = 0; i<leftNodes.length;i++) {
					var className = jQuery(leftNodes[i]).attr('data-class');
					var name = jQuery(leftNodes[i]).text();
					rightArea.append('<li data-class='+className+'>'+name+'</li>');
				}
				leftNodes.remove();
			}
			if (objId == 'moveAllLeft') {
				//全部左移
				var rightNodes = rightArea.find("li");
				for (var i = 0; i<rightNodes.length;i++) {
					var className = jQuery(rightNodes[i]).attr('data-class');
					var name = jQuery(rightNodes[i]).text();
					leftArea.append('<li data-class='+className+'>'+name+'</li>');
				}
				rightNodes.remove();
			}
		}
		
		//图表总览设置保存事件
		function chartOverviewSave(obj){
			if(jQuery('#showlistul').find('li').length <= 0){
				$.MsgBox.Alert("消息","至少显示一项");
				return;
			}
			jQuery('#chartOverviewSetting_Dialog').modal('hide');
			savePageConfig();
			chartOverviewShow();			
			//加载数据
			isLoaddata();
		}		
		function chartOverviewShow(){
			var flag=false;
			var rightArea = jQuery('#showlistul');
			var leftArea = jQuery('#hiddenlistul'),nodeList =jQuery(".cellDrag").eq(0).children();
			var rightAreaLength = rightArea.find('li').length;
			var leftAreaLength = leftArea.find('li').length;
			for(var i = 0; i < rightAreaLength; i ++){
				//显示列表
				var className = rightArea.find('li:eq('+i+')').attr('data-class');
				jQuery('#'+ className).show();
			}
			for(var i = 0; i < leftAreaLength; i ++){
				var className = leftArea.find('li:eq('+i+')').attr('data-class');
				hideArry.push(className);
				jQuery('#'+ className).hide();
			}
			for(var j = 0 ;j < nodeList.length;j++){
				if(jQuery.inArray(nodeList[j].getAttribute("id"),hideArry) == -1 ){
					flag = true;
				}
			}
			if(!flag){
				 jQuery('.cellDrag').eq(0).width(1);
			}
		}
		
		//当前关注左移右移事件
		function currentMove(obj){
			var objId = jQuery(obj).attr('id');
			var rightArea = jQuery('#perparedpc');
			var leftArea = jQuery('#perparingpc');
			var rightAreaLength = rightArea.find('.current').length;
			var leftAreaLength = leftArea.find('.current').length;
			var _array = [];
			if(objId == 'currentmoveleft'){
				//左移
				//获取右侧选中的目标				
				
				for(var i = 0; i < rightAreaLength; i ++){
					_array = [];
					var name = rightArea.find('.current:eq('+i+')').html();
					//根据id去重
					var id = rightArea.find('.current:eq('+i+') td[hidden]').attr('data-id');
					var leftlength = leftArea.find('tr').length;
					for(var h = 0; h < leftlength; h++){
						var oldId = leftArea.find('tr:eq('+h+') td[hidden]').attr('data-id');
						if( id == oldId){							
							_array.push('false');
						}else{
							_array.push('true');
						}
					}
					if(!_array.contains('false')){
						leftArea.append('<tr>'+name+'</tr>');
					}					
				}
				rightArea.find('.current').remove();
			}
			if(objId == 'currentmoveright'){
				//右移
				
				for(var i = 0; i < leftAreaLength; i ++){
					_array = [];
					var name = leftArea.find('.current:eq('+i+')').html();
					//根据id去重
					var id = leftArea.find('.current:eq('+i+') td[hidden]').attr('data-id');
					var rightlength = rightArea.find('tr').length;
					for(var h = 0; h < rightlength; h++){
						var oldId = rightArea.find('tr:eq('+h+') td[hidden]').attr('data-id');
						if( id == oldId){							
							_array.push('false');
						}else{
							_array.push('true');
						}
					}
					if(!_array.contains('false')){
						rightArea.append('<tr>'+name+'</tr>');
					}					
				}
				leftArea.find('.current').remove();
			}
		}
		
		
//单个主机详情情况
//响应时间
var gaugeOptions = {
        chart: {
            type: 'solidgauge'
        },
        title: null,
        pane: {
            center: ['50%', '85%'],
            size: '100%',
            startAngle: -90,
            endAngle: 90,
            background: {
                backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
                innerRadius: '60%',
                outerRadius: '100%',
                shape: 'arc'
            }
        },
        tooltip: {
            enabled: false
        },
        // the value axis
        yAxis: {
        	stops: [
                [0.1, '#0cbcd6'], // 主要
                [0.6, '#da9715'], // 警告
                [0.8, '#e07808'], // 严重
                [0.9, '#cd4718'] //致命
            ],
            lineWidth: 0,
            minorTickInterval: null,
            tickPixelInterval: 400,
            tickWidth: 0,
            title: {
                y: -70
            },
            labels: {
                y: 16
            }
        },
        plotOptions: {
            solidgauge: {
                dataLabels: {
                    y: 5,
                    borderWidth: 0,
                    useHTML: true
                }
            }
        }
    };
   
    
    //单个主机详情页面 关闭事件
    function  fadeformodalClose(obj){
    	jQuery(obj).parents('.fadeformodal').addClass('modal-hide');
    	jQuery('body').css('overflow','auto');
    	clearInterval(timer);
    }
   
    function hostDtailFun(obj){
    		var object = jQuery(obj);
        	object.addClass("selectedLi");
        	var id = object.attr('id');
        	var groupid = object.attr('data-groupid');
        	var name = object.children('label').html();
        	var width = jQuery("header").width() - jQuery("#resource-cell").width() - 30;
        	var hostside = jQuery('#hostSide');
        	jQuery('#hostSide').attr('data-id',id);
        	object.parents('tr').addClass('current');
        	object.parents('tr').siblings().removeClass('current');
        	//内容显示
        	hostside.removeClass('modal-hide');
        	if(!jQuery("#hostSide").hasClass("modal-hide")){
        		jQuery("#hostSide").find(".article").width(width);
        	}
        	//hostside.find('.header-title-nobg h1').html("主机名称 - "+name);
        	hostside.find('.header-title-nobg .cell').html("<h1 data-id='"+id+"'>主机名称 - "+name+"</h1>");
        	laodWebMonitorMsg(id,groupid);
        	loadInterfaceMsg(id,groupid);
        	loadDiskUsageMsg(id,groupid);
        	loadResourceAlarmInfo(id);
        	loadHostDetailMsg(id);
            loadUsedRateInfo(id,groupid);
        	loadBaseInfo(id);
   	 }
        //加载单个主机中web监控信息
        function laodWebMonitorMsg(id,groupid){
        	jQuery("#webMonitorInfo").html('<tr><td colspan="4"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>'); 
        	jQuery.ajax({
        		  method: "POST",
        		  data: {
    				  	hostId:id
    			  },
        		  url: "${ctx}/overview/webMonitorInfo.json",
        		  success:function(data) {
        			  var  temp=[];
        			  for(var i=0;i<data.length;i++){
        				 if(data[i]!=null && data[i]!= ""){
        					 var name=data[i].name;
            				 var stepNo=data[i].stepNo;
            				 var checkInfo=data[i].recentTime;
            				 var status=data[i].status;
            				 var httptestid = data[i].httptestid;
            				 var info = data[i].info;
            				 var stepName = data[i].stepName;
            				
            				 //null 
            				 if(status=="0"){
            				 if(null==info||""==info){
            						 status="正常";
                					 temp.push('<tr><td>'+name+'</td><td>'+stepNo+'</td><td>'+checkInfo+'</td><td><font color="green">'+status+'</td>');
            					 }else{           						 
            						 status = "异常";
            						 temp.push('<tr><td>'+name+'</td><td>'+stepNo+'</td><td>'+checkInfo+'</td>');
            						 temp.push('<td><span onmouseover="hintBox.HintWraper(event, this, jQuery(\'#hintbox_'+httptestid+'\').html(), \'\');" onclick="hintBox.showStaticHint(event, this, jQuery(\'#hintbox_'+httptestid+'\').html(), \'\', false);" class="cursor-pointer"><font color="red">'+status+'</font><span style="display: none;"><span id="hintbox_'+httptestid+'"><font color="red">'+'步骤"'+stepName+'"失败:'+info+'</font></span></span></span></td>')
            					         					 
            				} 
            			
         					 	
            					 if(httptestid!=null){
        	       					 temp.push('<td><a href="${ctx}/php/httpdetails.php?fullscreen=0&groupid='+groupid+'&hostid='+id+'&httptestid='+httptestid+'"><img src="${ctx}/img/icon-huanzhuang.svg" width="13px" height="13px"></a></td></tr>'); 
                				 }else{
                   					 temp.push('<td><a href="#" onclick="promptWebInfo()"><img src="${ctx}/img/icon-huanzhuang.svg" width="13px" height="13px"></a></td></tr>'); 
                				 } 
            				 
                				 
            					 //status="正常";
            					 //temp.push('<tr><td>'+name+'</td><td>'+stepNo+'</td><td>'+checkInfo+'</td><td><font color="green">'+status+'</td>');
            					// if(httptestid!=null){
        	       					// temp.push('<td><a href="${ctx}/php/httpdetails.php?fullscreen=0&groupid='+groupid+'&hostid='+id+'&httptestid='+httptestid+'"><img src="${ctx}/img/icon-huanzhuang.svg" width="13px" height="13px"></a></td></tr>'); 
                				// }else{
                   					// temp.push('<td><a href="#" onclick="promptWebInfo()"><img src="${ctx}/img/icon-huanzhuang.svg" width="13px" height="13px"></a></td></tr>'); 
                				// }
            				 }/* else{
            					 status="异常";
            					 temp.push('<tr><td>'+name+'</td><td>'+stepNo+'</td><td>'+checkInfo+'</td><td><font color="red">'+status+'</td>');
            				 } */
            				 

            				 
        				 }
        			  }
        			 temp=temp.join(""); 
        			 jQuery("#webMonitorInfo").html(temp); 
        		  },
        		  error:function(textStatus){
        			  $.MsgBox.Alert(textStatus);
        		  }
        	  });
    	}
            
  
        function FlowConver(doubleNum){
        	//定义计数器
			var i = 0;
        	//循环除以1024，直到比1024小
			while(doubleNum > (1 << 10)){
				doubleNum  = doubleNum / (1 << 10);
				i ++;
			}
        	//保留两位小数 
			doubleNum = doubleNum.toFixed(2);
        	//switch判断数据的单位是什么，PS:多个数据判断的时候switch的速度要快于if
			switch(i){
				case 0:
					return doubleNum + " Kbps";
				case 1:
					//return "<font color='#009688'>" + doubleNum + " Mbps</font>";
					return doubleNum + " Mbps";
				case 2:
					//return "<font color='#FF5722'>" + doubleNum + " Gbps</font>";
					return doubleNum + " Gbps";
				case 3:
					return doubleNum + " Tbps";
				case 4:
					return doubleNum + " Pbps";
				case 5:
					return doubleNum + " Ebps";
				default:
					return doubleNum + " Kbps";
			}
   		}
   
    //加载接口信息
     function loadInterfaceMsg(id,groupid){
    	jQuery("#interfaceInfo").html('<tr><td colspan="6"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>'); 
    	jQuery.ajax({
  		  method: "POST",
  		  data: {
				  	hostId:id
			  },
  		  url: "${ctx}/overview/interfaceInfo.json",
  		  success:function(data) {
  			  var  temp=[];    
  			  for(var i=0;i<data.length;i++){
  				 if(data[i]!=null && data[i]!= ""){
  					 var status=data[i].status;
      				 var interfaceName=data[i].interfaceName;
      				 var inputFlow=data[i].inputFlow;
      				 var outputFlow=data[i].outputFlow;
      				 var statusChangedTime=data[i].statusChangedTime;
      				 var graphId=data[i].graphId;
      				 if(status == "0"){
      					 //up
      					 temp.push('<tr><td><span class="pot-green"></span><label>Up</label></td><td><img src="${ctx}/img/interface.svg" width="15"><label>'+interfaceName+'</label></td><td>'+FlowConver(inputFlow)+'</td><td class="sorttd">'+FlowConver(outputFlow)+'</td><td>'+statusChangedTime+'</td>');
      				 }else {
      					 //down
      					temp.push('<tr><td><span class="pot-red"></span><label>Down</label></td><td><img src="${ctx}/img/interface.svg" width="15"><label>'+interfaceName+'</label></td><td>'+FlowConver(inputFlow)+'</td><td class="sorttd">'+FlowConver(outputFlow)+'</td><td>'+statusChangedTime+'</td>')
      				 }
      				 //temp.push('<td><img src="${ctx}/img/interface.svg" width="15"><label>'+interfaceName+'</label></td><td class="sorttd">'+FlowConver(inputFlow)+'</td><td class="sorttd">'+FlowConver(outputFlow)+'</td><td>'+statusChangedTime+'</td>');
      				
       				 if(graphId!=null){
       					 temp.push('<td><a href="${ctx}/php/charts.php?fullscreen=0&groupid='+groupid+'&hostid='+id+'&graphid='+graphId+'"><img src="${ctx}/img/icon-huanzhuang.svg" width="13px" height="13px"></a></td></tr>');
       				 }else{
       					 temp.push('<td><a href="#" onclick="promptInfo()"><img src="${ctx}/img/icon-huanzhuang.svg" width="13px" height="13px"></a></td></tr>');
       				 }
       				 
  				 }
  			  }
  			 temp=temp.join(""); 
  			 jQuery("#interfaceInfo").html(temp); 
  		  }
  	  });
    }

//流量排序
var table=document.getElementById("tb");
var headers1=table.getElementsByClassName("thi1");
var headers2=table.getElementsByClassName("thi2");
function makeSortable(table) {
	    var table=document.getElementById("tb");
 	    for(var i=0;i<headers1.length;i++){
 	        (function(n){
 	            var flag=false;
 	            headers1[n].onclick=function(){
 	                // sortrows(table,n);
 	                var tbody=table.tBodies[0];//第一个<tbody>
 	                var rows=tbody.getElementsByTagName("tr");//tbody中的所有行
 	                //console.log("rows"+rows);
 	                rows=Array.prototype.slice.call(rows,0);//真实数组中的快照
						//console.log("row2" +rows);
 	                
 	                //基于第n个<td>元素的值对行排序
 	                rows.sort(function(row1,row2){
 	                	//获得第几行,第几列 0开始
 	                	//document .getElementById ("tbl").rows [1].cells[2];
 	                    var cell1=row1.getElementsByTagName("td")[2];//获得第n个单元格
 	                    var cell2=row2.getElementsByTagName("td")[2];
 	                    var val1=cell1.textContent||cell1.innerText;//获得文本内容
 	                    var val2=cell2.textContent||cell2.innerText;
 	                    //console.log("文本1"+val1);
 	                    //console.log("文本2"+val2);
 						
 	                    //中间值
 	                    //0.03kbps
 	                    var tval1= val1.indexOf("b") -1;  //单位为kbps、Mbps等等,从bps开始截取,减二得到数据(类似0.01kpbs)
 	                    var tval2= val2.indexOf("b") -1;  //单位为kbps、Mbps等等,从bps开始截取,减二得到数据(类似0.01kpbs)
 	                    
 	                    //var unit1 = val1.indexOf("s");   //得到最后一位
 	                   // var unit2 = val2.indexOf("s");
 	                    
 	                 	var v1 = val1.substring(0,tval1); //获得值
 	                    var v2 = val2.substring(0,tval2);
 	                    //需要对不同单位进行比较
 	                    //分为kbps mbps gbps tbps ebps pbps
 	                    //截取单位进行数值转换 包含k/m
 	                    if(val1.substring(tval1)=="Kbps"){
 	                    	v1 = v1;
 	                    }
							if(val1.substring(tval1)=="Mbps"){
 	                    	v1 = v1 * 1000;
 	                    }
 	                    if(val1.substring(tval1)=="Gbps"){
 	                    	v1 = v1 * 1000 * 1000;
 	                    }
 	                    if(val1.substring(tval1)=="Tbps"){
 	                    	v1 = v1 * 1000 * 1000 * 1000;
 	                    }
 	                    if(val1.substring(tval1)=="Pbps"){
 	                    	v1 = v1 * 1000 * 1000 * 1000 * 1000;
 	                    }
 	                    if(val1.substring(tval1)=="Ebps"){
 	                    	v1 = v1 * 1000 * 1000 * 1000 * 1000 * 1000;
 	                    }
 	                    //第二个值
							if(val2.substring(tval2)=="Kbps"){
 	                    	v2=v2;
 	                    }
						if(val2.substring(tval2)=="Mbps"){
 	                    	v2 = v2 * 1000;
 	                    	//console.log("值22-"+v2);
 	                    }
 	                    if(val2.substring(tval2)=="Gbps"){
 	                    	v2= v2 * 1000 * 1000;
 	                    }
 	                    if(val1.substring(tval2)=="Tbps"){
 	                    	v2 = v2* 1000 * 1000 * 1000;
 	                    }
 	                    if(val2.substring(tval2)=="Pbps"){
 	                    	v2= v2 * 1000 * 1000 * 1000 * 1000;
 	                    }
 	                    if(val2.substring(tval2)=="Ebps"){
 	                    	v2 = v2 * 1000 * 1000 * 1000 * 1000 * 1000;
 	                    }
 	            		//console.log("位置1"+tval1);
 	            		//console.log("位置2"+tval2);

 	                    
 	                    
 	            
 	                    //console.log("值1"+v1);
 	                    //console.log("值2"+v2);
 	                    
 	                    jQuery('#inSpan').removeClass("arrow-down").addClass('arrow-up');
 	                    jQuery('#outSpan').removeClass("arrow-down").removeClass("arrow-up");
 	                    if(parseFloat(v1)<parseFloat(v2)){
 	                        return -1;
 	                    }else if(parseFloat(v1)>parseFloat(v2)){
 	                        return 1;
 	                    }else{
 	                        return 0;
 	                    }
 	 	          		//console.log("排序");

 						//jQuery('OutSpan').addClass('arrow-up');
 	                });
					

 	                if(flag){
 	          		jQuery("#inSpan").removeClass("arrow-up").addClass("arrow-down");
	                jQuery('#outSpan').removeClass("arrow-down").removeClass("arrow-up");

 	                 rows.reverse();
 	                   
 	                }
 	                //在tbody中按它们的顺序把行添加到最后
 	                //这将自动把它们从当前位置移走，故没必要预先删除它们
 	                //如果<tbody>还包含了除了<tr>的任何其他元素，这些节点将会悬浮到顶部位置
 	                for(var i=0;i<rows.length;i++){
 	                    tbody.appendChild(rows[i]);
 	                }

 	                flag=!flag;
 	            }
 	        }(i));
 	    }
 	}

  	/* window.onload=function(){
 		var table=document.getElementById("tb");
 	    makeSortable(table);
 	}   */
 	for(i=0;i<headers1.length;i++){
 		makeSortable(i);
 	}
 	function makeSortable2(table) {
	    var table=document.getElementById("tb");
 	    for(var i=0;i<headers2.length;i++){
 	        (function(n){
 	            var flag=false;
 	            headers2[n].onclick=function(){
 	                // sortrows(table,n);
 	                var tbody=table.tBodies[0];//第一个<tbody>
 	                var rows=tbody.getElementsByTagName("tr");//tbody中的所有行
 	                //console.log("rows"+rows);
 	                rows=Array.prototype.slice.call(rows,0);//真实数组中的快照
						//console.log("row2" +rows);
 	                
 	                //基于第n个<td>元素的值对行排序
 	                rows.sort(function(row1,row2){
 	                	//获得第几行,第几列 0开始
 	                	//document .getElementById ("tbl").rows [1].cells[2];
 	                    var cell1=row1.getElementsByTagName("td")[3];//获得第n个单元格
 	                    var cell2=row2.getElementsByTagName("td")[3];
 	                    var val1=cell1.textContent||cell1.innerText;//获得文本内容
 	                    var val2=cell2.textContent||cell2.innerText;
 	                    //console.log("文本1"+val1);
 	                    //console.log("文本2"+val2);
 						
 	                    //中间值
 	                    //0.03kbps
 	                    var tval1= val1.indexOf("b") -1;  //单位为kbps、Mbps等等,从bps开始截取,减二得到数据(类似0.01kpbs)
 	                    var tval2= val2.indexOf("b") -1;  //单位为kbps、Mbps等等,从bps开始截取,减二得到数据(类似0.01kpbs)
 	                    
 	                    
 	                 	var v1 = val1.substring(0,tval1); //获得值
 	                    var v2 = val2.substring(0,tval2);
 	                    //需要对不同单位进行比较
 	                    //分为kbps mbps gbps tbps ebps pbps
 	                    //截取单位进行数值转换 包含k/m
 	                    if(val1.substring(tval1)=="Kbps"){
 	                    	v1 = v1;
 	                    }
							if(val1.substring(tval1)=="Mbps"){
 	                    	v1 = v1 * 1000;
 	                    }
 	                    if(val1.substring(tval1)=="Gbps"){
 	                    	v1 = v1 * 1000 * 1000;
 	                    }
 	                    if(val1.substring(tval1)=="Tbps"){
 	                    	v1 = v1 * 1000 * 1000 * 1000;
 	                    }
 	                    if(val1.substring(tval1)=="Pbps"){
 	                    	v1 = v1 * 1000 * 1000 * 1000 * 1000;
 	                    }
 	                    if(val1.substring(tval1)=="Ebps"){
 	                    	v1 = v1 * 1000 * 1000 * 1000 * 1000 * 1000;
 	                    }
 	                    //第二个值
							if(val2.substring(tval2)=="Kbps"){
 	                    	v2=v2;
 	                    }
						if(val2.substring(tval2)=="Mbps"){
 	                    	v2 = v2 * 1000;
 	                    	//console.log("值22-"+v2);
 	                    }
 	                    if(val2.substring(tval2)=="Gbps"){
 	                    	v2= v2 * 1000 * 1000;
 	                    }
 	                    if(val1.substring(tval2)=="Tbps"){
 	                    	v2 = v2* 1000 * 1000 * 1000;
 	                    }
 	                    if(val2.substring(tval2)=="Pbps"){
 	                    	v2= v2 * 1000 * 1000 * 1000 * 1000;
 	                    }
 	                    if(val2.substring(tval2)=="Ebps"){
 	                    	v2 = v2 * 1000 * 1000 * 1000 * 1000 * 1000;
 	                    }
 	            		//console.log("位置1"+tval1);
 	            		//console.log("位置2"+tval2);

 	                    
 	                    
 	            
 	                    //console.log("值1"+v1);
 	                    //console.log("值2"+v2);
 	                    //添加类样式
 	                    jQuery('#outSpan').removeClass("arrow-down").addClass('arrow-up');
 	                    jQuery('#inSpan').removeClass("arrow-down").removeClass("arrow-up");
 	                    if(parseFloat(v1)<parseFloat(v2)){
 	                        return -1;
 	                    }else if(parseFloat(v1)>parseFloat(v2)){
 	                        return 1;
 	                    }else{
 	                        return 0;
 	                    }
 	            
	                });
					

	                if(flag){
	 	          		jQuery("#outSpan").removeClass("arrow-up").addClass("arrow-down");
 	                    jQuery('#inSpan').removeClass("arrow-down").removeClass("arrow-up");
	                    rows.reverse();
	                   //修改类样式

	                }
 	                //在tbody中按它们的顺序把行添加到最后
 	                //这将自动把它们从当前位置移走，故没必要预先删除它们
 	                //如果<tbody>还包含了除了<tr>的任何其他元素，这些节点将会悬浮到顶部位置
 	                for(var i=0;i<rows.length;i++){
 	                    tbody.appendChild(rows[i]);
 	                }

 	                flag=!flag;
 	            }
 	        }(i));
 	    }
 	}


 	for(i=0;i<headers2.length;i++){
 		makeSortable2(i);
 	} 	

 	
 	
     function promptInfo(){
      	$.MsgBox.Alert("消息","进口流量与出口流量未建立图形关系！");
      }
     function promptWebInfo(){
      	$.MsgBox.Alert("消息","未建立图形关系！");
      }
    var graphId;
    
    //加载磁盘使用率信息
    function loadDiskUsageMsg(id,groupid){
    	jQuery("#diskUsageInfo").html('<tr><td colspan="6"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>'); 
    	jQuery.ajax({
    		  method: "POST",
    		  data: {
  				  	hostId:id
  			  },
    		  url: "${ctx}/overview/diskUsageInfo.json",
    		  
    		  success:function(data) {
    			  if(data.length == 0){
    				  //jQuery("#diskUsageInfo").hide();
    				  jQuery("#diskOnly_widget").hide();
    			  }else{
    				  jQuery("#diskOnly_widget").show();
    			  var  temp=[];
    			  for(var i=0;i<data.length;i++){
    				 if(data[i]!=null && data[i]!= ""){
    					 var driveLetter=data[i].driveLetter;
        				 var totalCapacity=data[i].totalCapacity;
        				 var usedCapacity=data[i].usedCapacity;
        				 var freeCapacity=data[i].freeCapacity;
        				 var usedRate=data[i].usedRate;
        				 var totalItemid=data[i].totalItemid;
        				 var usageItemid=data[i].usageItemid;
        				 var graphId=data[i].graphId;
         				 //console.log('graphId:'+graphId);
         				 if(totalCapacity!=0 && totalCapacity!=null){
         					 if(graphId!=null){
             					 temp.push('<tr><td><img src="${ctx}/img/disk.svg" width="15"> <label>'+driveLetter+'</label></td><td>'+totalCapacity+'GB</td><td>'+usedCapacity+'GB</td><td>'+freeCapacity+'GB</td><td><label>'+usedRate+'%</label><span class="xs_slide" title="'+usedRate+'%"><span style="width:'+usedRate+'%"></span></span></td><td><a href="${ctx}/php/charts.php?fullscreen=0&groupid='+groupid+'&hostid='+id+'&graphid='+graphId+'"><img src="${ctx}/img/icon-huanzhuang.svg" width="13px" height="13px"></a></td></tr>');
    	
             				 }else{ //点图标，弹出提示框
             					 temp.push('<tr><td><img src="${ctx}/img/disk.svg" width="15"> <label>'+driveLetter+'</label></td><td>'+totalCapacity+'GB</td><td>'+usedCapacity+'GB</td><td>'+freeCapacity+'GB</td><td><label>'+usedRate+'%</label><span class="xs_slide" title="'+usedRate+'%"><span style="width:'+usedRate+'%"></span></span></td><td><a onclick="message()"><img src="${ctx}/img/icon-huanzhuang.svg" width="13px" height="13px"></a></td></tr>');
             				 }
         				 }
    				 }
    			  }
    			 temp=temp.join(""); 
    			 jQuery("#diskUsageInfo").html(temp); 
    			  }
    		  }
    		  
    	  });
    }
    
    function message(){
     	$.MsgBox.Alert("消息","磁盘总容量与使用量未建立图形关系！");
     }
    //根据totalItemid和usageItemid获取对应的groupid
    var graphUrl = function(a,b){
    	var graphId = '';
    	return function(){
    		jQuery.ajax({
     			  method: "POST",
     			  data: {
     					  	totalItemid:a,
     					  	usageItemid:b
     				  },
     			  url: "${ctx}/overview/getGraphidByItemids.json",
     			  success:function(data) {
     				  for(var i=0;i<data.length;i++){
     					  if(data[i]!=null && data[i]!= ""){
     						  if(i==0){
     							  graphId = data[i];
     						  }
     					  }
     				  }
     			  }
     		  });
    	}
    };

   
    //加载主机详细信息
    function loadHostDetailMsg(id){
    	jQuery.ajax({
  		  method: "POST",
  		  data: {
				  	hostId:id
			  },
  		  url: "${ctx}/overview/hostDetailInfo.json",
  		  success:function(data) {
  			 var  temp=[];
  			 var $computerMessage = jQuery('#computerMessage');
  			 temp.push('<table class="list-table2"><tbody>');
  			 var status=data.status;
			 var ip=data.ip;
			 var os=data.os;
			 var name=data.name;
			 var description=data.description;
			 var startTime=data.startTime;
			 var duration=data.duration;
			 if(data==""||data==null){
				 ip="";
				 os="";
				 name="";
				 description="";
				 startTime="";
				 duration="";
			 }
			 if(startTime!=0){
				 startTime=getLocalTime(startTime); 
			 }else{
				 startTime="";
			 }
			 if(status=="0"){
				 temp.push('<tr><td>主机状态</td><td><span class="pot-green"></span><label>监控中</label></td></tr>');
			 }else{
				 temp.push('<tr><td>主机状态</td><td><span class="pot-red"></span><label>未监控</label></td></tr>');
			 }
			temp.push('<tr><td style="width:60px">IP地址</td><td>'+ip+'</td></tr><tr><td>操作系统</td><td>'+os+'</td></tr><tr><td>主机名称</td><td>'+name+'</td></tr><tr><td>描述</td><td>'+description+'</td></tr><tr><td>启动时间</td><td>'+startTime+'</td></tr><tr><td>持续时间</td><td>'+duration+'</td></tr>');
  			temp.push('</tbody></table>');
  			$computerMessage.html(temp.join(''));
  		  }
  	  });
    }
    
    //加载资源报警信息
    function loadResourceAlarmInfo(id){
    	jQuery("#resourceAlarmInfo").html('<tr><td colspan="8"><div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div></td></tr>'); 
    	jQuery.ajax({
   		  method: "POST",
   		  async: false,
   		  data: {
 				  	hostId:id
 			  },
   		  url: "${ctx}/overview/resourceAlarmInfo.json",
   		  success:function(data) {
			  if(data.length == 0){  
					  var widgetObj = jQuery('#resourceAlarm_widget');
					  jQuery('.body', widgetObj).slideUp(50);
					  jQuery('.dashbrd-widget-foot', widgetObj).slideUp(50);
					  jQuery("#resourceAlarmInfo").html("");

			  }else{
				  var widgetObj = jQuery('#resourceAlarm_widget');
					jQuery('.body', widgetObj).slideDown(50);
					jQuery('.dashbrd-widget-foot', widgetObj).slideDown(50);
				  

				  
				  jQuery("#diskOnly_widget").show();
   			  
   			  var  temp=[];
   			  for(var i=0;i<data.length;i++){
   				 if(data[i]!=null && data[i]!= ""){
   					 var host=data[i].host;
       				 var description=data[i].description;
       				 var eventMsg=data[i].eventMsg
       				 var startClock=data[i].startClock;
       				 var subClock=data[i].subClock;
       				 var messages=data[i].messages;
       				 var acknowledged=data[i].acknowledged;
       				 var action=data[i].action;
       				 var alertTime=data[i].alertTime;
       				 var status=data[i].status;
       				 var eventid=data[i].eventid;
       				 var priority=data[i].priority;
       				//获得本地时间
  				     startClock=getLocalTime(startClock);
       				 temp.push('<tr><td>'+host+'</td>');
       				 if(priority=="0"){
       					temp.push('<td class="info-bg">');
       				 }else if(priority=="1"){
       					 temp.push('<td class="info-bg">');
       				 }else if(priority=="2"){
       					 temp.push('<td class="warning-bg">');
       				 }else if(priority=="3"){
       					 temp.push('<td class="average-bg">');
       				 }else if(priority=="4"){
       					 temp.push('<td class="high-bg">');
       				 }else if(priority=="5"){
       					 temp.push('<td class="high-bg">');
       				 }
       				 //if () {
       					 //红色 high-bg;橙色 average-bg;紫色 info-bg;黄色 warning-bg;
       					 //
      			     temp.push('<span onmouseover="hintBox.HintWraper(event, this, jQuery(\'#hintbox_'+eventid+'\').html(), \'\', \'max-width:500px\');" onclick="hintBox.showStaticHint(event, this, jQuery(\'#hintbox_'+eventid+'\').html(), \'\', false, \'max-width:500px\');" class="link-action">'+description+'<span style="display: none;"><span id="hintbox_'+eventid+'"><div><table class="list-table"><thead><tr><th>时间</th><th>状态</th><th>持续时间</th><th>时长</th></tr></thead><tbody>')
      			     for(var j = 0; j< eventMsg.length; j++){
      			    	if(eventMsg[j]!=null && eventMsg[j]!= ""){
      			    		var startTime=eventMsg[j].startClock;
         					startTime=getLocalTime(startTime);
         					var status1=eventMsg[j].status;
         					var subClock1=eventMsg[j].subClock;
         					var duration1=eventMsg[j].duration;
         					var acknowledged1=eventMsg[j].acknowledged;
         					temp.push('<tr><td>'+startTime+'</td>')
         					if(status1==1){
         						temp.push('<td><span style="color: #DC0000">问题</span></td>');
         					}else{
         						temp.push('<td><span style="color: #429e47">正常</span></td>');
         					}
      			    		temp.push('<td>'+subClock1+'</td><td>'+duration1+'</td>')
      			    		/* if(acknowledged1==1){
      			    			temp.push('<td><a class="link-alt green" >是</a></td></tr>');
      			    		}else{
      			    			temp.push('<td><a class="link-alt red" >不</a></td></tr>');
      			    		} */
      			    		
      			    		/* if(acknowledged1==0){
      	       					 temp.push('<td><a href="${ctx}/php/zabbix.php?action=acknowledge.edit&eventids[]='+eventid+'"><font color="red">不</td>');
      	       				 }else{
      	       					temp.push('<td><a href="${ctx}/php/zabbix.php?action=acknowledge.edit&eventids[]='+eventid+'"><font color="green">是</td>');
      	       				 } */
      			    		
      			    	}
      				 }
      				 temp.push('</tbody></table></div></span></span></span></td>');
       				 //}
       				 temp.push('<td>'+startClock+'</td><td>'+subClock+'</td><td>'+messages+'</td>');
       				/*  if(acknowledged==0){
       					 temp.push('<td><a href="${ctx}/php/zabbix.php?action=acknowledge.edit&eventids[]='+eventid+'"><font color="red">不</td>');
       				 }else{
       					temp.push('<td><a href="${ctx}/php/zabbix.php?action=acknowledge.edit&eventids[]='+eventid+'"><font color="green">是</td>');
       				 } */
       				if(alertTime >= 1){
       					jQuery.ajax({
      						 type:'post',
		    				 url:"${ctx}/overview/resourceAlert.json", //请求数据的地址
		    				 async: false,
		    				 data : {
		    					 eventId:eventid
		    				 },
		    				 success:function(data){
		    					 var ltd = '<td><span class="link-action red" onmouseover="hintBox.HintWraper(event, this, jQuery(\'#hintbox_action_'+eventid+'\').html(), \'\', \'max-width:500px\');" onclick="hintBox.showStaticHint(event, this, jQuery(\'#hintbox_action_'+eventid+'\').html(), \'\', false, \'max-width:500px\');">'+alertTime+'<span style="display: none;"><span id="hintbox_action_'+eventid+'"><table class="list-table"><thead><tr><th>时间</th><th>用户</th><th>细节</th><th>状态</th><th>信息</th></tr></thead><tbody>';
		    					 var tr = '';
		    					 for (var i = 0; i < data.size(); i++) {
		    						tr += '<tr>' 
									tr += '<td>' + data[i].time + '</td>';
									if(data[i].name == '' && data[i].surname == '') {
										tr += '<td>' + data[i].alias + '</td>';
									} else {
										tr += '<td>' + data[i].alias + '(' + data[i].name + " " + data[i].surname + ')' + '</td>';
									}
									tr += '<td>' + data[i].description + '</td>';
									if(data[i].status == 1) {
										tr += '<td><span class="green">已送达</span></td>';
									} else {
										tr += '<td><span class="red">未发送</span></td>';
									}
									if(data[i].error == '') {
										tr += '<td></td>';
									} else {
										tr += '<td><span class="status-red cursor-pointer" onmouseover="hintBox.HintWraper(event, this,\'' + data[i].error + '\', \'\', \'max-width:500px;color:red\');" onclick="hintBox.showStaticHint(event, this,\'' + data[i].error + '\', \'\', false, \'max-width:500px;color:red\');"><b>×</b></span></td>';
									}
									tr += '</tr>';
								}
		    					var rtd = '</tbody></table></span></span></span></td>';
		    					temp.push(ltd+tr+rtd);
		    				 }
					     });
       				}else{
       					temp.push('<td></td>');
       				}       				
       			/* 	if(status==0){
       					temp.push('<td><font color="green">启用</td></tr>');
       				}else{
       					temp.push('<td><font color="red">禁用</td></tr>');
       				} */
   				 }
   			  }
   			 temp=temp.join(""); 
   			 jQuery("#resourceAlarmInfo").html(temp); 
   		  }
   		  }
   	  });
    	
    }
    
    //加载拓扑图信息
    function loadSysmapInfo(){
    	jQuery('#mapbox').html('<div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div>');
    	var left = jQuery('#mapChooseList').offset().left + 12;
    	var top = jQuery('#mapChooseList').offset().top + 12;
    	var html = '<ul class="action-menu action-menu-top" style="left:'+left+'px;top:'+top+'px;height: 300px;overflow: auto;display:none;" id="sysmap">'
    			+ '</ul>';
    	jQuery('body').append(html);
    	jQuery.ajax({
     		  method: "POST",
     		  url: "${ctx}/overview/topologicalInfo.json",
     		  success:function(data) {
     			 //jQuery('.loadingindex').hide();
     			//jQuery('.loading', '#mapbox').hide();
     			jQuery('#mapbox').html('<div class="loading"><label style="color:#333;font-size:18px;fill:#333;">未发现任何数据 </label></div>');
     			 var temp = [];
     			 var tempId;
     			 jQuery('#sysmap').empty('');
     			  for(var i=0;i<data.length;i++){
     				 if(data[i]!=null && data[i]!= ""){
     					 var sysmapId=data[i].sysmapId;
     					 var sysmapName=data[i].sysmapName;
     					 var isSelected=data[i].isSelected;
     					// obj.add(new Option(sysmapName,sysmapId)); 
     					if(isSelected == "1"){
     						temp.push('<li><a class="action-menu-item selected" value="'+sysmapId+'">'+sysmapName+'</a></li>');
     						tempId = sysmapId;
     					}else{
     						temp.push('<li><a class="action-menu-item" value="'+sysmapId+'">'+sysmapName+'</a></li>');
     					}    					
     					
     				 }
     			  }
     			 jQuery('#sysmap').append(temp.join(''));
     			 if(tempId!=""&& tempId!=null){
     				var change = jQuery("#mapbox_widget").data("type");
     				 mapInit(tempId,change);
     			 }
     		  }
     	  });
    }
    
    //拓扑图名字selectchange事件
    function selectChange(){
    	var obj=document.getElementById('sysmap');
		var index=obj.selectedIndex; //序号，取当前选中选项的序号
		var val = obj.options[index].value;
    	mapInit(val);
    }
    
    function mapInit(id,type){
    	if(type == "max"){
    		var height = jQuery(".mainViewContent").height()-70;
    		jQuery('#mapbox').html('<iframe id="map" width="100%" height="'+height+'" src="../php/zabbix.php?action=map.view2&sysmapid='+id+'&fullscreen=1" onload="loadIframe()" class="iframe"></iframe>');
    	}else{
	    	jQuery('#mapbox').html('<iframe id="map" width="100%" height="550" src="../php/zabbix.php?action=map.view2&sysmapid='+id+'&fullscreen=1" onload="loadIframe()" class="iframe"></iframe>');
    	}
    }
    function loadIframe(){
    	jQuery('.iframe').contents().find('body').css("background-color", "#fff");
    	jQuery('.iframe').contents().find('body').css("margin-bottom", 0);
    }
    function comHeight(id){
    	var iframe = document.getElementById(id); 
    	var bHeight = iframe.contentWindow.document.body.scrollHeight;  
        var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;  
        var height = Math.max(bHeight, dHeight); 
        return height;
    }
    function hideDom(){
    	jQuery(".memRate").contents().find('html').addClass('mapHtml');
    	jQuery('.memRate').contents().find('body').css("margin-bottom", 0);
    	jQuery('.memRate').contents().find('body .filter-btn-container').remove();
    	jQuery('.memRate').contents().find('body .header-title').remove();
    	jQuery('.memRate').contents().find('body .header-title').remove();
    }
    function loadIframeMem(){
    	var height1;
    	setTimeout(function(){
    		height1 = comHeight("memroyRate");
    		jQuery("#memroyRate").height(height1);
    	},100)
    	hideDom();
    }
    function loadIframeCpu(){
    	var height2;
    	setTimeout(function(){
    		height2 = comHeight("cpuRate");
    		jQuery("#cpuRate").height(height2);
    	},100)
    	hideDom();
    }
    function loadUsedRateInfo(id,groupid){
    		//jQuery('#cpuOnly').prepend('<div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div>');
	    	jQuery.ajax({
	   		  method: "POST",
	   		  data: {
				  	hostId:id
			  },
	   		  url: "${ctx}/overview/hostUsedRateInfo.json",
	   		  success:function(data) {
	   			//jQuery('#cpuOnly .loading').remove();
	   			  var cpuRate=data.cpuRate;
	   			  var memoryRate=data.memoryRate;
	   			  var cpuRateGraphId=data.cpuRateGraphId;
	   			  var memoryRateGraphId=data.memoryRateGraphId;
	   			  if(groupid && cpuRateGraphId){
	   				 jQuery("#cpuUseRate_widget").show();
	   			 	 jQuery('.iframeContent').html('<iframe id="cpuRate" class="memRate" width="100%" height="450" src="../php/charts.php?groupid='+groupid+'&hostid='+id+'&graphid='+cpuRateGraphId+'&fullscreen=1" onload="loadIframeCpu()" class="iframeCpu"></iframe>');
	   			  }else{
	   				  jQuery("#cpuUseRate_widget").hide();
	   			  }
	   			  if(groupid && memoryRateGraphId){
	   				 jQuery("#memoryUseRate_widget").show();
	   			 	 jQuery('.iframeContentM').html('<iframe id="memroyRate" class="memRate" width="100%" height="450" src="../php/charts.php?groupid='+groupid+'&hostid='+id+'&graphid='+memoryRateGraphId+'&fullscreen=1" onload="loadIframeMem()" class="iframeCpu"></iframe>')
	   			  }else{
	   				jQuery("#memoryUseRate_widget").hide();
	   			  }
		   		  jQuery('#container-cpuOnly').highcharts(Highcharts.merge(gaugeOptions, {
		   		        yAxis: {
		   		            min: 0,
		   		            max: 100,
		   		            title: {
		   		                text: 'cpu使用率'
		   		            }
		   		        },
		   		        credits: {
		   		            enabled: false
		   		        },
		   		        navigation: {
		   		            buttonOptions: {
		   		                enabled: false
		   		            }
		   		        },
		   		        series: [{
		   		            name: '',
		   		            data: [cpuRate],
		   		            dataLabels: {
		   		                format: '<div style="text-align:center"><span style="font-size:20px;color:' +
		   		                ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y:.1f}</span><br/>' +
		   		                '<span style="font-size:12px;color:silver">%</span></div>'
		   		            },
		   		            tooltip: {
		   		                valueSuffix: '%'
		   		            }
		   		        }]
		   		    }));
		   			
		   			jQuery('#container-memoryOnly').highcharts(Highcharts.merge(gaugeOptions, {
		   		        yAxis: {
		   		            min: 0,
		   		            max: 100,
		   		            title: {
		   		                text: '内存使用率'
		   		            }
		   		        },
		   		        credits: {
		   		            enabled: false
		   		        },
		   		        navigation: {
		   		            buttonOptions: {
		   		                enabled: false
		   		            }
		   		        },
		   		        series: [{
		   		            name: '',
		   		            data: [memoryRate],
		   		            dataLabels: {
		   		                format: '<div style="text-align:center"><span style="font-size:20px;color:' +
		   		                ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y:.1f}</span><br/>' +
		   		                '<span style="font-size:12px;color:silver">%</span></div>'
		   		            },
		   		            tooltip: {
		   		                valueSuffix: '%'
		   		            }
		   		        }]
		   		    }));
		   			  
		   			var chart,point;
	   		        
	   		        chart = jQuery('#container-cpuOnly').highcharts();
	   		        if (chart) {
	   		            point = chart.series[0].points[0];
	   		            point.update(point.y);
	   		        }
	   		        chart = jQuery('#container-memoryOnly').highcharts();
	   		        if (chart) {
	   		            point = chart.series[0].points[0];
	   		            point.update(point.y);
	   		        }
	   		 	 }
	   	  	});
		
	}
    
    
    //获取平均响应时间、丢包率
    function loadBaseInfo(id){
    	//jQuery('#responseAndIcmppingLoss').prepend('<div class="loading"><img src="${ctx}/img/ajax-loader.gif"><label>正在加载请稍等……</label></div>');
    	jQuery.ajax({
  		  method: "POST",
  		  data: {
			  	hostId:id
		  },
  		  url: "${ctx}/overview/hostBaseInfo.json",
  		  success:function(data) {
  			//jQuery('#responseAndIcmppingLoss .loading').remove();
  			  var responseTime=data.responseTime;
  			  var packetLossRate=data.packetLossRate;
  			  //console.log(responseTime + packetLossRate);
  			  
	  		    jQuery('#container-responseTime').highcharts(Highcharts.merge(gaugeOptions, {
	  		        yAxis: {
	  		            min: 0,
	  		            max: 100,
	  		            title: {
	  		                text: '平均响应时间（ms）'
	  		            }
	  		        },
	  		        credits: {
	  		            enabled: false
	  		        },
	  		        navigation: {
	  		            buttonOptions: {
	  		                enabled: false
	  		            }
	  		        },
	  		        series: [{
	  		            name: '平均响应时间（ms）',
	  		            data: [responseTime],
	  		            dataLabels: {
	  		                format: '<div style="text-align:center"><span style="font-size:20px;color:' +
	  		                ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>' +
	  		                '<span style="font-size:12px;color:silver">ms</span></div>'
	  		            },
	  		            tooltip: {
	  		                valueSuffix: ' ms'
	  		            }
	  		        }]
	  		    }));
	  		    jQuery('#container-icmppingLoss').highcharts(Highcharts.merge(gaugeOptions, {
	  		        yAxis: {
	  		            min: 0,
	  		            max: 100,
	  		            title: {
	  		                text: '丢包率'
	  		            }
	  		        },
	  		        credits: {
	  		            enabled: false
	  		        },
	  		        navigation: {
	  		            buttonOptions: {
	  		                enabled: false
	  		            }
	  		        },
	  		        series: [{
	  		            name: '丢包率',
	  		            data: [packetLossRate],
	  		            dataLabels: {
	  		                format: '<div style="text-align:center"><span style="font-size:20px;color:' +
	  		                ((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y:.1f}</span><br/>' +
	  		                '<span style="font-size:12px;color:silver">%</span></div>'
	  		            },
	  		            tooltip: {
	  		                valueSuffix: '%'
	  		            }
	  		        }]
	  		    }));
	  		    
	  		  var chart,point;
	  		  	chart = jQuery('#container-speed').highcharts();
		        if (chart) {
		            point = chart.series[0].points[0];
		            point.update(point.y);
		        }
		        // RPM
		        chart = jQuery('#container-rpm').highcharts();
		        if (chart) {
		            point = chart.series[0].points[0];
		            point.update(point.y);
		        }
	  		    
  			  
  		  	}
     	 });
    }
    
    //判断数组是否包含某某元素
    Array.prototype.contains = function ( needle ) {
		  for (var k in this) {
		    if (this[k] == needle) return true;
		  }
		  return false;
	}
    
  //验证字符串是否是数字
    function checkNumber(theObj) {
      var reg = /^[1-9]?[0-9]$/;
      if (reg.test(theObj)) {
    	  if(theObj==0){
    		  return false;
    	  }else{
    		  return true;
    	  }
      }
      return false;
    }
    
  
  //cpu 内存 磁盘 设置功能 取消事件
  function readlocalstorage(id){
	  var role = jQuery('#'+id).attr('data');
	  type = localStorage.getItem("local"+role+"type");
	  limit = localStorage.getItem("local"+role+"limit");
	  bignum = localStorage.getItem("local"+role+"bignum");
	  smallnum = localStorage.getItem("local"+role+"smallnum");
	  jQuery('#' + role + 'type').val(type);
	  jQuery('#' + role + 'limit').val(limit);
	  jQuery('#' + role + 'bignum').val(bignum);
	  jQuery('#' + role + 'smallnum').val(smallnum);
  }
 
function validate(id){
	var role = jQuery('#'+id).attr('data');

  	jQuery("#"+role+"bignum").keyup(function(){
		big=jQuery("#"+role+"bignum").val();
		if(!checkNumber(big)){
			jQuery("#"+role+"bignum").val('');
			return false;
		}	
		if( parseInt(big) < 0 || parseInt(big) >= 100){
			jQuery("#"+role+"bignum").val('');
			return false;
	   }
	});
  	
  	jQuery("#"+role+"smallnum").keyup(function(){
  		small=jQuery("#"+role+"smallnum").val();
  		if(!checkNumber(small)){
  			//jQuery('.loadingindex').hide();
  			//alert("请输入整数");
  			jQuery("#"+role+"smallnum").val('');
  			return false;
  		}	
  		if( parseInt(small) < 0 || parseInt(small) >= 100){
  			//jQuery('.loadingindex').hide();
  			//alert("请输入0~100的整数");
  			jQuery("#"+role+"smallnum").val('');
  			return false;
  		}
  	});
}

//获得本地时间
function getLocalTime(nS) {     
    return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");      
 }
 
//用户刷新时间
function getUserRefresh(){
	  jQuery.ajax({
		  method: "POST",
		  url: "${ctx}/formview/getUserRefresh.json",
		  async:false,
		  data: {
			  userId:userId,
		  },
		  success:function(data) {
			  if(null != data && 0 != data){
				  refreshTime = data*1000;
			  }else{
				  refreshTime = 60000;
			  }

		  } 
	  });	  
	  return refreshTime;
}
//获取URL
function getUrl(){
    var hostUrl = window.location.href.split('?')[1];
    if(hostUrl){
        var hostId=hostUrl.split('&')[0].split('=')[1];
       
    }
     var args={
    	urlId:document.getElementById("hostid").value,
    	groupId:document.getElementById("groupid").value,
    	dataId:document.getElementById("dataId").value,
    	hostId:hostId
    };
    return args; 
}

</script>
