[icinga-checkins] icinga.org: icingaweb2/master: js: fix urls for dynamic css/js reloads

git at icinga.org git at icinga.org
Mon Feb 29 21:41:01 CET 2016


Module: icingaweb2
Branch: master
Commit: 28204762ab26774b026f402ccee4ac2beb4ebff8
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=28204762ab26774b026f402ccee4ac2beb4ebff8

Author: Thomas Gelf <thomas at gelf.net>
Date:   Mon Feb 29 21:40:48 2016 +0100

js: fix urls for dynamic css/js reloads

---

 public/js/icinga.js    |    2 +-
 public/js/icinga/ui.js |   14 ++++++++++----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/public/js/icinga.js b/public/js/icinga.js
index 06c797a..b52c19a 100644
--- a/public/js/icinga.js
+++ b/public/js/icinga.js
@@ -217,7 +217,7 @@
                 $ = undefined;
 
                 oldjQuery.getScript(
-                    oldConfig.baseUrl + 'js/icinga.min.js'
+                    oldConfig.baseUrl.replace(/\/$/, '') + '/js/icinga.min.js'
                 ).done(function () {
                     var jQuery = window.jQuery;
                     window.icinga = new window.Icinga(oldConfig);
diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js
index a797aab..09876e9 100644
--- a/public/js/icinga/ui.js
+++ b/public/js/icinga/ui.js
@@ -99,12 +99,18 @@
             $('link').each(function() {
                 var $oldLink = $(this);
                 if ($oldLink.hasAttr('type') && $oldLink.attr('type').indexOf('css') > -1) {
+                    var base = location.protocol + '//' + location.host;
+                    if (location.port) {
+                        base += location.port;
+                    }
+                    var url = icinga.utils.addUrlParams(
+                        $(this).attr('href'),
+                        { id: new Date().getTime() }
+                    );
+
                     var $newLink = $oldLink.clone().attr(
                         'href',
-                        icinga.utils.addUrlParams(
-                            $(this).attr('href'),
-                            { id: new Date().getTime() }
-                        )
+                        base + '/' + url.replace(/^\//, '')
                     ).on('load', function() {
                         icinga.ui.fixControls();
                         $oldLink.remove();



More information about the icinga-checkins mailing list