From a79f786546c60eae1456e5e2e6ace3da5eb72c03 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 20 Jun 2014 16:18:10 +0200 Subject: [PATCH] JS/loader: add icon cache prototype Just playing around, I'm still unsure whether this really helps. The motivation behind this patch are icons loaded again after not being displayed for a little while. Remains disabled unless we know whether and for which scenarios (cache disabled, HTTPS...) this really helps. --- public/js/icinga/loader.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 583cf0fed..3ab3d587e 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -28,6 +28,8 @@ */ this.requests = {}; + this.iconCache = {}; + this.autorefreshEnabled = true; }; @@ -243,6 +245,22 @@ return true; }, + cacheLoadedIcons: function($container) { + // TODO: this is just a prototype, disabled for now + return; + + var self = this; + $('img.icon', $container).each(function(idx, img) { + var src = $(img).attr('src'); + if (typeof self.iconCache[src] !== 'undefined') { + return; + } + var cache = new Image(); + cache.src = src + self.iconCache[src] = cache; + }); + }, + /** * Handle successful XHR response */ @@ -434,6 +452,7 @@ if (newBody) { this.icinga.ui.fixDebugVisibility().triggerWindowResize(); } + self.cacheLoadedIcons(req.$target); if (active) { var focusedUrl = this.icinga.ui.getFocusedContainerDataUrl();