js: fix urls for dynamic css/js reloads

This commit is contained in:
Thomas Gelf 2016-02-29 21:40:48 +01:00
parent 96f50c5dfa
commit 28204762ab
2 changed files with 11 additions and 5 deletions

View File

@ -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);

View File

@ -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();