Changeset 9781


Ignore:
Timestamp:
Dec 14, 2011, 9:16:40 PM (13 years ago)
Author:
rick
Message:

Allow specifing custom filters from the CLI

File:
1 edited

Legend:

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

    r9779 r9781  
    408408   * Blank parameters are ignored.
    409409   */
    410   $('#add_filter').click(function(){
    411     // get values from elements
    412 
    413     lname = $("#lname").val();
    414     if (lname == ''){
    415       lname= 'Custom Filter';
    416     }
    417 
     410  function add_filter(lname, filter) {
    418411    // setting layer
    419412    OpenLayers.Layer.OSM.Overlay = OpenLayers.Class(OpenLayers.Layer.OSM, {
    420413      initialize: function(name, options) {
    421414        var url = [
    422           "tile/${z}/${x},${y}.png?" + $("#raw_filter").val(),
     415          "tile/${z}/${x},${y}.png?" + filter,
    423416        ];
    424417        options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
     
    435428
    436429    $("#custom").append("<span id=\"" + lname + "\"><div id='layer_switcher_colour' style='background-color:rgb(" + colour + ")' /><input type=checkbox id=togglelayer checked /><font>" + lname + " </font><a id=rmvlayer>X</a><br /></span>");
     430  }
     431
     432  $('#add_filter').click(function(){
     433    lname = $("#lname").val();
     434    if (lname == ''){
     435      lname= 'Custom Filter';
     436    }
     437    add_filter(lname, $("#raw_filter").val());
     438
    437439  });
    438440  init_heatmap();
    439441  init_slider(35,75);
     442
     443  // Initiate the custom filters
     444  var items = window.location.hash.split('#').slice(1);
     445  for (var i=0; i < items.length; i++) {
     446    var y = items[i].split('!');
     447    var label = y[0];
     448    var url = y[1];
     449    add_filter(label, url);
     450  }
    440451});
Note: See TracChangeset for help on using the changeset viewer.