blob: 976f8dea288cc4f6bd65b39af7e62ccb815a5291 (
plain) (
blame)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
var githubNodesObj = {};
var githubEdgesObj = {};
var graphAttributes = {};
// Interface:
function init(){
getGraphAttributes()
}
function newQuery(query){
sigmaDOM = thisMovie("SiGMa");
getGithubGraph(query);
}
function thisMovie(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document[movieName];
}
}
function setComboBoxes(){
var colorAtts = [];
var sizeAtts = [];
for(var att in graphAttributes){
graphAttributes[att]["id"] = att;
if(graphAttributes[att]["type"]=="Num"){
sizeAtts.push(graphAttributes[att]);
colorAtts.push(graphAttributes[att]);
}else{
colorAtts.push(graphAttributes[att]);
}
}
var nodes_color = document.forms["node_properties"]["nodes_color"];
var nodes_size = document.forms["node_properties"]["nodes_size"];
while(nodes_color.options.length) nodes_color.options.remove(0);
while(nodes_size.options.length) nodes_size.options.remove(0);
var i;
var optn;
var l=colorAtts.length;
for(i=0;i<l;i++){
optn = document.createElement("OPTION");
optn.text = colorAtts[i]["label"] ? colorAtts[i]["label"] : colorAtts[i]["id"];
optn.value = colorAtts[i]["id"];
nodes_color.options.add(optn);
}
l=sizeAtts.length;
for(i=0;i<l;i++){
optn = document.createElement("OPTION");
optn.text = sizeAtts[i]["label"] ? sizeAtts[i]["label"] : sizeAtts[i]["id"];
optn.value = sizeAtts[i]["id"];
nodes_size.options.add(optn)
}
}
// SiGMa interaction:
function toggleDisplayLabels(){
if(sigmaDOM){
if(sigmaDOM.getDisplayLabels()){
sigmaDOM.setDisplayLabels(false);
}else{
sigmaDOM.setDisplayLabels(true);
}
}
}
function toggleDisplayEdges(){
if(sigmaDOM){
if(sigmaDOM.getDisplayEdges()){
sigmaDOM.setDisplayEdges(false);
}else{
sigmaDOM.setDisplayEdges(true);
}
}
}
function toggleFishEye(){
if(sigmaDOM){
if(sigmaDOM.hasFishEye()){
sigmaDOM.deactivateFishEye();
}else{
sigmaDOM.activateFishEye();
}
}
}
function resetGraph(graph){
recenterGraph();
killForceAtlas();
deleteGraph();
updateGraph(graph);
initForceAtlas();
setColor(document.forms["node_properties"]["nodes_color"].value,graphAttributes);
setSize(document.forms["node_properties"]["nodes_size"].value);
}
function onClickNodes(nodesArray){
if(nodesArray.length){
sigmaDOM = thisMovie("SiGMa");
query = nodesArray[0];
getGithubGraph(query);
document.getElementById("query").value = query;
}
}
function onOverNodes(nodesArray){
for(var i=0;i<nodesArray.length;i++){
console.debug("node: "+nodesArray[i]);
}
}
// Github network:
function getGithubGraph(user){
url = "/graph/local/"+user;
$.ajax({
url: url,
dataType: 'json',
success:
function(json){
resetGraph(json);
}
});
}
function getGraphAttributes(){
url = "/graph/attributes";
$.ajax({
url: url,
dataType: 'json',
success:
function(json){
graphAttributes = (json && json["attributes"]) ? json["attributes"] : {};
setComboBoxes();
}
});
}
|