Loading...
$(document).ready(function() {
$(".loading").hide();
$(".tabs").tabs({
cookie : {
expires : 1
},
ajaxOptions: {
error: function(xhr, status, index, anchor) {
var errorMessage = "Error loading tab: " + xhr.status + " " + xhr.statusText;
// Attempt to get more detailed error message
if (xhr.responseText) {
var json = JSON.parse(xhr.responseText);
if (json.errorMessage) {
errorMessage = json.errorMessage
}
}
// Display error message
$(anchor.hash).text(errorMessage);
// Reload the page if session has timed out
if (xhr.statusCode == 401) {
window.location.reload();
}
},
beforeSend: function() {
$('.loading').show();
},
complete: function() {
$(".loading").hide();
}
}
});
$(".indicator").each(function(index, object){
$("#" + object.id).load('${request.contextPath}/migration/' + object.id + '?format=count');
});
$(".fetch-indicator").live("click", function(){
$(this).text("Loading...");
var url = $(this).data("url");
$(this).load(url, {}, function(xhr, textStatus, request) {
if (textStatus !== "success") {
$(this).text("");
var error = JSON.parse(xhr);
$(this).text("Error: " + error.errorMessage);
return;
}
$(this).text(xhr);
});
});
$("#btn-fetch-all-indicators").live("click", function(){
$(".fetch-indicator").each(function(index, object) {
$(object).trigger("click");
});
});
$(".btn-post-data").live("click", function(){
var url = $(this).data("url");
onLoading();
$.post(url, {}, function(data, textStatus, xhr) {
onComplete();
});
});
});
function onLoading() {
$(".loading").show();
$("#status").hide();
$("#migration-status").text("Starting migration...")
}
function onComplete() {
$(".loading").hide();
$("#status").show();
$("#migration-status").text("Completed migration! ")
}