From 965ae4e5bbf9daee07171d24a85bee5915721efb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 26 Mar 2014 09:28:03 +0000 Subject: [PATCH] Initial commit of icinga.reload, this allows as to replace JS at runtime * Works only with minified JS right now as it loads only a single file file --- public/js/icinga.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/public/js/icinga.js b/public/js/icinga.js index 67b960797..868d662cd 100644 --- a/public/js/icinga.js +++ b/public/js/icinga.js @@ -149,7 +149,36 @@ this.modules = []; this.timer = this.events = this.loader = this.ui = this.logger = this.utils = null; + }, + + reload: function () { + setTimeout(function () { + var oldjQuery = window.jQuery; + var oldConfig = window.icinga.config; + var oldIcinga = window.Icinga; + window.icinga.destroy(); + window.Icinga = undefined; + window.$ = undefined; + window.jQuery = undefined; + + oldjQuery.getScript( + oldConfig.baseUrl + 'js/icinga.min.js' + ).done(function () { + window.jQuery = oldjQuery; + window.$ = window.jQuery; + window.Icinga = oldIcinga; + window.icinga = new Icinga(oldConfig); + window.icinga.ui.reloadCss(); + oldjQuery = undefined; + oldConfig = undefined; + oldIcinga = undefined; + }).fail(function () { + window.icinga = new Icinga(oldConfig); + window.icinga.ui.reloadCss(); + }); + }, 0); } + }; window.Icinga = Icinga;