// Turn Output on or off function modOutputOutput(btn_val) { $.ajax({ type: 'GET', url: '/output_mod/' + btn_val, {% if not misc.hide_alert_success %} success: function(data) { if (data.startsWith("SUCCESS")) { toastr['success']("Output: " + data); } else { toastr['error']("Output: " + data); } }, {% endif %} {% if not misc.hide_alert_warning %} error: function(data) { toastr['error']("Output " + btn_val.split("/")[0] + ": " + data); } {% endif %} }); } $(document).ready(function() { $('.turn_on').click(function() { const btn_val = this.name; const send_cmd = btn_val.substring(btn_val.indexOf('/')+1); {% if not misc.hide_alert_info %} toastr['info']('Command sent to turn output On'); {% endif %} modOutputOutput(send_cmd); }); $('.turn_off').click(function() { const btn_val = this.name; const send_cmd = btn_val.substring(btn_val.indexOf('/') + 1); {% if not misc.hide_alert_info %} toastr['info']('Command sent to turn output Off'); {% endif %} modOutputOutput(send_cmd); }); $('.output_on_amt').click(function() { const btn_val = this.name; const chart = btn_val.split('/')[0]; const output_id = btn_val.split('/')[1]; const channel_id = btn_val.split('/')[2]; const on_amt = $('#sec_on_amt_' + chart + '_' + output_id + '_' + channel_id).val(); const send_cmd = btn_val.substring(btn_val.indexOf('/') + 1); {% if not misc.hide_alert_info %} toastr['info']('Command sent to turn output On for ' + on_amt); {% endif %} modOutputOutput(send_cmd + on_amt); }); $('.duty_cycle_on_amt').click(function() { const btn_val = this.name; const chart = btn_val.split('/')[0]; const output_id = btn_val.split('/')[1]; const channel_id = btn_val.split('/')[2]; const dc = $('#duty_cycle_on_amt_' + chart + '_' + output_id + '_' + channel_id).val(); const send_cmd = btn_val.substring(btn_val.indexOf('/') + 1); {% if not misc.hide_alert_info %} toastr['info']('Command sent to turn output On with a duty cycle of ' + dc + '%'); {% endif %} modOutputOutput(send_cmd + dc); }); });