Merge pull request #4053 from Icinga/feature/js-addUrlFlag
JS: Introduce Icinga.Utils.addUrlFlag()
This commit is contained in:
commit
4c39772667
|
@ -415,13 +415,19 @@
|
|||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the specified flag to the given URL
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {string} flag
|
||||
*
|
||||
* @returns {string}
|
||||
*
|
||||
* @deprecated since version 2.8.0. Use {@link Icinga.Utils.addUrlFlag()} instead
|
||||
*/
|
||||
addUrlFlag: function(url, flag)
|
||||
{
|
||||
if (url.match(/\?/)) {
|
||||
return url + '&' + flag;
|
||||
} else {
|
||||
return url + '?' + flag;
|
||||
}
|
||||
return this.icinga.utils.addUrlFlag(url, flag);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -543,7 +549,7 @@
|
|||
if (rerenderLayout) {
|
||||
var parts = url.split(/#!/);
|
||||
url = parts.shift();
|
||||
var redirectionUrl = this.addUrlFlag(url, 'renderLayout');
|
||||
var redirectionUrl = icinga.utils.addUrlFlag(url, 'renderLayout');
|
||||
var r = this.loadUrl(redirectionUrl, $('#layout'));
|
||||
r.historyUrl = url;
|
||||
if (parts.length) {
|
||||
|
|
|
@ -225,6 +225,30 @@
|
|||
return params;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the specified flag to the given URL
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {string} flag
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
addUrlFlag: function (url, flag) {
|
||||
var pos = url.search(/#(?!!)/);
|
||||
|
||||
if (url.indexOf('?') !== -1) {
|
||||
flag = '&' + flag;
|
||||
} else {
|
||||
flag = '?' + flag;
|
||||
}
|
||||
|
||||
if (pos === -1) {
|
||||
return url + flag;
|
||||
}
|
||||
|
||||
return url.slice(0, pos) + flag + url.slice(pos);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether two HTMLElements overlap
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue