Ignore:
Timestamp:
Jun 7, 2011, 12:43:21 PM (13 years ago)
Author:
dennisw
Message:

Switching to jquery.

Location:
src/django_gheat/website
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/website/static/heatmap_extensions_test.js

    r9233 r9234  
    3333// Uses zoomlevel en mouseposition to call the nodelist.py view. View returns nodes in json format which is read and printed in document element.
    3434function getNodeList(zoomlevel, mousepos) {
    35   var url = "/website/nodelist/" + zoomlevel + "," + mousepos.lat + "," + mousepos.lon;
    36   var ajax = new AjaxRequest(url, setNodeList);
    37   ajax.doGet();
    38 }
    39 
    40 
    41 function setNodeList(responseText) {
    42   json_nodelist=eval('(' + responseText + ')');
    43   if (json_nodelist.length>0){
    44     list = 'Wireless Leiden nodes on mouseposition:<br /><b>';
    45     for (var i=0; i<json_nodelist.length; i++){
    46       list += json_nodelist[i].fields.ssid + '<br />';
     35  $.getJSON("/website/nodelist/" + zoomlevel + "," + mousepos.lat + "," + mousepos.lon,
     36    function(json) {
     37      content = 'Wireless Leiden nodes on mouseposition:<br /><b>';
     38      $.each(json, function(i,json){
     39        content += json.fields.ssid;
     40      });
     41      content += '</br>';
     42      $("#node_list").html(content);
    4743    }
    48     list += '</b>';
    49   }
    50   else{
    51     list = 'No nodes to display.';
    52   }
    53   document.getElementById('node_list').innerHTML=list;
     44  );
    5445}
    5546
  • src/django_gheat/website/templates/home.html

    r9223 r9234  
    22<head>
    33  <link href="{{ STATIC_URL }}style.css" rel="stylesheet" type="text/css" media="screen" />
     4  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    45  <script type="text/javascript" language="Javascript" src="{{ STATIC_URL }}OpenLayers.js"></script>
    56  <script type="text/javascript" language="Javascript" src="{{ STATIC_URL }}OpenStreetMap.js"></script>
    67  <script type="text/javascript" language="Javascript" src="{{ STATIC_URL }}heatmap.js"></script>
    78  <script type="text/javascript" language="Javascript" src="{{ STATIC_URL }}heatmap_extensions_test.js"></script>
    8   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    99  <script language="javascript" type="text/javascript">
    10     function toggleDiv(div){
    11       var show = div;
    12       var hide;
    13       if(show == 'info'){
    14         hide = 'filter';
    15       }
    16       else{
    17         hide = 'info';
    18       }     
    19       if(document.getElementById(show).style.display != 'block'){
    20         document.getElementById(show).style.display = 'block';
    21         document.getElementById(hide).style.display = 'none';
    22       }
    23       else{
    24         document.getElementById(show).style.display = 'none';
    25         document.getElementById(hide).style.display = 'none';
    26       }
    27     }
     10    $(function(){
     11      $('#menu_filter').click(function(){
     12        $('#filter').slideToggle('fast');
     13        $('#info').slideUp('fast');
     14      });
     15      $('#menu_info').click(function(){
     16        $('#filter').slideUp('fast');
     17        $('#info').slideToggle('fast');
     18      });
     19    });
    2820  </script>
    2921</head>
    30 
    31 
    3222<body onload="init(), get_filters()">
    3323  <div id="heatmap"></div>
     
    3727    </div>
    3828    <div id="menu">
    39       <a href="javascript:toggleDiv('info')">Info</a>
    40       <a href="javascript:toggleDiv('filter')">Filters</a>
     29      <a id="menu_info">Info</a>
     30      <a id="menu_filter">Filters</a>
    4131    </div>
    4232    <div id="info">
     
    5040      </div>
    5141      <div id="filter_list">
    52 
    5342      </div>
    5443    </div>
Note: See TracChangeset for help on using the changeset viewer.