kopia lustrzana https://github.com/cyoung/stratux
Send configuration changes to server.
rodzic
531ce0f881
commit
a2652cdd9b
|
@ -1,4 +1,3 @@
|
||||||
// socket.io specific code
|
|
||||||
var socket = io.connect('http://192.168.10.1:9110');
|
var socket = io.connect('http://192.168.10.1:9110');
|
||||||
|
|
||||||
function setConnectedClass (cssClass) {
|
function setConnectedClass (cssClass) {
|
||||||
|
@ -18,58 +17,47 @@ socket.on('connect', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('reconnect', function () {
|
socket.on('reconnect', function () {
|
||||||
message('System', 'Reconnected to the server');
|
console.log('System', 'Reconnected to the server');
|
||||||
setConnectedClass('label-success');
|
setConnectedClass('label-success');
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('reconnecting', function () {
|
socket.on('reconnecting', function () {
|
||||||
message('System', 'Attempting to re-connect to the server');
|
console.log('System', 'Attempting to re-connect to the server');
|
||||||
setConnectedClass('label-danger');
|
setConnectedClass('label-danger');
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('error', function (e) {
|
socket.on('error', function (e) {
|
||||||
message('System', e ? e : 'A unknown error occurred');
|
console.log('System', e ? e : 'A unknown error occurred');
|
||||||
setConnectedClass('label-danger');
|
setConnectedClass('label-danger');
|
||||||
});
|
});
|
||||||
|
|
||||||
function message (from, msg) {
|
socket.on('status', function (msg) {
|
||||||
$('#lines').append($('<p>').append($('<b>').text(from), msg));
|
console.log('Received status update.')
|
||||||
}
|
});
|
||||||
|
|
||||||
|
socket.on('configuration', function (msg) {
|
||||||
// dom manipulation
|
console.log('Received configuration update.')
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('input[name=UAT_Enabled]').change(function(){
|
$('input[name=UAT_Enabled]').click(function () {
|
||||||
$('#settings').ajaxSubmit({url: 'control.php', type: 'post'})
|
console.log('UAT_Enabled clicked');
|
||||||
});
|
socket.emit('UATconfigurationChange', $('input[name=UAT_Enabled]').val());
|
||||||
$('input[name=ES_Enabled]').change(function(){
|
|
||||||
$('#settings').ajaxSubmit({url: 'control.php', type: 'post'})
|
|
||||||
});
|
|
||||||
$('input[name=GPS_Enabled]').change(function(){
|
|
||||||
$('#settings').ajaxSubmit({url: 'control.php', type: 'post'})
|
|
||||||
});
|
|
||||||
$('input[name=AHRS_Enabled]').change(function(){
|
|
||||||
$('#settings').ajaxSubmit({url: 'control.php', type: 'post'})
|
|
||||||
});
|
|
||||||
});
|
|
||||||
(function worker() {
|
|
||||||
$.ajax({
|
|
||||||
url: 'control.php',
|
|
||||||
success: function(data) {
|
|
||||||
obj = $.parseJSON(data);
|
|
||||||
$.each(obj, function(k, v) {
|
|
||||||
// Radio values.
|
|
||||||
if ((k == "UAT_Enabled") || (k == "ES_Enabled") || (k == "GPS_Enabled") || (k == "AHRS_Enabled")) {
|
|
||||||
$('[name=' + k + ']').val([v.toString()]);
|
|
||||||
}
|
|
||||||
$('#' + k).text(v);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
$('input[name=ES_Enabled]').click(function () {
|
||||||
complete: function() {
|
console.log('ES_Enabled clicked');
|
||||||
// Schedule the next request when the current one is complete.
|
socket.emit('ESconfigurationChange', $('input[name=ES_Enabled]').val());
|
||||||
setTimeout(worker, 1000);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
})();
|
|
||||||
|
$('input[name=GPS_Enabled]').click(function () {
|
||||||
|
console.log('GPS_Enabled clicked');
|
||||||
|
socket.emit('GPSconfigurationChange', $('input[name=GPS_Enabled]').val());
|
||||||
|
});
|
||||||
|
|
||||||
|
$('input[name=AHRS_Enabled]').click(function () {
|
||||||
|
console.log('AHRS_Enabled clicked');
|
||||||
|
socket.emit('AHRSconfigurationChange', $('input[name=AHRS_Enabled]').val());
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
Ładowanie…
Reference in New Issue