Search Page Monitor Gadget
test for the montior
by Nivaldo
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/highcharts/4.0.1/highcharts.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/highcharts/4.0.1/themes/sand-signika.js"></script>
<div id="ApaProducts" style="width:360px; height:200px;"></div>
CSS
body {
margin: 0 0 0 0;
width: 360px;
height: 200px;
}
tspan {
font: normal 11px sans-serif;
}
JavaScript
var statsRequest;
function displayStats() {
//var url = "http://mlstage1.apa.org:8004/pimain/services/test-graphs/test-gadget.xqy";
var url = "http://ml1r.apa.org:8354/gadget/test-gadget-sp2.xqy";
if (window.XMLHttpRequest) {
statsRequest = new XMLHttpRequest();
//console.log(statsRequest);
//console.log("statsRequest initated - option 1");
}
else {
statsRequest = new ActiveXObject("Microsoft.XMLHTTP");
//console.log("statsRequest initated - option 2");
}
if (statsRequest == null) {
alert("Your browser doesn't support Ajax");
};
//statsRequest = new ActiveXObject("Microsoft.XMLHTTP");
statsRequest.onreadystatechange = writeStats;
statsRequest.open("GET", url, true);
statsRequest.send(null);
//setTimeout("displayStats()", 600000);
setTimeout("displayStats()", 60000);
}
function writeStats() {
if (statsRequest.readyState == 4) {
if (statsRequest.status == 200) {
var dataObj = (eval('{' + statsRequest.responseText + '}'));
//alert(statsRequest.responseText);
var datavalues = dataObj[0].datavalues;
var xcategories = dataObj[1].xcategories;
var ytitle = dataObj[2].ytitle;
var valuesuffix = dataObj[3].valuesuffix;
var charttype = dataObj[4].charttype;
var chart = $('#ApaProducts').highcharts({
chart: {
type: charttype, //'column'
zoomType: 'xy',
inverted: true,
//backgroundColor: '#FAEBD7',
shadow: false
},
title: {
text: 'Search Page Monitor Gadget (LIVE Server)'
},
subtitle: {
text: ''
},
credits: {
text: 'Click here for Monitor App at LIVE Server',
...