-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.js
50 lines (42 loc) · 1.26 KB
/
actions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var color = d3.scale.category10();
function update_node_colors(colors) {
$("circle").each(function() {
$(this).attr('group',colors[$(this).attr('name')]);
$(this).css("fill",color($(this).attr('group')));
});
}
function update_weights(copweight,robweight) {
$(".copcount,.coppic").each(function () {
$(this).attr("weight",copweight[$(this).attr('vertex_id')]);
});
$(".robcount,.robpic").each(function () {
$(this).attr("weight",robweight[$(this).attr('vertex_id')]);
});
$("text.copcount,text.robcount").each(function () {
$(this).text($(this).attr('weight'));
});
$(".copcount,.coppic,.robcount,.robpic").each(function () {
if( $(this).attr('weight') != "0"){
$(this).css("display","block");
}
else{
$(this).css("display","none");
}
});
}
function onclick (d) {
$.ajax({
url: '/click_on_node',
data: JSON.stringify({'node_clicked':d}),
type: 'POST',
success: function(response) {
//console.log(response);
response = jQuery.parseJSON(response);
update_node_colors(response['focused']);
update_weights(response['copweight'],response['robweight']);
},
error: function(error) {
console.log(error);
}
});
}