Add support for anchors in the main url

refs #9844
This commit is contained in:
Matthias Jentsch 2015-08-28 14:16:27 +02:00
parent ef8ee3302b
commit 55521bf880
1 changed files with 39 additions and 2 deletions

View File

@ -187,9 +187,13 @@
).addToHistory = false;
}
if (document.location.hash && document.location.hash.match(/^#!/)) {
if (this.getPaneAnchor(0)) {
$('#col1').data('icingaUrl', $('#col1').data('icingaUrl') + '#' + this.getPaneAnchor(0));
}
parts = document.location.hash.split(/#!/);
var hash = this.getPaneFragment();
if (hash && hash.match(/^#!/)) {
parts = hash.split(/#!/);
if ($('#layout > #login').length) {
// We are on the login page
@ -215,6 +219,39 @@
}
},
/**
* Get the state of the selected pane
*
* @param col {int} The column index 0 or 1
*
* @returns {String} The string representing the state
*/
getPaneAnchor: function (col) {
if (col !== 1 && col !== 0) {
throw 'Trying to get anchor for non-existing column: ' + col;
}
var panes = document.location.toString().split('#!')[col];
return panes && panes.split('#')[1];
},
/**
* Get the side-pane state fragment after (and including) the #!
*
* @returns {String} The pane url containing the '#!'
*/
getPaneFragment: function () {
var hash = document.location.hash;
if (hash) {
if (hash.match(/^#[^!]/)) {
var hashs = hash.split('#');
hashs.shift();
hashs.shift();
hash = '#' + hashs.join('#');
}
}
return hash;
},
/**
* Cleanup
*/