2014-02-01 03:57:19 -05:00
|
|
|
// create filters for maps
|
2012-10-21 21:10:43 -04:00
|
|
|
|
2012-12-14 13:31:39 -05:00
|
|
|
function switchVisible(category, duration) {
|
2012-10-21 21:10:43 -04:00
|
|
|
if (categoryVisible[category] == true) {
|
2012-12-14 13:31:39 -05:00
|
|
|
hideCategory(category, duration);
|
2012-10-21 21:10:43 -04:00
|
|
|
}
|
|
|
|
else if (categoryVisible[category] == false) {
|
2012-12-14 13:31:39 -05:00
|
|
|
showCategory(category, duration);
|
2012-10-21 21:10:43 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-14 13:31:39 -05:00
|
|
|
function hideCategory(category, duration) {
|
2012-10-21 21:10:43 -04:00
|
|
|
if (duration == null) duration = 500;
|
2012-12-15 02:39:14 -05:00
|
|
|
Mconsole.graph.eachNode( function (n) {
|
2013-01-01 17:45:35 -05:00
|
|
|
if (n.getData('metacode') == category) {
|
2012-12-22 03:32:12 -05:00
|
|
|
n.setData('alpha', 0.4, 'end');
|
2012-10-21 21:10:43 -04:00
|
|
|
n.eachAdjacency(function(adj) {
|
2012-12-22 03:32:12 -05:00
|
|
|
adj.setData('alpha', 0.4, 'end');
|
2012-10-21 21:10:43 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2012-12-15 02:39:14 -05:00
|
|
|
Mconsole.fx.animate({
|
2012-10-21 21:10:43 -04:00
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: duration
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-12-14 13:31:39 -05:00
|
|
|
function showCategory(category, duration) {
|
2012-10-21 21:10:43 -04:00
|
|
|
if (duration == null) duration = 500;
|
2012-12-15 02:39:14 -05:00
|
|
|
Mconsole.graph.eachNode( function (n) {
|
2013-01-01 17:45:35 -05:00
|
|
|
if (n.getData('metacode') == category) {
|
2012-10-21 21:10:43 -04:00
|
|
|
n.setData('alpha', 1, 'end');
|
|
|
|
n.eachAdjacency(function(adj) {
|
|
|
|
adj.setData('alpha', 1, 'end');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2012-12-15 02:39:14 -05:00
|
|
|
Mconsole.fx.animate({
|
2012-10-21 21:10:43 -04:00
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: duration
|
|
|
|
});
|
|
|
|
}
|
2012-11-23 11:00:00 -08:00
|
|
|
|
2012-12-22 03:32:12 -05:00
|
|
|
// These functions toggle ALL nodes and synapses on the page
|
2012-12-14 13:31:39 -05:00
|
|
|
function hideAll(duration) {
|
2012-11-23 11:00:00 -08:00
|
|
|
if (duration == null) duration = 500;
|
2012-12-15 02:39:14 -05:00
|
|
|
Mconsole.graph.eachNode( function (n) {
|
2014-02-01 03:57:19 -05:00
|
|
|
n.setData('alpha', 0.4, 'end');
|
|
|
|
n.eachAdjacency(function(adj) {
|
|
|
|
adj.setData('alpha', 0.2, 'end');
|
|
|
|
});
|
2012-11-23 11:00:00 -08:00
|
|
|
});
|
2012-12-15 02:39:14 -05:00
|
|
|
Mconsole.fx.animate({
|
2012-11-23 11:00:00 -08:00
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: duration
|
|
|
|
});
|
|
|
|
}
|
2012-12-14 13:31:39 -05:00
|
|
|
function showAll(duration) {
|
2012-11-23 11:00:00 -08:00
|
|
|
if (duration == null) duration = 500;
|
2012-12-15 02:39:14 -05:00
|
|
|
Mconsole.graph.eachNode( function (n) {
|
2012-11-23 11:00:00 -08:00
|
|
|
n.setData('alpha', 1, 'end');
|
|
|
|
n.eachAdjacency(function(adj) {
|
2014-02-01 03:57:19 -05:00
|
|
|
adj.setData('alpha', 0.4, 'end');
|
2012-11-23 11:00:00 -08:00
|
|
|
});
|
|
|
|
});
|
2012-12-15 02:39:14 -05:00
|
|
|
Mconsole.fx.animate({
|
2012-11-23 11:00:00 -08:00
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: duration
|
|
|
|
});
|
|
|
|
}
|
2012-12-16 15:00:43 -05:00
|
|
|
|
2014-02-01 03:57:19 -05:00
|
|
|
function filterTopicsByMap(mapID) {
|
2013-02-21 19:59:59 -05:00
|
|
|
Mconsole.graph.eachNode(function (n) {
|
2014-02-01 03:57:19 -05:00
|
|
|
if (n.getData('inmaps').indexOf(parseInt(mapID)) !== -1) {
|
|
|
|
n.setData('alpha', 1, 'end');
|
2013-02-21 19:59:59 -05:00
|
|
|
}
|
2014-02-01 03:57:19 -05:00
|
|
|
else {
|
|
|
|
n.setData('alpha', 0.4, 'end');
|
2013-02-21 19:59:59 -05:00
|
|
|
}
|
2014-02-01 03:57:19 -05:00
|
|
|
Mconsole.fx.animate({
|
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} // filterTopicsByName
|
|
|
|
|
|
|
|
function filterTopicsByMapper(mapperID) {
|
|
|
|
Mconsole.graph.eachNode(function (n) {
|
|
|
|
if (n.getData('userid').toString() == mapperID) {
|
|
|
|
n.setData('alpha', 1, 'end');
|
2013-02-21 19:59:59 -05:00
|
|
|
}
|
2014-02-01 03:57:19 -05:00
|
|
|
else {
|
|
|
|
n.setData('alpha', 0.4, 'end');
|
|
|
|
}
|
|
|
|
Mconsole.fx.animate({
|
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} // filterTopicsByName
|
|
|
|
|
|
|
|
function filterTopicsByName(searchQuery) {
|
|
|
|
Mconsole.graph.eachNode(function (n) {
|
|
|
|
nodeName = n.name.toLowerCase();
|
|
|
|
if (nodeName.indexOf(searchQuery) !== -1 && searchQuery != "") {
|
|
|
|
n.setData('alpha', 1, 'end');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
n.setData('alpha', 0.4, 'end');
|
|
|
|
}
|
|
|
|
Mconsole.fx.animate({
|
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} // filterTopicsByName
|
2012-12-22 03:32:12 -05:00
|
|
|
|
2012-12-25 18:29:20 -05:00
|
|
|
function clearCanvas() {
|
2013-02-14 21:58:55 -05:00
|
|
|
Mconsole.graph.eachNode(function(n) {
|
|
|
|
Mconsole.graph.removeNode(n.id);
|
|
|
|
});
|
|
|
|
Mconsole.plot();
|
|
|
|
}
|
|
|
|
|
|
|
|
function clearCanvasExceptRoot() {
|
|
|
|
var ids = new Array();
|
|
|
|
Mconsole.graph.eachNode(function(n) {
|
|
|
|
ids.push(n.id);
|
|
|
|
});
|
|
|
|
|
|
|
|
var root = Mconsole.graph.nodes[Mconsole.root];
|
|
|
|
ids.forEach(function(id, index) {
|
|
|
|
if (id != root.id) {
|
|
|
|
Mconsole.graph.removeNode(id);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
fetchRelatives(root); //also runs Mconsole.plot()
|
2012-12-25 18:29:20 -05:00
|
|
|
}
|
2012-12-22 03:32:12 -05:00
|
|
|
|
2013-02-21 19:59:59 -05:00
|
|
|
/**
|
2014-02-01 03:57:19 -05:00
|
|
|
* Define all the dynamic interactions for the Filter By Metacode using Jquery
|
2013-02-21 19:59:59 -05:00
|
|
|
*/
|
2014-02-01 03:57:19 -05:00
|
|
|
|
2012-12-22 03:32:12 -05:00
|
|
|
$(document).ready(function() {
|
2014-02-01 03:57:19 -05:00
|
|
|
$('.sidebarFilterBox .showAll').click(function(e) {
|
2013-02-21 20:52:46 -05:00
|
|
|
showAll();
|
2014-02-01 03:57:19 -05:00
|
|
|
$('#filter_by_metacode ul li').removeClass('toggledOff');
|
2013-02-21 20:52:46 -05:00
|
|
|
for (var catVis in categoryVisible) {
|
|
|
|
categoryVisible[catVis] = true;
|
|
|
|
}
|
|
|
|
});
|
2014-02-01 03:57:19 -05:00
|
|
|
$('.sidebarFilterBox .hideAll').click(function(e) {
|
2013-02-21 20:52:46 -05:00
|
|
|
hideAll();
|
2014-02-01 03:57:19 -05:00
|
|
|
$('#filter_by_metacode ul li').addClass('toggledOff');
|
2013-02-21 20:52:46 -05:00
|
|
|
for (var catVis in categoryVisible) {
|
|
|
|
categoryVisible[catVis] = false;
|
|
|
|
}
|
2014-02-01 03:57:19 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// toggle visibility of topics with metacodes based on status in the filters list
|
|
|
|
$('#filter_by_metacode ul li').click(function(event) {
|
|
|
|
|
2013-02-21 20:52:46 -05:00
|
|
|
var category = $(this).children('img').attr('alt');
|
|
|
|
switchVisible(category);
|
|
|
|
|
|
|
|
// toggle the image and the boolean array value
|
|
|
|
if (categoryVisible[category] == true) {
|
|
|
|
$(this).addClass('toggledOff');
|
|
|
|
categoryVisible[category] = false;
|
|
|
|
}
|
|
|
|
else if (categoryVisible[category] == false) {
|
|
|
|
$(this).removeClass('toggledOff');
|
|
|
|
categoryVisible[category] = true;
|
|
|
|
}
|
|
|
|
});
|
2014-02-01 03:57:19 -05:00
|
|
|
});
|