var tableId = "#ulogs-table";
var dateOutputFormat = d3.time.format("%m/%d/%Y %I:%M:%S %p");
var filterText = "filter the message";
var xmldata = null;
var types = {
error: {name: "error", id: "errors", css: "error",},
warning: {name: "warning", id: "warnings", css: "warning",},
message: {name: "message", id: "messages", css: "message",},
profile: {name: "profile", id: "debug", css: "message",},
profile_end: {name: "profile", id: "debug", css: "message",},
debug: {name: "profile", id: "debug", css: "message",},
};
function init() {
var logEndpoint = getUrlVars()["ulog"];
var requestData = {};
if (getUrlVars()["start"])
requestData["start"] = getUrlVars()["start"];
if (getUrlVars()["count"])
requestData["count"] = getUrlVars()["count"];
//logEndpoint
if (!logEndpoint)
return;
block();
$.ajax({
url: logEndpoint,
type: "GET",
data: requestData,
dataType: "xml",
success: function(xml, textStatus, jqXHR) {
xmldata = xml;
populateTable(tableId, xml);
},
error: function (xhr, ajaxOptions, thrownError) {
console.error(this.url + "\n" + ajaxOptions + " " + xhr.status + " " + thrownError);
},
complete: function() {
$("#filter").val(filterText);
$("#filter").focus(function() {
if($(this).val() == filterText)
$(this).val("");
});
$("#filter").blur(function() {
if($(this).val() == "")
$(this).val(filterText);
});
$("#filter").change(function() {
filterTable(tableId, xmldata);
});
$("#header input:checkbox").change(function() {
filterTable(tableId, xmldata);
});
unBlock();
}
});
}
function populateTable(id, xml) {
$("").append(
$("")
.append(
$(" ").text("Type")
)
.append(
$(" ").text("Timestamp")
)
.append(
$(" ").text("Context")
)
.append(
$(" ").text("Message")
)
).appendTo(id);
populateLines(id, xml);
$(id).tablesorter({
// Sort on the second column asc
sortList: [[1,0]]
});
}
function populateLines(id, xml) {
var filterValue = $("#filter").val();
if (filterValue == filterText)
filterValue = "";
var re = new RegExp(filterValue, "i");
var context = $(xml).find("context");
var contextName = context.attr("name");
var tbody = $("