Create a gist now

Instantly share code, notes, and snippets.

@JustinAiken /devices.php Secret
Created Mar 21, 2015

Embed
What would you like to do?
devices.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Devices</title>
<link type="text/css" rel="Stylesheet" href="css/mystyles.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
function refresh_dev_list() {
$.ajax({
type:'POST',
url: 'dev_list.php',
cache: false,
success: function (data) {
$('#dev_list tbody').html(data);
}
});
}
function show_device(id) {
var rowid = "#row" + id;
$(rowid).addClass("selected").siblings().removeClass("selected");
$.ajax({
type:'POST',
url: 'dev_detail.php',
//data: { id : id, prot: prot, type: type},
data: { id : id},
dataType: 'json',
cache: false,
success: function (dev_data) {
//alert(dev_data.info);
$('#dev_info tbody').html(dev_data.info);
$('#dev_attrs tbody').html(dev_data.attrs);
}
});
}
function switchDev(nodeId, attrId, on) {
$.ajax({
type:'POST',
url: 'set_dev_value.php',
data: { nodeId : nodeId, attrId: attrId, value: on},
cache: false,
success: function (data) {
setTimeout(function(){show_device(nodeId)}, 500);
alert(data);
}
});
}
function setDevValue(nodeId, attrId) {
var vid = "value_set" + attrId;
var v = document.getElementById(vid).value;
$.ajax({
type:'POST',
url: 'set_dev_value.php',
data: { nodeId : nodeId, attrId: attrId, value: v},
cache: false,
success: function (data) {
setTimeout(function(){show_device(nodeId)}, 500);
alert(data);
}
});
}
$(document).ready(function(){
refresh_dev_list();
});
</script>
</head>
<body>
<?php $cur_page='page_devices'; $title = 'Device List'; include("header.php"); ?>
<div class="text_panel panel1">
<table style="width: 50%;margin:0 auto;" border="0" cellpadding="10" cellspacing="0">
<tr>
<td valign="top">
<h3>Device List:</h3>
<table id='dev_list' class="devices" cellspacing="0" cellpadding="0" >
<thead><tr>
<th>Id</th>
<th>Protocol</th>
<th>Type</th>
</tr></thead>
<tbody>
</tbody>
</table>
</td>
<td width="50%" valign="top">
<h3>Device Detail:</h3>
<div class="text_panel panel1">
<table id='dev_info' width='100%'>
<tbody>
</tbody>
</table>
<h4>Attributes:</h4>
<table class=devices id='dev_attrs' width='100%'>
<tbody>
</tbody>
</table>
</div>
</td>
</tr>
</table>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment