mirror of
				https://github.com/opennetworkinglab/onos.git
				synced 2025-11-04 10:11:16 +01:00 
			
		
		
		
	Added 'B' keystroke to toggle background image visibility.
Also added configuration boolean to indicate whether the background image should be visible on startup.
This commit is contained in:
		
							parent
							
								
									76285c7712
								
							
						
					
					
						commit
						ee66e61638
					
				@ -36,8 +36,10 @@
 | 
				
			|||||||
        },
 | 
					        },
 | 
				
			||||||
        options: {
 | 
					        options: {
 | 
				
			||||||
            layering: true,
 | 
					            layering: true,
 | 
				
			||||||
            collisionPrevention: true
 | 
					            collisionPrevention: true,
 | 
				
			||||||
 | 
					            loadBackground: true
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
 | 
					        backgroundUrl: 'img/us-map.png',
 | 
				
			||||||
        data: {
 | 
					        data: {
 | 
				
			||||||
            live: {
 | 
					            live: {
 | 
				
			||||||
                jsonUrl: 'rs/topology/graph',
 | 
					                jsonUrl: 'rs/topology/graph',
 | 
				
			||||||
@ -265,6 +267,9 @@
 | 
				
			|||||||
    function processKeyEvent() {
 | 
					    function processKeyEvent() {
 | 
				
			||||||
        var code = d3.event.keyCode;
 | 
					        var code = d3.event.keyCode;
 | 
				
			||||||
        switch (code) {
 | 
					        switch (code) {
 | 
				
			||||||
 | 
					            case 66:    // B
 | 
				
			||||||
 | 
					                toggleBackground();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
            case 71:    // G
 | 
					            case 71:    // G
 | 
				
			||||||
                cycleLayout();
 | 
					                cycleLayout();
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
@ -281,6 +286,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    function toggleBackground() {
 | 
				
			||||||
 | 
					        var bg = d3.select('#bg'),
 | 
				
			||||||
 | 
					            vis = bg.style('visibility'),
 | 
				
			||||||
 | 
					            newvis = (vis === 'hidden') ? 'visible' : 'hidden';
 | 
				
			||||||
 | 
					        bg.style('visibility', newvis);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function cycleLayout() {
 | 
					    function cycleLayout() {
 | 
				
			||||||
        config.options.layering = !config.options.layering;
 | 
					        config.options.layering = !config.options.layering;
 | 
				
			||||||
        network.force.resume();
 | 
					        network.force.resume();
 | 
				
			||||||
@ -437,8 +449,10 @@
 | 
				
			|||||||
                id: 'bg',
 | 
					                id: 'bg',
 | 
				
			||||||
                width: view.width,
 | 
					                width: view.width,
 | 
				
			||||||
                height: view.height,
 | 
					                height: view.height,
 | 
				
			||||||
                'xlink:href': 'img/us-map.png'
 | 
					                'xlink:href': config.backgroundUrl
 | 
				
			||||||
            });
 | 
					            })
 | 
				
			||||||
 | 
					            .style('visibility',
 | 
				
			||||||
 | 
					                    config.options.loadBackground ? 'visible' : 'hidden');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//        function zoomRedraw() {
 | 
					//        function zoomRedraw() {
 | 
				
			||||||
//            d3.select("#zoomable").attr("transform",
 | 
					//            d3.select("#zoomable").attr("transform",
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user