2011-01-25 00:55:47 +00:00
|
|
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
/* This is used to cache the current state whether the user is allowed to select more entities from
|
|
|
|
the datatable or not. Once Max number of entity selection is reached the user can no longer select
|
|
|
|
more & this variable will be set to false. */
|
|
|
|
$("#datatable").data("isEntitySelectionAllowed", true);
|
|
|
|
|
|
|
|
$("#organizationLabel").text(organizationLabel).css("color", "#2485ae");
|
|
|
|
$("#organizationMoniker").text(organizationLabel);
|
|
|
|
$("#organizationMoniker").attr("href", organizationVIVOProfileURL);
|
|
|
|
|
|
|
|
$notificationContainer = $("#notification-container").notify();
|
|
|
|
|
|
|
|
graphContainer = $("#graphContainer");
|
|
|
|
tableDiv = $('#paginatedTable');
|
|
|
|
|
|
|
|
//click event handler for clear button
|
|
|
|
$("a.clear-selected-entities").click(function(){
|
|
|
|
clearRenderedObjects();
|
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When the intra-entity parameters are clicked,
|
|
|
|
* update the status accordingly.
|
|
|
|
*/
|
|
|
|
|
|
|
|
$("select.comparisonValues").change(function(){
|
|
|
|
|
|
|
|
var selectedValue = $("select.comparisonValues option:selected").val();
|
|
|
|
|
|
|
|
var selectedParameter;
|
|
|
|
|
|
|
|
$.each(COMPARISON_PARAMETERS_INFO, function(index, parameter) {
|
|
|
|
|
|
|
|
if (parameter.value === selectedValue) {
|
|
|
|
selectedParameter = parameter;
|
2011-01-25 20:09:32 +00:00
|
|
|
window.location = parameter.viewLink;
|
2011-01-25 00:55:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2011-01-25 20:08:54 +00:00
|
|
|
$("#body").empty().html("<div id='loading-comparisons'>Loading " + selectedValue + " <img src='" + loadingImageLink + "' /></div>");
|
2011-01-25 01:28:11 +00:00
|
|
|
|
2011-01-25 00:55:47 +00:00
|
|
|
/*
|
|
|
|
* This piece of code is not executed at all because the redirect happens before there is a chance
|
|
|
|
* to render the below contents.
|
|
|
|
* */
|
|
|
|
|
2011-01-25 01:28:11 +00:00
|
|
|
/*
|
|
|
|
|
2011-01-25 00:55:47 +00:00
|
|
|
$("#comparisonParameter").text("Total Number of " + selectedValue);
|
|
|
|
$('#yaxislabel').html("Number of " + selectedValue).mbFlipText(false);
|
|
|
|
$('#yaxislabel').css("color", "#595B5B");
|
2011-01-25 01:28:11 +00:00
|
|
|
$('#comparisonHeader').html(selectedValue).css('font-weight', 'bold');
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
2011-01-25 00:55:47 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$("input[type=checkbox].easyDeselectCheckbox").live('click', function(){
|
|
|
|
|
|
|
|
var checkbox = $(this);
|
|
|
|
var checkboxValue = $(this).attr("value");
|
|
|
|
var linkedCheckbox = labelToCheckedEntities[checkboxValue];
|
|
|
|
var entityToBeRemoved = labelToEntityRecord[checkboxValue];
|
|
|
|
|
|
|
|
if(!checkbox.is(':checked')){
|
|
|
|
//console.log("Easy deselect checkbox is unclicked!");
|
|
|
|
updateRowHighlighter(linkedCheckbox);
|
|
|
|
removeUsedColor(entityToBeRemoved);
|
|
|
|
removeEntityUnChecked(renderedObjects, entityToBeRemoved);
|
|
|
|
removeLegendRow(linkedCheckbox);
|
|
|
|
removeCheckBoxFromGlobalSet(linkedCheckbox);
|
|
|
|
$(linkedCheckbox).attr('checked', false);
|
|
|
|
checkIfColorLimitIsReached();
|
|
|
|
displayLineGraphs();
|
|
|
|
updateCounter();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox) {
|
|
|
|
|
|
|
|
removeUsedColor(entity);
|
|
|
|
removeEntityUnChecked(renderedObjects, entity);
|
|
|
|
removeLegendRow(checkbox);
|
|
|
|
removeCheckBoxFromGlobalSet(checkbox);
|
|
|
|
|
|
|
|
checkbox.closest("tr").removeClass('datatablerowhighlight');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox) {
|
|
|
|
|
|
|
|
getNextFreeColor(entity);
|
|
|
|
|
|
|
|
//Generate the bar, checkbox and label for the legend.
|
|
|
|
createLegendRow(entity, $("#bottom"));
|
|
|
|
|
|
|
|
renderLineGraph(renderedObjects, entity);
|
|
|
|
labelToCheckedEntities[checkboxValue] = checkbox;
|
2011-01-26 18:15:17 +00:00
|
|
|
labelToCheckedEntities[checkboxValue].entity = entity;
|
|
|
|
|
|
|
|
// console.log(labelToCheckedEntities[checkboxValue], entity);
|
2011-01-25 00:55:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* To highlight the rows belonging to selected entities.
|
|
|
|
* */
|
|
|
|
checkbox.closest("tr").addClass('datatablerowhighlight');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function performEntityCheckboxClickedRedrawActions() {
|
|
|
|
|
|
|
|
setTickSizeOfAxes();
|
|
|
|
checkIfColorLimitIsReached();
|
|
|
|
displayLineGraphs();
|
|
|
|
updateCounter();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* function to populate the labelToEntityRecord object with the
|
|
|
|
* values from the json file and
|
|
|
|
* dynamically generate checkboxes
|
|
|
|
*/
|
|
|
|
function loadData(jsonData) {
|
|
|
|
|
|
|
|
// var yearRange;
|
|
|
|
$.each(jsonData, function (index, val) {
|
|
|
|
setOfLabels.push(val.label);
|
|
|
|
labelToEntityRecord[val.label] = val;
|
|
|
|
});
|
|
|
|
|
|
|
|
getEntityVisMode(jsonData);
|
|
|
|
prepareTableForDataTablePagination(jsonData);
|
|
|
|
setEntityLevel();
|
|
|
|
|
|
|
|
$(".disabled-checkbox-event-receiver").live("click", function () {
|
|
|
|
|
|
|
|
if ($(this).next().is(':disabled')) {
|
|
|
|
|
|
|
|
createNotification("warning-notification", {
|
|
|
|
title: 'Error',
|
|
|
|
text: 'A Maximum 10 entities can be compared. Please remove some & try again.'
|
|
|
|
}, {
|
|
|
|
custom: true,
|
|
|
|
expires: false
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2011-01-26 18:15:17 +00:00
|
|
|
/*
|
|
|
|
* When the elements in the paginated div
|
|
|
|
* are clicked this event handler is called
|
|
|
|
*/
|
|
|
|
$("input." + entityCheckboxSelectorDOMClass).live('click', function () {
|
2011-01-25 00:55:47 +00:00
|
|
|
|
|
|
|
var checkbox = $(this);
|
|
|
|
var checkboxValue = $(this).attr("value");
|
|
|
|
var entity = labelToEntityRecord[checkboxValue];
|
|
|
|
|
|
|
|
if (checkbox.is(':checked')) {
|
|
|
|
|
|
|
|
performEntityCheckboxSelectedActions(entity, checkboxValue, checkbox);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
performEntityCheckboxUnselectedActions(entity, checkboxValue, checkbox);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
performEntityCheckboxClickedRedrawActions();
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-01-26 18:15:17 +00:00
|
|
|
function initiateTemporalGraphRenderProcess(givenGraphContainer, jsonData) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* initial display of the grid when the page loads
|
|
|
|
* */
|
|
|
|
init(givenGraphContainer);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* render the temporal graph per the sent content.
|
|
|
|
* */
|
|
|
|
loadData(jQuery.parseJSON(jsonData));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This will make sure that top 3 entities are selected by default when the page loads.
|
|
|
|
*/
|
|
|
|
$.each($("input." + entityCheckboxSelectorDOMClass), function(index, checkbox) {
|
2011-01-25 00:55:47 +00:00
|
|
|
|
2011-01-26 18:15:17 +00:00
|
|
|
if (index > 2) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-25 00:55:47 +00:00
|
|
|
|
2011-01-26 18:15:17 +00:00
|
|
|
$(this).attr('checked', true);
|
|
|
|
|
|
|
|
var checkboxValue = $(this).attr("value");
|
|
|
|
var entity = labelToEntityRecord[checkboxValue];
|
|
|
|
|
|
|
|
performEntityCheckboxSelectedActions(entity, checkboxValue, $(this));
|
|
|
|
|
|
|
|
performEntityCheckboxClickedRedrawActions();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
2011-01-25 00:55:47 +00:00
|
|
|
|
2011-01-26 18:15:17 +00:00
|
|
|
initiateTemporalGraphRenderProcess(graphContainer, jsonString);
|
2011-01-25 00:55:47 +00:00
|
|
|
});
|