2013-06-25 01:16:28 +02:00
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
/*** Tree toggles in logfiles. ***/
|
|
|
|
|
|
|
|
/* Set the appearance of the toggle depending on whether the
|
|
|
|
corresponding subtree is initially shown or hidden. */
|
|
|
|
$(".tree-toggle").map(function() {
|
|
|
|
if ($(this).siblings("ul:hidden").length == 0) {
|
|
|
|
$(this).text("-");
|
|
|
|
} else {
|
|
|
|
$(this).text("+");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/* When a toggle is clicked, show or hide the subtree. */
|
|
|
|
$(".tree-toggle").click(function() {
|
|
|
|
if ($(this).siblings("ul:hidden").length != 0) {
|
|
|
|
$(this).siblings("ul").show();
|
|
|
|
$(this).text("-");
|
|
|
|
} else {
|
|
|
|
$(this).siblings("ul").hide();
|
|
|
|
$(this).text("+");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/* Implementation of the expand all link. */
|
|
|
|
$(".tree-expand-all").click(function() {
|
|
|
|
$(".tree-toggle", $(this).parent().siblings(".tree")).map(function() {
|
|
|
|
$(this).siblings("ul").show();
|
|
|
|
$(this).text("-");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
/* Implementation of the collapse all link. */
|
|
|
|
$(".tree-collapse-all").click(function() {
|
|
|
|
$(".tree-toggle", $(this).parent().siblings(".tree")).map(function() {
|
|
|
|
$(this).siblings("ul").hide();
|
|
|
|
$(this).text("+");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$("table.clickable-rows").click(function(event) {
|
|
|
|
if ($(event.target).closest("a").length) return;
|
|
|
|
link = $(event.target).parents("tr").find("a.row-link");
|
|
|
|
if (link.length == 1)
|
|
|
|
window.location = link.attr("href");
|
|
|
|
});
|
|
|
|
|
|
|
|
bootbox.animate(false);
|
|
|
|
|
|
|
|
$(".hydra-popover").popover({});
|
|
|
|
|
|
|
|
$(function() {
|
|
|
|
if (window.location.hash) {
|
2013-08-28 17:06:08 +02:00
|
|
|
$(".nav-tabs a[href='" + window.location.hash + "']").tab('show');
|
2013-06-25 01:16:28 +02:00
|
|
|
}
|
2013-08-28 17:06:08 +02:00
|
|
|
|
|
|
|
/* If no tab is active, show the first one. */
|
|
|
|
$(".nav-tabs").each(function() {
|
|
|
|
if ($("li.active", this).length > 0) return;
|
2013-10-03 01:34:17 +02:00
|
|
|
$("a", $(this).children("li:not(.dropdown)").first()).tab('show');
|
2013-08-28 17:06:08 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
/* Ensure that pressing the back button on another page
|
|
|
|
navigates back to the previously selected tab on this
|
|
|
|
page. */
|
|
|
|
$('.nav-tabs').bind('show', function(e) {
|
|
|
|
var pattern = /#.+/gi;
|
|
|
|
var id = e.target.toString().match(pattern)[0];
|
|
|
|
history.replaceState(null, "", id);
|
|
|
|
});
|
2013-06-25 01:16:28 +02:00
|
|
|
})
|
|
|
|
});
|
2013-09-21 19:25:01 +02:00
|
|
|
|
|
|
|
var tabsLoaded = {};
|
|
|
|
|
2013-10-03 18:49:37 +02:00
|
|
|
function makeLazyTab(tabName, uri) {
|
2013-09-21 19:25:01 +02:00
|
|
|
$('.nav-tabs').bind('show', function(e) {
|
|
|
|
var pattern = /#.+/gi;
|
|
|
|
var id = e.target.toString().match(pattern)[0];
|
|
|
|
if (id == '#' + tabName && !tabsLoaded[id]) {
|
|
|
|
tabsLoaded[id] = 1;
|
|
|
|
$('#' + tabName).load(uri, function(response, status, xhr) {
|
|
|
|
if (status == "error") {
|
|
|
|
$('#' + tabName).html("<div class='alert alert-error'>Error loading tab: " + xhr.status + " " + xhr.statusText + "</div>");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2013-10-03 18:49:37 +02:00
|
|
|
};
|
2013-10-03 17:23:41 +02:00
|
|
|
|
2013-10-03 18:49:37 +02:00
|
|
|
function escapeHTML(s) {
|
|
|
|
return $('<div/>').text(s).html();
|
|
|
|
};
|
|
|
|
|
|
|
|
function requestJSON(args) {
|
2013-10-03 17:23:41 +02:00
|
|
|
args.dataType = 'json';
|
|
|
|
args.error = function(data) {
|
|
|
|
json = {};
|
|
|
|
try {
|
|
|
|
if (data.responseText)
|
|
|
|
json = $.parseJSON(data.responseText);
|
|
|
|
} catch (err) {
|
|
|
|
}
|
|
|
|
if (json.error)
|
2013-10-03 18:49:37 +02:00
|
|
|
bootbox.alert(escapeHTML(json.error));
|
2013-10-03 17:23:41 +02:00
|
|
|
else if (data.responseText)
|
2013-10-03 18:49:37 +02:00
|
|
|
bootbox.alert("Server error: " + escapeHTML(data.responseText));
|
2013-10-03 17:23:41 +02:00
|
|
|
else
|
|
|
|
bootbox.alert("Unknown server error!");
|
|
|
|
};
|
|
|
|
return $.ajax(args);
|
2013-10-03 18:49:37 +02:00
|
|
|
};
|
2013-10-03 17:23:41 +02:00
|
|
|
|
2013-10-03 18:49:37 +02:00
|
|
|
function redirectJSON(args) {
|
2013-10-03 17:23:41 +02:00
|
|
|
args.success = function(data) {
|
|
|
|
window.location = data.redirect;
|
|
|
|
};
|
|
|
|
return requestJSON(args);
|
2013-10-03 18:49:37 +02:00
|
|
|
};
|