Merge branch 'fed4fire' into onelab
[myslice.git] / portal / static / js / onelab_slice-resource-view.js
1 $(document).ready(function() {
2     $('li#GoogleMap').click(function (e) {
3         $('.'+this.id).trigger('show');
4     });
5
6     $('a.sl-platform').click(function (e) {
7         $('.'+this.id).trigger('show');
8     });
9
10
11         $('ul.nav-resources a').click(function() {
12         $('ul.nav-resources li').removeClass('active');
13         $(this).parent().addClass('active');
14         $('div.panel').hide();
15         $('div#'+$(this).data('panel')).show();
16         /*
17         if ($(this).data('panel') == 'map') {
18                 mapInit();
19         }
20         */
21     });
22     $('div.list-resources a').click(function() {
23         $('div.list-resources a').removeClass('active');
24         $(this).addClass('active');
25         $('div.panel').hide();
26         $('div#'+$(this).data('panel')).show();
27        
28     });
29     
30     // Unused "List of testbeds" tab
31     /*
32     $.get("/rest/network", function(data) {
33                 var list = '<div class="list-group-item sl-platform"><span class="list-group-item-heading">Testbeds</span></div>';
34                 for(i=0; i<data.length;i++) {
35                         list += '<a href="#" class="list-group-item sl-platform" data-platform="'+data[i].network_hrn+'"><span class="list-group-item-heading">'+data[i].network_longname+'</span><p class="list-group-item-text">'+data[i].network_hrn+'</p></a>';
36                 }
37                 $('#select-platform').html(list);
38         }).done(function() {
39                 
40         });
41         */
42
43         $('button#ApplyPendind').click(function() {
44                 myslice.apply();
45                 // $.each(myslice.pending, function(k, p) {
46                         // console.log(p);
47                 // });
48                 // $.post("/update/slice", {}, function() {
49 //                      
50                 // });
51         });
52         
53    //google.maps.event.addDomListener(window, 'load', initialize);
54 });
55
56 function mapInit() {
57         
58     $.get("/rest/resource/", {"fields" : ["hostname","latitude","longitude"] }, function(data) {
59         
60                 var mapOptions = {
61               center: new google.maps.LatLng(48.8567, 2.3508),
62               zoom: 4,
63               scrollwheel: false
64             };
65             var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
66                  marker = new google.maps.Marker({
67                         position: new google.maps.LatLng(48.8567, 2.3508),
68                         map: map,
69                         icon: '/static/img/marker2.png'
70                     });
71                 
72                 for (i = 0; i < data.length; i++) {  
73                         if (!data[i].longitude) continue;
74                     marker = new google.maps.Marker({
75                         position: new google.maps.LatLng(data[i].latitude, data[i].longitude),
76                         map: map
77                     });
78                         var infowindow = new google.maps.InfoWindow();
79
80                         google.maps.event.addListener(marker, 'click', (function(marker, i) {
81                         return function() {
82                           infowindow.setContent(data[i].hostname);
83                           infowindow.open(map, marker);
84                         };
85                 })(marker, i));
86             }
87           });
88 }