From c0d1ceda2ced97fc9aefff5363b995c2103abd8c Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 16 Mar 2016 17:54:07 +0545 Subject: Redmine #5994 services_ntpd standardize advanced buttons --- src/usr/local/www/services_ntpd.php | 112 ++++++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 30 deletions(-) diff --git a/src/usr/local/www/services_ntpd.php b/src/usr/local/www/services_ntpd.php index dd639ac..22af484 100644 --- a/src/usr/local/www/services_ntpd.php +++ b/src/usr/local/www/services_ntpd.php @@ -333,18 +333,18 @@ $section->addInput(new Form_Checkbox( '' . 'Status > System Logs > NTP' . ''); // Statistics logging section -$btnadvstats = new Form_Button( +$btnadv = new Form_Button( 'btnadvstats', - 'Advanced', + 'Display Advanced', null, 'fa-cog' ); -$btnadvstats->addClass('btn-info btn-sm'); +$btnadv->addClass('btn-info btn-sm'); $section->addInput(new Form_StaticText( 'Statistics Logging', - $btnadvstats + $btnadv ))->setHelp('Warning: These options will create persistent daily log files in /var/log/ntp.'); $section->addInput(new Form_Checkbox( @@ -369,18 +369,18 @@ $section->addInput(new Form_Checkbox( )); // Leap seconds section -$btnleap = new Form_Button( - 'btnleap', - 'Advanced', +$btnadv = new Form_Button( + 'btnadvleap', + 'Display Advanced', null, 'fa-cog' ); -$btnleap->addClass('btn-info btn-sm'); +$btnadv->addClass('btn-info btn-sm'); $section->addInput(new Form_StaticText( 'Leap seconds', - $btnleap + $btnadv ))->setHelp('A leap second file allows NTP to advertize an upcoming leap second addition or subtraction. ' . 'Normally this is only useful if this server is a stratum 1 time server. '); @@ -413,34 +413,86 @@ print($form); // + showadvstats = ; + } else { + // It was a click, swap the state. + showadvstats = !showadvstats; + } + + hideCheckbox('clockstats', !showadvstats); + hideCheckbox('loopstats', !showadvstats); + hideCheckbox('peerstats', !showadvstats); + + if (showadvstats) { + text = ""; + } else { + text = ""; + } + $('#btnadvstats').html(' ' + text); + } + + $('#btnadvstats').prop('type', 'button'); + + $('#btnadvstats').click(function(event) { + show_advstats(); }); - // Make the ‘clear’ button a plain button, not a submit button - $('#btnadvrestr').prop('type','button'); + // Show advanced leap second options ====================================== + var showadvleap = false; + + function show_advleap(ispageload) { + var text; + // On page load decide the initial state based on the data. + if (ispageload) { + + showadvleap = ; + } else { + // It was a click, swap the state. + showadvleap = !showadvleap; + } + + hideInput('leaptext', !showadvleap); + hideInput('leapfile', !showadvleap); + + if (showadvleap) { + text = ""; + } else { + text = ""; + } + $('#btnadvleap').html(' ' + text); + } - // Make the ‘btnleap’ button a plain button, not a submit button - $('#btnleap').prop('type','button'); + $('#btnadvleap').prop('type', 'button'); - // On click, show the controls in the leap seconds section - $("#btnleap").click(function() { - hideInput('leaptext', false); - hideInput('leapfile', false); + $('#btnadvleap').click(function(event) { + show_advleap(); }); - // Set intial states - hideCheckbox('clockstats', true); - hideCheckbox('loopstats', true); - hideCheckbox('peerstats', true); - hideInput('leaptext', true); - hideInput('leapfile', true); + // Set initial states + show_advstats(true); + show_advleap(true); // Suppress "Delete row" button if there are fewer than two rows checkLastRow(); -- cgit v1.1