mirror of
https://github.com/unraid/webgui.git
synced 2026-01-07 10:10:05 -06:00
Feedback form: code optimization
This commit is contained in:
@@ -388,7 +388,7 @@ function openChanges(cmd,title,nchan,button=0) {
|
||||
$('div.spinner.fixed').hide();
|
||||
swal({title:title,text:"<pre id='swalbody'></pre><hr>",html:true,animation:'none',showConfirmButton:button!=0,confirmButtonText:"<?=_('Close')?>"},function(close){
|
||||
$('.sweet-alert').hide('fast').removeClass('nchan');
|
||||
if ($('#submit-button').length > 0) $('#submit-button').remove();
|
||||
if ($('#submit_button').length > 0) $('#submit_button').remove();
|
||||
});
|
||||
$('.sweet-alert').addClass('nchan');
|
||||
$('pre#swalbody').html(data);
|
||||
|
||||
@@ -204,49 +204,50 @@ function form_submit(url, params, panel, diagnostics) {
|
||||
}
|
||||
|
||||
$(function() {
|
||||
$('button.confirm').text("<?=_('Cancel')?>");
|
||||
if ($('#submit_button').length == 0) $('button.confirm').before('<input type="button" id="submit_button" value="<?=_('Submit')?>" disabled>');
|
||||
|
||||
$('input[name=mode]').click(function() {
|
||||
var panel = $('input[name=mode]:checked').val();
|
||||
var showPanel = '#'+panel+'_panel';
|
||||
$('.allpanels').not(showPanel).fadeOut('fast');
|
||||
var loadfunction = window[panel+'_load'];
|
||||
var tab = $('input[name=mode]:checked').val();
|
||||
var panel = '#'+tab+'_panel';
|
||||
var email = "<?=_('Contact Email Address')?>";
|
||||
$('.allpanels').not(panel).fadeOut('fast');
|
||||
var loadfunction = window[tab+'_load'];
|
||||
if (typeof loadfunction !== 'undefined' && $.isFunction(loadfunction)) {
|
||||
loadfunction();
|
||||
} else {
|
||||
$(showPanel).fadeIn('fast');
|
||||
$(panel).fadeIn('fast');
|
||||
}
|
||||
var required = (panel == 'troubleshoot');
|
||||
var email = "<?=_('Contact Email Address')?>";
|
||||
var option = " (<?=_('optional')?>)";
|
||||
$('input#email').prop('placeholder',email+(required?'':option)).prop('required',required);
|
||||
$('#submit_button').prop('disabled',validInput($('#'+panel+'_panel textarea')));
|
||||
var required = ['troubleshoot'].includes(tab);
|
||||
var optional = required ? "" : " (<?=_('optional')?>)";
|
||||
$('input#email').prop('placeholder',email+optional).prop('required',required);
|
||||
$('#submit_button').prop('disabled',validInput($('#'+tab+'_panel textarea')));
|
||||
});
|
||||
|
||||
$('button.confirm').text("<?=_('Cancel')?>");
|
||||
if ($('#submit_button').length == 0) $('button.confirm').before('<input type="button" id="submit_button" value="<?=_('Submit')?>" disabled>');
|
||||
|
||||
$('textarea').on('input change',function(){
|
||||
$('#submit_button').prop('disabled',validInput($(this)));
|
||||
});
|
||||
|
||||
$('input#email').on('input change',function(){
|
||||
var panel = $('input[name=mode]:checked').val();
|
||||
$('#submit_button').prop('disabled',validInput($('#'+panel+'_panel textarea')));
|
||||
var tab = $('input[name=mode]:checked').val();
|
||||
$('#submit_button').prop('disabled',validInput($('#'+tab+'_panel textarea')));
|
||||
});
|
||||
|
||||
$('#submit_button').click(function() {
|
||||
switch ($('input[name=mode]:checked').val()) {
|
||||
case 'featureRequest':
|
||||
form_submit('https://keys.lime-technology.com/feedback/featurerequest',{description:$('#featureRequest').val()}, $('#featureRequest_panel'));
|
||||
var tab = '#'+$('input[name=mode]:checked').val();
|
||||
switch (tab) {
|
||||
case '#featureRequest':
|
||||
form_submit('https://keys.lime-technology.com/feedback/featurerequest',{description:$(tab).val()}, $(tab+'_panel'));
|
||||
break;
|
||||
case 'bugReport':
|
||||
form_submit('https://keys.lime-technology.com/feedback/bugreport',{description:$('#bugReport').val()}, $('#bugReport_panel'), 1);
|
||||
case '#bugReport':
|
||||
form_submit('https://keys.lime-technology.com/feedback/bugreport',{description:$(tab).val()}, $(tab+'_panel'), 1);
|
||||
break;
|
||||
case 'troubleshoot':
|
||||
case '#troubleshoot':
|
||||
// @todo - update this to use a new troubleshoot endpoint
|
||||
form_submit('https://keys.lime-technology.com/feedback/bugreport',{description:$('#troubleshoot').val()}, $('#troubleshoot_panel'), 1);
|
||||
form_submit('https://keys.lime-technology.com/feedback/bugreport',{description:$(tab).val()}, $(tab+'_panel'), 1);
|
||||
break;
|
||||
case 'otherComment':
|
||||
form_submit('https://keys.lime-technology.com/feedback/comment',{description:$('#otherComment').val()}, $('#otherComment_panel'));
|
||||
case '#otherComment':
|
||||
form_submit('https://keys.lime-technology.com/feedback/comment',{description:$(tab).val()}, $(tab+'_panel'));
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user