From 2393aa4c6c06d7d877f5e226749b913fc04298d4 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 30 Nov 2014 10:40:37 +0100 Subject: [PATCH] js/module: introduce JS-side ID cache --- public/js/module.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/public/js/module.js b/public/js/module.js index 66ff644..6eb0870 100644 --- a/public/js/module.js +++ b/public/js/module.js @@ -7,6 +7,8 @@ */ this.module = module; + this.idCache = {}; + this.initialize(); this.module.icinga.logger.debug('BP module loaded'); @@ -87,17 +89,23 @@ fixOpenedBps: function(event) { var $container = $(event.currentTarget); - var opened = $container.data('refreshParams'); - if (typeof opened === 'undefined' || typeof opened.opened === 'undefined') { + var container_id = $container.attr('id'); + + if (typeof this.idCache[container_id] === 'undefined') { return; } + var $procs = $('table.process', $container); + $.each(this.idCache[$container.attr('id')], function(idx, id) { + var $el = $('#' + id); + $procs = $procs.not($el); + + $el.parents('table.process').each(function (idx, el) { + $procs = $procs.not($(el)); - opened = opened.opened; - $.each(opened, function(idx, ids) { - $.each(ids.split('_'), function(idx, id) { - $('#' + id, $container).removeClass('collapsed'); }); }); + + $procs.addClass('collapsed'); }, /**