// Turn Output on or off function modOutputPWM(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 %} }); } // Output PWM Slider Widget function showVal(chart, duty_cycle){ document.getElementById("range_val_" + chart).innerHTML = duty_cycle; } function PWMSlidersendVal(chart, output_id, channel_id, duty_cycle){ document.getElementById("range_val_" + chart).innerHTML = duty_cycle; const cmd_send = output_id + '/' + channel_id + '/on/pwm/' + duty_cycle; modOutputPWM(cmd_send); } $(document).ready(function() { $('.turn_off_pwm_slider').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 %} modOutputPWM(send_cmd); }); $('.duty_cycle_on_amt_pwm_slider').click(function() {const output_id = btn_val.split('/')[1]; const channel_id = btn_val.split('/')[2]; const btn_val = this.name; const chart = btn_val.split('/')[0]; const dc = $('#pwm_slider_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 %} modOutputPWM(send_cmd + dc); }); });