
Untitled
By: a guest on
Sep 20th, 2012 | syntax:
JavaScript | size: 2.61 KB | hits: 28 | expires: Never
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TerraXML Devices</title>
<link href="css/smoothness/jquery-ui-1.8.23.custom.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery-1.7.2.min.js""></script>
<script type="text/javascript" src="jquery-ui-1.8.23.custom.min.js"></script>
</script>
<script type="text/javascript">
$(document).ready(function() {
createDynamicTable($("#tbl"), 4, 16);
updateTable();
setInterval("updateTable()", 4000);
});
function updateTable() {
$.ajax({
type: "GET",
url: "xml_parser.exe",
ifModified:true,
dataType: "xml",
statusCode: {
404: function() {
console.log('Page not found');
return;
}
},
success: function(xml, status) {
if (status != 'success') {
return;
}
$("#tbl td.tableCell").each(function() {
var found_dev = 0;
var id = $(this).attr('id');
$(xml).find('dev').each(function(){
var log = '';
var diag = '';
var error = '';
var address = $(this).attr('id');
var status = $(this).attr('status');
console
if (status & 0x01) {
log = '(D)';
}
if (status & 0x02) {
log = '(L)';
}
if (status & 0x08) {
log = '(E)';
}
var title = $(this).attr('title');
if (id == address) {
if (status != 0) {
$("#tbl td.tableCell")
$("#"+address).html('<button><a href=\"device.html?dev=' + address + '\">' + title + ' ' + error + diag + log + '</a></button>');
found_dev = 1;
}
}
});
if (!found_dev) {
$("#tbl td.tableCell")
$("#"+id).html("---");
}
});
},
error: function(res, stat) {
console.log('non success'+ res+stat);
}
});
}
function createDynamicTable(tbody, rows, cols) {
if (tbody == null || tbody.length < 1) return;
for (var r = 0; r < rows; r++) {
var trow = $("<tr>");
for (var c = 0; c < cols; c++) {
var cellText = 16 * r + c;
var blah = $("<td id=" + cellText +">")
.addClass("tableCell")
.text(cellText)
.appendTo(trow);
}
trow.appendTo(tbody);
}
}
</script>
</head>
<body>
<div id="page-wrap">
</div>
<table id="tbl" border="1">
<tbody>
</tbody>
</table>
</body>
</html>