From c318c949b1de8cc22f02178e726dc6560ff4844c Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 3 Feb 2024 22:33:02 +0100 Subject: [PATCH] Feedback form: code optimization --- emhttp/plugins/dynamix/scripts/feedback | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/feedback b/emhttp/plugins/dynamix/scripts/feedback index 765e098d4..20f98d091 100755 --- a/emhttp/plugins/dynamix/scripts/feedback +++ b/emhttp/plugins/dynamix/scripts/feedback @@ -205,21 +205,15 @@ function form_submit(url, params, panel, diagnostics) { $(function() { $('#control_panel input[name=mode]').click(function() { - var showPanel = '#'+$('#control_panel input[name=mode]:checked').val()+'_panel'; + var panel = $('#control_panel input[name=mode]:checked').val(); + var showPanel = '#'+panel+'_panel'; $('.allpanels').not(showPanel).fadeOut('fast'); - var loadfunction = window[$('#control_panel input[name=mode]:checked').val()+'_load']; + var loadfunction = window[panel+'_load']; if (typeof loadfunction !== 'undefined' && $.isFunction(loadfunction)) { loadfunction(); } else { $(showPanel).fadeIn('fast'); } - }); - - $('button.confirm').text(""); - if ($('#submit-button').length == 0) $('button.confirm').before(''); - - $('input[name=mode]').click(function(){ - var panel = $('input[name=mode]:checked').val(); var required = (panel == 'troubleshoot'); var email = ""; var option = " ()"; @@ -227,6 +221,9 @@ $(function() { $('#submit-button').prop('disabled',validInput($('#'+panel+'_panel textarea'))); }); + $('button.confirm').text(""); + if ($('#submit-button').length == 0) $('button.confirm').before(''); + $('textarea').on('input change',function(){ $('#submit-button').prop('disabled',validInput($(this))); });