Main.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>主动监控</title>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="FusionCharts.js"></script>
<script type="text/javascript">
var openUrl;
//var hostIP = "http://10.204.32.116/ActiveChart";
var hostIP = "http://localhost:9999";
Date.prototype.Format = function(formatStr) {
var str = formatStr;
var now = new Date();
var Week = ['日', '一', '二', '三', '四', '五', '六'];
str = str.replace(/yyyy|YYYY/, now.getFullYear());
str = str.replace(/yy|YY/, (now.getYear() % 100) > 9 ? (now.getYear() % 100).toString() : '0' + (now.getYear() % 100));
str = str.replace(/MM/, now.getMonth() > 9 ? now.getMonth().toString() : '0' + now.getMonth());
str = str.replace(/M/g, now.getMonth());
str = str.replace(/w|W/g, Week[now.getDay()]);
str = str.replace(/dd|DD/, now.getDate() > 9 ? now.getDate().toString() : '0' + now.getDate());
str = str.replace(/d|D/g, now.getDate());
str = str.replace(/hh|HH/, now.getHours() > 9 ? now.getHours().toString() : '0' + now.getHours());
str = str.replace(/h|H/g, now.getHours());
str = str.replace(/mm/, now.getMinutes() > 9 ? now.getMinutes().toString() : '0' + now.getMinutes());
str = str.replace(/m/g, now.getMinutes());
str = str.replace(/ss|SS/, now.getSeconds() > 9 ? now.getSeconds().toString() : '0' + now.getSeconds());
str = str.replace(/s|S/g, now.getSeconds());
return str;
}
var timeout = 10000;
function updateChart(DOMId) {
$(document).ready(function() {
var dn = System.Gadget.Settings.readString("dn");
var kpiId = System.Gadget.Settings.readString("kpiId");
var kpiName = System.Gadget.Settings.readString("kpiName");
System.Debug.outputString(dn); //DEBUG CODE
System.Debug.outputString(kpiId); //DEBUG CODE
System.Debug.outputString(kpiName); //DEBUG CODE
$.ajax({
type: "POST", //访问WebService使用Post方式请求
contentType: "application/json", //WebService 会返回Json类型
url: hostIP + "/Chart/GadgetService.asmx/SetKpiValueByDN", //调用WebService的地址和方法名称组合 ---- WsURL/方法名
data: "{dn:'" + dn + "',chsName:'" + kpiName + "',KpiId:" + kpiId + "}", //这里是要传递的参数,格式为 data: "{paraName:paraValue}",下面将会看到
dataType: 'json',
success: function(result) { //回调函数,result,返回值
openUrl = result.d + "";
System.Debug.outputString("URL:" + result.d); //DEBUG CODE
}
});
});
var strURL = hostIP +"/Chart/Gallery/Data/Angular5.xml?time=a" + Date.prototype.Format("yyyyMMddhhmmss");
var myChart = new FusionCharts(hostIP + "/Chart/Charts/AngularGauge.swf", "myChartId", "200", "200", "0", "0");
myChart.setDataURL(strURL);
myChart.render("chartdiv");
Load_Settings();
timerID = setTimeout(updateChart, timeout);
//var setI = setInterval(updateChart, 2000);
}
function Load_Settings() {
try {
speedcfg = System.Gadget.Settings.readString("speed");
if (speedcfg) timeout = parseInt(speedcfg) * 1000;
System.Debug.outputString("加载" + timeout); //DEBUG CODE
} catch (e) { };
}
function Initialize() {
try {
System.Gadget.settingsUI = "options.html";
Load_Settings();
} catch (e) {
System.Debug.outputString("调试信息" + e); //DEBUG CODE
};
}
function windowOpen() {
window.open(openUrl, "NewWin", "height=524,width=1100,top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,fullscreen=yes");
}
</script>
</head>
<body onload="Initialize();updateChart();" style=" margin:0; width: 200px; height: 200px; background-repeat:no-repeat; background:url(bgbk5.png);">
<form >
</table>
</body>
</html>