2013-01-04 05:20:43 +00:00
|
|
|
function arraysEqual(a1,a2) {
|
|
|
|
return JSON.stringify(a1)==JSON.stringify(a2);
|
|
|
|
}
|
|
|
|
|
|
|
|
newJSON = <%= @mapjson %>;
|
|
|
|
|
|
|
|
if (!arraysEqual(json,newJSON)) {
|
|
|
|
json = newJSON;
|
|
|
|
$.each(json, function(i,topic){
|
|
|
|
var temp = Mconsole.graph.getNode(topic.id);
|
|
|
|
|
|
|
|
// in this case the node wasn't on the page before, so we create it
|
|
|
|
if (temp == null) {
|
|
|
|
Mconsole.graph.addNode(topic);
|
|
|
|
var temp = Mconsole.graph.getNode(topic.id);
|
|
|
|
temp.setData('dim', 1, 'start');
|
|
|
|
temp.setData('dim', 25, 'end');
|
|
|
|
var newPos = new $jit.Complex();
|
|
|
|
newPos.x = temp.data.$xloc;
|
|
|
|
newPos.y = temp.data.$yloc;
|
|
|
|
temp.setPos(newPos, 'start');
|
|
|
|
temp.setPos(newPos, 'current');
|
|
|
|
temp.setPos(newPos, 'end');
|
|
|
|
Mconsole.fx.plotNode(temp, Mconsole.canvas);
|
|
|
|
Mconsole.labels.plotLabel(Mconsole.canvas, temp, Mconsole.config);
|
|
|
|
Mconsole.fx.animate({
|
|
|
|
modes: ['node-property:dim','edge-property:lineWidth'],
|
2013-01-04 06:01:54 +00:00
|
|
|
duration: 1000
|
2013-01-04 05:20:43 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
else { // in this case we found a topic so we have to update it
|
2013-01-04 06:01:54 +00:00
|
|
|
temp.adjacencies = topic.adjacencies;
|
2013-01-04 05:20:43 +00:00
|
|
|
var newPos = new $jit.Complex();
|
|
|
|
newPos.x = temp.data.$xloc;
|
|
|
|
newPos.y = temp.data.$yloc;
|
|
|
|
temp.setPos(newPos, 'end');
|
|
|
|
var label = Mconsole.labels.getLabel(topic.id);
|
2013-01-04 06:01:54 +00:00
|
|
|
if (temp.name != topic.name) {
|
|
|
|
temp.name = topic.name;
|
|
|
|
$(label).find('.best_in_place_name').html(topic.name);
|
|
|
|
$(label).find('.label').html(topic.name);
|
|
|
|
}
|
|
|
|
if (temp.data.$metacode != topic.data.$metacode) {
|
|
|
|
$(label).find('.best_in_place_metacode').html(topic.data.$metacode);
|
|
|
|
$(label).find('img.icon').attr('alt', topic.data.$metacode);
|
|
|
|
$(label).find('img.icon').attr('src', imgArray[topic.data.$metacode].src);
|
|
|
|
}
|
|
|
|
if (temp.data.$desc != topic.data.$desc) {
|
|
|
|
$(label).find('.best_in_place_desc').html(topic.data.$desc);
|
|
|
|
}
|
|
|
|
if (temp.data.$link != topic.data.$link) {
|
|
|
|
$(label).find('.best_in_place_link').html(topic.data.$link);
|
|
|
|
$(label).find('.link').attr('href',topic.data.$link);
|
|
|
|
}
|
|
|
|
temp.data = topic.data;
|
2013-01-04 05:20:43 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Mconsole.animate({
|
|
|
|
modes: ['linear'],
|
|
|
|
transition: $jit.Trans.Quad.easeInOut,
|
|
|
|
duration: 500
|
|
|
|
});
|
|
|
|
}
|