diff --git a/emhttp/plugins/dynamix/scripts/feedback b/emhttp/plugins/dynamix/scripts/feedback index 4b7c775b5..e6cd0349e 100755 --- a/emhttp/plugins/dynamix/scripts/feedback +++ b/emhttp/plugins/dynamix/scripts/feedback @@ -13,7 +13,7 @@ $docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp'); require_once "$docroot/webGui/include/Helpers.php"; -extract(parse_plugin_cfg('dynamix', true)); +extract(parse_plugin_cfg('dynamix',true)); // add translations $_SERVER['REQUEST_URI'] = ''; @@ -22,191 +22,249 @@ require_once "$docroot/webGui/include/Translations.php"; $var = parse_ini_file('state/var.ini'); $unraid = parse_ini_file('/etc/unraid-version'); -$keyfile = !empty(_var($var, 'regFILE')) ? trim(base64_encode(@file_get_contents($var['regFILE']))) : ''; -$width = in_array($display['theme'], ['azure', 'gray']) ? '98.4%' : '100%'; +$keyfile = !empty(_var($var,'regFILE')) ? trim(base64_encode(@file_get_contents($var['regFILE']))) : ''; +$width = in_array($display['theme'], ['azure','gray']) ? '98.8%' : '100%'; ?>
- -=_('NOTE')?>: =_('Submission of this bug report will automatically send your system diagnostics to Lime Technology')?>.
-=_('NOTE')?>: =_('Submission of this troubleshooting request will automatically send your system diagnostics to Lime Technology')?>.
-=_('Sorry, an error occurred')?>. =_('Please try again later')?>.
"; + $('#thanks_panel').html(failure_message).fadeIn('fast'); + } else { + data.message = data.message || ''; + var url_parts = url.split('/'); + var success_message = '
' + data.message + '
=_('Sorry, an error occurred')?>. =_('Please try again later')?>.
"; + $('#thanks_panel').html(failure_message).fadeIn('fast'); + }).always(function() { + $('#spinner_image').fadeOut('fast'); + panel.fadeOut('fast').find('textarea,input').prop('disabled', false); + }); + $('#submit-button').prop('disabled',true); +} + +$(function() { + $('#control_panel input[name=mode]').click(function() { + var showPanel = '#'+$('#control_panel input[name=mode]:checked').val()+'_panel'; + $('.allpanels').not(showPanel).fadeOut('fast'); + var loadfunction = window[$('#control_panel input[name=mode]:checked').val()+'_load']; + if (typeof loadfunction !== 'undefined' && $.isFunction(loadfunction)) { + loadfunction(); + } else { + $(showPanel).fadeIn('fast'); + } + }); + + $('button.confirm').text("=_('Cancel')?>"); + if ($('#submit-button').length == 0) $('button.confirm').before(''); + + $('input[name=mode]').click(function(){ + var label = $('input[name=mode]:checked').val(); + var required = (label == 'troubleshoot'); + var email = "=_('Contact Email Address')?>"; + var option = " (=_('optional')?>)"; + $('#submit-button').prop('disabled',$('#'+label)!=''); + $('input#email').prop('placeholder',email+(required?'':option)).prop('required',required); + }); + + $('textarea').on('input change',function(){ + var panel = $(this).parent().prop('id').replace('_panel',''); + $('#submit-button').prop('disabled',validInput($(this).val(),panel) || !validEmail($('input#email'))); + }); + + $('input#email').on('input change',function(){ + var panel = $('input[name=mode]:checked').val(); + $('#submit-button').prop('disabled',validInput($('#'+panel+'_panel textarea').val(),panel) || !validEmail($(this))); + }); + + $('#submit-button').click(function() { + switch ($('input[name=mode]:checked').val()) { + case 'featureRequest': + form_submit('https://keys.lime-technology.com/feedback/featurerequest',{description:$('#featureRequest').val(), email:$('input#email').val()}, $('#featureRequest_panel')); + break; + case 'bugReport': + form_submit('https://keys.lime-technology.com/feedback/bugreport',{description:$('#bugReport').val(), email:$('input#email').val()}, $('#bugReport_panel'), 1); + break; + case 'troubleshoot': + // @todo - update this to use a new troubleshoot endpoint + form_submit('https://keys.lime-technology.com/feedback/bugreport',{description:$('#troubleshoot').val()+'\n\n'+$('#troubleshoot_details').val(), email:$('input#email').val()}, $('#troubleshoot_panel'), 1); + break; + case 'otherComment': + form_submit('https://keys.lime-technology.com/feedback/comment',{description:$('#otherComment').val(), email:$('input#email').val()}, $('#otherComment_panel')); + break; + } + }); + + feedback_reset(); + $('#optFeatureRequest').click(); +}); +