Changeset 6034

Show
Ignore:
Timestamp:
11/14/12 22:05:57 (7 years ago)
Author:
leonwlaw
Message:

Allpairspingmap webpage autorefreshes if the geoip lookup didn't finish yet.

Location:
seattle/trunk/repy/apps/allpairspingmap
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • seattle/trunk/repy/apps/allpairspingmap/allpairspingmap.mix

    r6033 r6034  
    191191  # Is there a specific reason why we sort these keys?  I'm leaving these 
    192192  # intact since the original version sorted them. 
    193   nodeiplist = mycontext['locationdata'].keys() 
     193  nodeiplist = mycontext['neighborlist'] 
    194194  nodeiplist.sort() 
    195195 
    196196  nodelist_str = '<ul id="coords">' 
    197   for nodeip, nodelocdict in mycontext['locationdata'].iteritems(): 
     197  for nodeip in nodeiplist: 
    198198    # Print node list element 
    199199    nodelist_str += ('<li id="node' + str(nodeiplist.index(nodeip)) + '"><span class="nodeip">' + 
    200200                      str(nodeip) + '</span>') 
    201201     
    202     if nodelocdict is not None: 
    203       nodelist_str += ('<span class="longitude">' + str(nodelocdict['longitude']) + 
    204                         '</span><span class="latitude">' + str(nodelocdict['latitude']) + 
    205                         '</span><span class="locationname">' + geoip_location_str(nodelocdict) + '</span>') 
     202    if nodeip in mycontext['locationdata']: 
     203      nodelocdict = mycontext['locationdata'][nodeip] 
     204      if nodelocdict is not None: 
     205        nodelist_str += ('<span class="longitude">' + str(nodelocdict['longitude']) + 
     206                          '</span><span class="latitude">' + str(nodelocdict['latitude']) + 
     207                          '</span><span class="locationname">' + geoip_location_str(nodelocdict) + '</span>') 
     208    # We didn't perform the lookup yet.  This is used to tell the client to  
     209    # refresh the page. 
    206210    else: 
    207       nodelist_str += "No location data available" 
     211      nodelist_str += "<span class='lookingup'></span>" 
    208212    nodelist_str += '</li>' 
    209213  nodelist_str += '</ul>' 
  • seattle/trunk/repy/apps/allpairspingmap/jquerygmaps.js

    r6032 r6034  
    99    var markers = []; 
    1010    $("ul#coords li").each(function(i) { 
    11       var latitude = $(this).children(".latitude").text(); 
    12       var longitude = $(this).children(".longitude").text(); 
    13       var point = new GLatLng(latitude, longitude); 
    14       marker = new GMarker(point); 
    15       map.addOverlay(marker); 
    16       marker.setImage("map_marker_icon.png"); 
    17       map.setCenter(point, 2); 
    18       markers[i] = marker; 
     11      // Do we have this node's location data? 
     12      if ($(this).children(".latitude").length) { 
     13        var latitude = $(this).children(".latitude").text(); 
     14        var longitude = $(this).children(".longitude").text(); 
     15        var point = new GLatLng(latitude, longitude); 
     16        marker = new GMarker(point); 
     17        map.addOverlay(marker); 
     18        marker.setImage("map_marker_icon.png"); 
     19        map.setCenter(point, 2); 
     20        markers[i] = marker; 
     21      } 
    1922    }); 
    2023 
     
    4548    $("#message").show().css({ top:markerOffset.y, left:markerOffset.x }); 
    4649  } 
     50   
     51   
     52  // Only initialize the map if we have some geoip data to display 
     53  if ($(".latitude").length) { 
     54    var map = initialize_map(); 
     55    $("#message").appendTo(map.getPane(G_MAP_FLOAT_SHADOW_PANE)); 
     56    var selected_node; 
     57    var selected_marker; 
     58    var selected_location; 
     59    var line; 
     60  } else { 
     61    // Remove the map constraints if we can't display the map 
     62    $('#map').css('width', 'auto').css('height', 'auto').text('No location data loaded!') 
     63  } 
     64   
     65  if ($('.lookingup').length) 
     66    // Reload after 5 seconds 
     67    setTimeout(function() {location.reload()}, 5000) 
    4768 
    48  
    49   var map = initialize_map(); 
    50   $("#message").appendTo(map.getPane(G_MAP_FLOAT_SHADOW_PANE)); 
    51   var selected_node; 
    52   var selected_marker; 
    53   var selected_location; 
    54   var line; 
    5569}); 
  • seattle/trunk/repy/apps/allpairspingmap/style.css

    r6032 r6034  
    88   display: none; 
    99} 
     10 
    1011#map { 
    11    width: 100%; 
     12   width: 1024px; 
    1213   height: 600px; 
    1314} 
     15 
    1416.gmnoprint { 
    1517   font-family: sans-serif;