2014-02-01 08:57:19 +00:00
|
|
|
// create filters for maps
|
2012-10-22 01:10:43 +00:00
|
|
|
|
2012-12-14 18:31:39 +00:00
|
|
|
function switchVisible(category, duration) {
|
2012-10-22 01:10:43 +00:00
|
|
|
if (categoryVisible[category] == true) {
|
2012-12-14 18:31:39 +00:00
|
|
|
hideCategory(category, duration);
|
2012-10-22 01:10:43 +00:00
|
|
|
}
|
|
|
|
else if (categoryVisible[category] == false) {
|
2012-12-14 18:31:39 +00:00
|
|
|
showCategory(category, duration);
|
2012-10-22 01:10:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-14 18:31:39 +00:00
|
|
|
function hideCategory(category, duration) {
|
2012-10-22 01:10:43 +00:00
|
|
|
if (duration == null) duration = 500;
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.graph.eachNode( function (n) {
|
2013-01-01 22:45:35 +00:00
|
|
|
if (n.getData('metacode') == category) {
|
2012-12-22 08:32:12 +00:00
|
|
|
n.setData('alpha', 0.4, 'end');
|
2012-10-22 01:10:43 +00:00
|
|
|
n.eachAdjacency(function(adj) {
|
2012-12-22 08:32:12 +00:00
|
|
|
adj.setData('alpha', 0.4, 'end');
|
2012-10-22 01:10:43 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.fx.animate({
|
2012-10-22 01:10:43 +00:00
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: duration
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-12-14 18:31:39 +00:00
|
|
|
function showCategory(category, duration) {
|
2012-10-22 01:10:43 +00:00
|
|
|
if (duration == null) duration = 500;
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.graph.eachNode( function (n) {
|
2013-01-01 22:45:35 +00:00
|
|
|
if (n.getData('metacode') == category) {
|
2012-10-22 01:10:43 +00:00
|
|
|
n.setData('alpha', 1, 'end');
|
|
|
|
n.eachAdjacency(function(adj) {
|
|
|
|
adj.setData('alpha', 1, 'end');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.fx.animate({
|
2012-10-22 01:10:43 +00:00
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: duration
|
|
|
|
});
|
|
|
|
}
|
2012-11-23 19:00:00 +00:00
|
|
|
|
2012-12-22 08:32:12 +00:00
|
|
|
// These functions toggle ALL nodes and synapses on the page
|
2012-12-14 18:31:39 +00:00
|
|
|
function hideAll(duration) {
|
2012-11-23 19:00:00 +00:00
|
|
|
if (duration == null) duration = 500;
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.graph.eachNode( function (n) {
|
2014-02-01 08:57:19 +00:00
|
|
|
n.setData('alpha', 0.4, 'end');
|
|
|
|
n.eachAdjacency(function(adj) {
|
|
|
|
adj.setData('alpha', 0.2, 'end');
|
|
|
|
});
|
2012-11-23 19:00:00 +00:00
|
|
|
});
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.fx.animate({
|
2012-11-23 19:00:00 +00:00
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: duration
|
|
|
|
});
|
|
|
|
}
|
2012-12-14 18:31:39 +00:00
|
|
|
function showAll(duration) {
|
2012-11-23 19:00:00 +00:00
|
|
|
if (duration == null) duration = 500;
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.graph.eachNode( function (n) {
|
2012-11-23 19:00:00 +00:00
|
|
|
n.setData('alpha', 1, 'end');
|
|
|
|
n.eachAdjacency(function(adj) {
|
2014-02-01 08:57:19 +00:00
|
|
|
adj.setData('alpha', 0.4, 'end');
|
2012-11-23 19:00:00 +00:00
|
|
|
});
|
|
|
|
});
|
2012-12-15 07:39:14 +00:00
|
|
|
Mconsole.fx.animate({
|
2012-11-23 19:00:00 +00:00
|
|
|
modes: ['node-property:alpha',
|
|
|
|
'edge-property:alpha'],
|
|
|
|
duration: duration
|
|
|
|
});
|
|
|
|
}
|
2012-12-16 20:00:43 +00:00
|
|
|
|
2014-02-01 08:57:19 +00:00
|
|
|
function filterTopicsByMap(mapID) {
|
2013-02-22 00:59:59 +00:00
|
|
|
Mconsole.graph.eachNode(function (n) {
|
2014-02-01 08:57:19 +00:00
|
|
|
if (n.getData('inmaps').indexOf(parseInt(mapID)) !== -1) {
|
|
|
|
n.setData('alpha', 1, 'end');
|
2013-02-22 00:59:59 +00:00
|
|
|
}
|
2014-02-01 08:57:19 +00:00
|
|
|
else {
|
|
|
|
n.setData('alpha', 0.4, 'end');
|
2013-02-22 00:59:59 +00:00
|
|
|
}
|
2014-02-01 08:57:19 +00: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-22 00:59:59 +00:00
|
|
|
}
|
2014-02-01 08:57:19 +00: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 08:32:12 +00:00
|
|
|
|
2012-12-25 23:29:20 +00:00
|
|
|
function clearCanvas() {
|
2013-02-15 02:58:55 +00: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 23:29:20 +00:00
|
|
|
}
|
2012-12-22 08:32:12 +00:00
|
|
|
|
2013-02-22 00:59:59 +00:00
|
|
|
/**
|
2014-02-01 08:57:19 +00:00
|
|
|
* Define all the dynamic interactions for the Filter By Metacode using Jquery
|
2013-02-22 00:59:59 +00:00
|
|
|
*/
|
2014-02-01 08:57:19 +00:00
|
|
|
|
2012-12-22 08:32:12 +00:00
|
|
|
$(document).ready(function() {
|
2014-02-01 08:57:19 +00:00
|
|
|
$('.sidebarFilterBox .showAll').click(function(e) {
|
2013-02-22 01:52:46 +00:00
|
|
|
showAll();
|
2014-02-01 08:57:19 +00:00
|
|
|
$('#filter_by_metacode ul li').removeClass('toggledOff');
|
2013-02-22 01:52:46 +00:00
|
|
|
for (var catVis in categoryVisible) {
|
|
|
|
categoryVisible[catVis] = true;
|
|
|
|
}
|
|
|
|
});
|
2014-02-01 08:57:19 +00:00
|
|
|
$('.sidebarFilterBox .hideAll').click(function(e) {
|
2013-02-22 01:52:46 +00:00
|
|
|
hideAll();
|
2014-02-01 08:57:19 +00:00
|
|
|
$('#filter_by_metacode ul li').addClass('toggledOff');
|
2013-02-22 01:52:46 +00:00
|
|
|
for (var catVis in categoryVisible) {
|
|
|
|
categoryVisible[catVis] = false;
|
|
|
|
}
|
2014-02-01 08:57:19 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// toggle visibility of topics with metacodes based on status in the filters list
|
|
|
|
$('#filter_by_metacode ul li').click(function(event) {
|
|
|
|
|
2013-02-22 01:52:46 +00: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 08:57:19 +00:00
|
|
|
});
|