Ignore:
Timestamp:
Jun 17, 2011, 1:13:58 PM (13 years ago)
Author:
dennisw
Message:

Moved scripts from home.html to heatmap_extensions.js for better overview.

Location:
src/django_gheat/website
Files:
2 edited

Legend:

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

    r9265 r9267  
    1414
    1515$(document).ready(function() {
     16  var signallayer = '';
    1617  var userlist = new Array();
    1718  var nodelist = new Array();
     19
     20  // add colour picker
     21  $("#colour").colorPicker();
     22
     23  // add date picker for start date
     24  $("#start_date").datepicker({
     25    dateFormat: "dd/mm/yy",
     26    onSelect: function(dateValue, inst){
     27      $("#end_date").datepicker("option", "minDate", dateValue);
     28    }
     29  });
     30
     31  // add date picker for end date
     32  $("#end_date").datepicker({
     33    dateFormat: "dd/mm/yy",
     34  });
     35
     36  // add slider for signal strength filter
     37  $("#slider").slider({
     38    range: true,
     39    min: 0,
     40    max: 100,
     41    values: [0, 100],
     42    // while sliding, it changes the text above the slider to show the values realtime
     43    slide: function(event, sig){
     44      $("#sig_value").text("Signal strength: " + sig.values[0] + " - " + sig.values[1]);
     45    },
     46    // on slider stop, it tries to delete the old layer and creates a new layer with the slider values
     47    stop: function(event, sig){
     48      if(signallayer){
     49        map.removeLayer(signallayer);
     50      }
     51      OpenLayers.Layer.OSM.Overlay = OpenLayers.Class(OpenLayers.Layer.OSM, {
     52        initialize: function(name, options) {
     53          var url = [
     54            "/website/tile/${z}/${x},${y}.png?colour=0,255,0&signaal__gte=" + sig.values[0] + "&signaal__lte=" + sig.values[1]
     55          ];
     56          options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
     57          var newArguments = [name, url, options];
     58          OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
     59        },
     60      CLASS_NAME: "OpenLayers.Layer.Overlay"
     61      });
     62      signallayer = new OpenLayers.Layer.OSM.Overlay("Signal strength: " + sig.values[0] + " - " + sig.values[1], {isBaseLayer: false, visibility: true});
     63      map.addLayer(signallayer);
     64    },
     65  });
     66
     67  // menu toggle
     68  $("#menu_filter").click(function(){
     69    $("#filter").slideToggle("fast");
     70    $("#info").slideUp("fast");
     71  });
     72  $("#menu_info").click(function(){
     73    $("#filter").slideUp("fast");
     74    $("#info").slideToggle("fast");
     75  });
    1876
    1977  // Fastest?: http://stackoverflow.com/questions/170986/what-is-the-best-way-to-add-options-to-a-select-from-an-array-with-jquery
  • src/django_gheat/website/templates/home.html

    r9266 r9267  
    1111  <script type="text/javascript" language="Javascript" src="{{ STATIC_URL }}colorpicker.js"></script>
    1212  <script type="text/javascript" language="Javascript" src="{{ STATIC_URL }}jquery-ui-1.8.13.custom.min.js"></script>
    13   <script language="javascript" type="text/javascript">
    14     $(function(){
    15       $("#colour").colorPicker();
    16       $("#start_date").datepicker({
    17         dateFormat: "dd/mm/yy",
    18         onSelect: function(dateValue, inst){
    19           $("#end_date").datepicker("option", "minDate", dateValue);
    20         }
    21       });
    22       var signallayer = '';
    23       $("#slider").slider({
    24         range: true,
    25         min: 0,
    26         max: 100,
    27         values: [0, 100],
    28         slide: function(event, sig){
    29           $("#sig_value").text("Signal strength: " + sig.values[0] + " - " + sig.values[1]);
    30         },
    31         stop: function(event, sig){
    32           if(signallayer){
    33             map.removeLayer(signallayer);
    34           }
    35           OpenLayers.Layer.OSM.Overlay = OpenLayers.Class(OpenLayers.Layer.OSM, {
    36             initialize: function(name, options) {
    37               var url = [
    38                 "/website/tile/${z}/${x},${y}.png?colour=0,255,0&signaal__gte=" + sig.values[0] + "&signaal__lte=" + sig.values[1]
    39               ];
    40               options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
    41               var newArguments = [name, url, options];
    42               OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
    43             },
    44           CLASS_NAME: "OpenLayers.Layer.Overlay"
    45           });
    46           signallayer = new OpenLayers.Layer.OSM.Overlay("Signal strength: " + sig.values[0] + " - " + sig.values[1], {isBaseLayer: false, visibility: true});
    47           map.addLayer(signallayer);
    48         },
    49       });
    50 
    51       $("#end_date").datepicker({
    52         dateFormat: "dd/mm/yy",
    53       });
    54 
    55       $("#menu_filter").click(function(){
    56         $("#filter").slideToggle("fast");
    57         $("#info").slideUp("fast");
    58       });
    59       $("#menu_info").click(function(){
    60         $("#filter").slideUp("fast");
    61         $("#info").slideToggle("fast");
    62       });
    63     });
    64   </script>
    6513</head>
    6614<body onload="init()">
Note: See TracChangeset for help on using the changeset viewer.