Fixing visuals for the SDN-IP demo. Fixed performance issue. Pulsing links instead of ants, less frequently and turning off the timer when not needed.
Change-Id: I7100d5da28bcf3a315e34a3ee8c6eb0b1cee0ac2
diff --git a/web/gui/src/main/webapp/topo2.js b/web/gui/src/main/webapp/topo2.js
index b2664fa..2a36dfd 100644
--- a/web/gui/src/main/webapp/topo2.js
+++ b/web/gui/src/main/webapp/topo2.js
@@ -731,10 +731,18 @@
var paths = data.payload.paths;
// Revert any links hilighted previously.
- link.classed('primary secondary animated optical', false);
+ link.attr('stroke-width', null)
+ .style('stroke-width', null)
+ .classed('primary secondary animated optical', false);
// Remove all previous labels.
removeLinkLabels();
+ if (paths.length && !antTimer) {
+ startAntTimer();
+ } else if (!paths.length && antTimer) {
+ stopAntTimer();
+ }
+
// Now hilight all links in the paths payload, and attach
// labels to them, if they are defined.
paths.forEach(function (p) {
@@ -2160,22 +2168,35 @@
// Load map data asynchronously; complete startup after that..
loadGeoJsonData();
- // start the and timer
- var dashIdx = 0;
- antTimer = setInterval(function () {
- // TODO: figure out how to choose Src-->Dst and Dst-->Src, per link
- dashIdx = dashIdx === 0 ? 14 : dashIdx - 2;
- d3.selectAll('.animated').style('stroke-dashoffset', dashIdx);
- }, 35);
+ //var dashIdx = 0;
+ //antTimer = setInterval(function () {
+ // // TODO: figure out how to choose Src-->Dst and Dst-->Src, per link
+ // dashIdx = dashIdx === 0 ? 14 : dashIdx - 2;
+ // d3.selectAll('.animated').style('stroke-dashoffset', dashIdx);
+ //}, 35);
}
- function unload(view, ctx, flags) {
+ function startAntTimer() {
+ var pulses = [ 5, 3, 1.2, 3 ],
+ pulse = 0;
+ antTimer = setInterval(function () {
+ pulse = pulse + 1;
+ pulse = pulse === pulses.length ? 0 : pulse;
+ d3.selectAll('.animated').style('stroke-width', pulses[pulse]);
+ }, 200);
+ }
+
+ function stopAntTimer() {
if (antTimer) {
clearInterval(antTimer);
antTimer = null;
}
}
+ function unload(view, ctx, flags) {
+ stopAntTimer();
+ }
+
// TODO: move these to config/state portion of script
var geoJsonUrl = 'json/map/continental_us.json', // TODO: Paul
geoJson;