summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/local/www/index.php47
-rw-r--r--src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php7
-rw-r--r--src/usr/local/www/widgets/widgets/gateways.widget.php6
-rw-r--r--src/usr/local/www/widgets/widgets/interface_statistics.widget.php6
-rw-r--r--src/usr/local/www/widgets/widgets/interfaces.widget.php7
-rw-r--r--src/usr/local/www/widgets/widgets/openvpn.widget.php6
-rw-r--r--src/usr/local/www/widgets/widgets/services_status.widget.php7
-rw-r--r--src/usr/local/www/widgets/widgets/smart_status.widget.php7
-rw-r--r--src/usr/local/www/widgets/widgets/system_information.widget.php6
-rw-r--r--src/usr/local/www/widgets/widgets/wake_on_lan.widget.php7
10 files changed, 56 insertions, 50 deletions
diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php
index 4d9535e..a7dde79 100644
--- a/src/usr/local/www/index.php
+++ b/src/usr/local/www/index.php
@@ -482,6 +482,53 @@ function updateWidgets(newWidget) {
$('input[name=sequence]', $('#widgetSequence_form')).val(sequence);
}
+// Determine if all the checkboxes are checked
+function are_all_checked(checkbox_panel_ref) {
+ var allBoxesChecked = true;
+ $(checkbox_panel_ref).each(function() {
+ if ((this.type == 'checkbox') && !this.checked) {
+ allBoxesChecked = false;
+ }
+ });
+ return allBoxesChecked;
+}
+
+// If the checkboxes are all checked, then clear them all.
+// Otherwise set them all.
+function set_clear_checkboxes(checkbox_panel_ref) {
+ checkTheBoxes = !are_all_checked(checkbox_panel_ref);
+
+ $(checkbox_panel_ref).each(function() {
+ $(this).prop("checked", checkTheBoxes);
+ });
+}
+
+// Set the given id to All or None button depending if the checkboxes are all checked.
+function set_all_none_button(checkbox_panel_ref, all_none_button_id) {
+ if (are_all_checked(checkbox_panel_ref)) {
+ text = "<?=gettext('None')?>";
+ } else {
+ text = "<?=gettext('All')?>";
+ }
+
+ $("#" + all_none_button_id).html('<i class="fa fa-undo icon-embed-btn"></i>' + text);
+}
+
+// Setup the necessary events to manage the All/None button and included checkboxes
+// used for selecting the items to show on a widget.
+function set_widget_checkbox_events(checkbox_panel_ref, all_none_button_id) {
+ set_all_none_button(checkbox_panel_ref, all_none_button_id);
+
+ $(checkbox_panel_ref).change(function() {
+ set_all_none_button(checkbox_panel_ref, all_none_button_id);
+ });
+
+ $("#" + all_none_button_id).click(function() {
+ set_clear_checkboxes(checkbox_panel_ref);
+ set_all_none_button(checkbox_panel_ref, all_none_button_id);
+ });
+}
+
events.push(function() {
// Make panels destroyable
diff --git a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
index 0ca13de..b8f7ba1 100644
--- a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
@@ -317,12 +317,7 @@ function get_dyndns_service_text($dyndns_type) {
setTimeout('dyndns_getstatus()', 5*60*1000);
}
events.push(function(){
- $("#showalldyndns").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showalldyndns");
});
// Do the first status check 2 seconds after the dashboard opens
setTimeout('dyndns_getstatus()', 2000);
diff --git a/src/usr/local/www/widgets/widgets/gateways.widget.php b/src/usr/local/www/widgets/widgets/gateways.widget.php
index 41b7094..f4408b8 100644
--- a/src/usr/local/www/widgets/widgets/gateways.widget.php
+++ b/src/usr/local/www/widgets/widgets/gateways.widget.php
@@ -220,11 +220,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
}
events.push(function(){
- $("#showallgateways").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallgateways");
// Start polling for updates some small random number of seconds from now (so that all the widgets don't
// hit the server at exactly the same time)
diff --git a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
index 8cd03fc..1c87c5f 100644
--- a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
+++ b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
@@ -216,11 +216,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
}
events.push(function(){
- $("#showallinterfacesforstats").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallinterfacesforstats");
// Start polling for updates some small random number of seconds from now (so that all the widgets don't
// hit the server at exactly the same time)
diff --git a/src/usr/local/www/widgets/widgets/interfaces.widget.php b/src/usr/local/www/widgets/widgets/interfaces.widget.php
index e8954a4..df3b717 100644
--- a/src/usr/local/www/widgets/widgets/interfaces.widget.php
+++ b/src/usr/local/www/widgets/widgets/interfaces.widget.php
@@ -220,12 +220,7 @@ endif;
<script>
//<![CDATA[
events.push(function(){
- $("#showallinterfaces").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallinterfaces");
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/openvpn.widget.php b/src/usr/local/www/widgets/widgets/openvpn.widget.php
index bc7ddd2..35a7865 100644
--- a/src/usr/local/www/widgets/widgets/openvpn.widget.php
+++ b/src/usr/local/www/widgets/widgets/openvpn.widget.php
@@ -384,11 +384,7 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
}
events.push(function(){
- $("#showallovpns").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallovpns");
// Start polling for updates some small random number of seconds from now (so that all the widgets don't
// hit the server at exactly the same time)
diff --git a/src/usr/local/www/widgets/widgets/services_status.widget.php b/src/usr/local/www/widgets/widgets/services_status.widget.php
index 2d04a93..f28a1ed 100644
--- a/src/usr/local/www/widgets/widgets/services_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/services_status.widget.php
@@ -164,12 +164,7 @@ if (count($services) > 0) {
<script type="text/javascript">
//<![CDATA[
events.push(function(){
- $("#showallservices").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallservices");
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/smart_status.widget.php b/src/usr/local/www/widgets/widgets/smart_status.widget.php
index fa309a9..9707e94 100644
--- a/src/usr/local/www/widgets/widgets/smart_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/smart_status.widget.php
@@ -194,12 +194,7 @@ if (count($devs) > 0) {
<script type="text/javascript">
//<![CDATA[
events.push(function(){
- $("#showallsmartdrives").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallsmartdrives");
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/system_information.widget.php b/src/usr/local/www/widgets/widgets/system_information.widget.php
index b6275c1..a04da18 100644
--- a/src/usr/local/www/widgets/widgets/system_information.widget.php
+++ b/src/usr/local/www/widgets/widgets/system_information.widget.php
@@ -590,11 +590,7 @@ function updateMeters() {
}
events.push(function(){
- $("#showallsysinfoitems").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallsysinfoitems");
});
var update_interval = "<?=$widgetperiod?>";
diff --git a/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php b/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php
index 21e7efe..e650114 100644
--- a/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php
+++ b/src/usr/local/www/widgets/widgets/wake_on_lan.widget.php
@@ -217,12 +217,7 @@ if (is_array($config['dhcpd'])) {
<script>
//<![CDATA[
events.push(function(){
- $("#showallwols").click(function() {
- $("#widget-<?=$widgetname?>_panel-footer [id^=show]").each(function() {
- $(this).prop("checked", true);
- });
- });
-
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallwols");
});
//]]>
</script>
OpenPOWER on IntegriCloud