$(document).ready(function() { $('#tabs').tabs({ }); $('#colorwheel').wheelColorPicker(); $("#btn-refresh-devices").on("click", getDevices); getActive(); getDevices(); }); function setColor() { var color = $('#colorwheel').val(); console.log(color); $.ajax({ url: 'ajax/ajax_setcolor.php', data: {color: color} }); } function setPattern(pattern) { $.ajax({ url: 'ajax/ajax_setpattern.php', data: {pattern: pattern} }); } function disableAuto() { $.ajax({ url: 'ajax/ajax_disableauto.php' }); } function lightsOff() { $.ajax({ url: 'ajax/ajax_lightsoff.php' }); } function getActive() { $.ajax({ url: 'ajax/ajax_getactive.php', dataType: 'text', success: function(data, stat, jqo) { $("#active-all").removeClass('active'); $("#active-up").removeClass('active'); $("#active-down").removeClass('active'); $("#active-wall").removeClass('active'); $("#active-cldn").removeClass('active'); $("#active-post").removeClass('active'); $("#" + data).addClass('active'); } }); } function escapeHTML(str) { return str.replace(/[<>]/g, function(match) { switch (match) { case '&': return '&'; case '<': return '<'; case '>': return '>'; default: return match; } }); } function getDevices() { $.ajax({ url: 'ajax/getdevices.php', dataType: 'json', success: function(data, stat, jqo) { var div = $("#devices"); div.html(""); var html = ""; data.forEach((device) => { html += "
"; html += "
Service:" + escapeHTML(device.service) + "
"; html += "
Label:" + escapeHTML(device.label) + "
"; html += "
Board:" + escapeHTML(device.board) + "
"; html += "
IP Address:" + escapeHTML(device.ipaddress) + "
"; html += "
Last Update:" + escapeHTML(device.lastupdate) + "
"; html += "
"; }); div.html(html); } }); } function setTarget(id) { $.ajax({ url: 'ajax/ajax_settarget.php', data: {target: id}, dataType: 'text', success: function(data, stat, jqo) { getActive(); } }); } // vim: ts=3 sw=3 ai: