From 621dd53615f14f5732a347346b4b8444e81ea97f Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 14 Feb 2017 15:42:49 +0545 Subject: Only save valid widget locations in config Some widgets create extra panels, e.g. the widgets that now have the filter functionality. Those panels are processed in the ".each" at line 424. They do not have an id in the form "widget-*" and when the old code tries to find the "*" part it gets "undefined". This results in the layout being saved like: ``` interface_statistics:col1:open,undefined:col1:close,system_information:col2:open,undefined:col2:close,picture:col3:open,rss:col3:open,ntp_status:col2:open ``` This PR puts extra checks in place so that the "undefined" stuff does not get written into the widget sequence string. --- src/usr/local/www/index.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/usr/local/www/index.php') diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php index ab41a4b..4d22d23 100644 --- a/src/usr/local/www/index.php +++ b/src/usr/local/www/index.php @@ -423,8 +423,13 @@ function updateWidgets(newWidget) { $('.container .col-md-').each(function(idx, col) { $('.panel', col).each(function(idx, widget) { var isOpen = $('.panel-body', widget).hasClass('in'); + var widget_basename = widget.id.split('-')[1]; - sequence += widget.id.split('-')[1] + ':' + col.id.split('-')[1] + ':' + (isOpen ? 'open' : 'close') + ','; + // Only save details for panels that have id's like'widget-*' + // Some widgets create other panels, so ignore any of those. + if ((widget.id.split('-')[0] == 'widget') && (typeof widget_basename !== 'undefined')) { + sequence += widget_basename + ':' + col.id.split('-')[1] + ':' + (isOpen ? 'open' : 'close') + ','; + } }); }); -- cgit v1.1