blob: d5975076e9bddddd7bbfc21b695de9c021ad1fe8 [file] [log] [blame]
Paul Greyson7a300822013-04-09 12:57:49 -07001/***************************************************************************************************
2extract url parameters into a map
3***************************************************************************************************/
Paul Greysonbcd3c772013-03-21 13:16:44 -07004function parseURLParameters() {
5 var parameters = {};
6
7 var search = location.href.split('?')[1];
8 if (search) {
9 search.split('&').forEach(function (param) {
10 var key = param.split('=')[0];
11 var value = param.split('=')[1];
12 parameters[key] = decodeURIComponent(value);
13 });
14 }
15
16 return parameters;
Paul Greyson5cc35f02013-03-28 10:07:36 -070017}
18
Paul Greyson7a300822013-04-09 12:57:49 -070019/***************************************************************************************************
20convenience function for moving an SVG element to the front so that it draws on top
21***************************************************************************************************/
22d3.selection.prototype.moveToFront = function() {
23 return this.each(function(){
24 this.parentNode.appendChild(this);
25 });
26};
27
28/***************************************************************************************************
29standard function for generating the 'd' attribute for a path from an array of points
30***************************************************************************************************/
31var line = d3.svg.line()
32 .x(function(d) {
33 return d.x;
34 })
35 .y(function(d) {
36 return d.y;
37 });
38
39
40/***************************************************************************************************
41starts the "pending" animation
42***************************************************************************************************/
43function setPending(selection) {
44 selection.classed('pending', false);
45 setTimeout(function () {
46 selection.classed('pending', true);
47 }, 0);
48}
49
50/***************************************************************************************************
51convert angle in degrees to radians
52***************************************************************************************************/
53function toRadians (degrees) {
54 return degrees * (Math.PI / 180);
55}
56
57/***************************************************************************************************
58used to generate DOM element id for this link
59***************************************************************************************************/
60function makeLinkKey(link) {
61 return link['src-switch'] + '=>' + link['dst-switch'];
62}
63
64/***************************************************************************************************
65used to generate DOM element id for this flow in the topology view
66***************************************************************************************************/
67function makeFlowKey(flow) {
68 return flow.srcDpid + '=>' + flow.dstDpid;
69}
70
71/***************************************************************************************************
72used to generate DOM element id for this flow in the selected flows table
73***************************************************************************************************/
74function makeSelectedFlowKey(flow) {
75 return 'S' + makeFlowKey(flow);
76}
77
78/***************************************************************************************************
79update the app header using the current model
80***************************************************************************************************/
81function updateHeader() {
82 d3.select('#lastUpdate').text(new Date());
83 d3.select('#activeSwitches').text(model.edgeSwitches.length + model.aggregationSwitches.length + model.coreSwitches.length);
84 d3.select('#activeFlows').text(model.flows.length);
85}
86
87