Ignore:
Timestamp:
Jun 27, 2011, 4:00:01 PM (13 years ago)
Author:
dennisw
Message:

Added/changed/clarified some comments in code.

File:
1 edited

Legend:

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

    r9297 r9302  
    1 // Uses zoomlevel and mouseposition to call the nodelist.py view. View returns nodes in json format which is read and printed in document element.
     1/**
     2 * Uses zoomleven and mouseposition to call nodelist.py view.
     3 * View returns nodes in json format, values are printed in doc element.
     4 */
    25function getNodeList(zoomlevel, mousepos){
    36  $.getJSON("/website/nodelist/" + zoomlevel + "," + mousepos.lat + "," + mousepos.lon,
     
    1316}
    1417
    15 // Right way to get url parameters?: http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery/1404100#1404100
     18/**
     19 * Right way to get url parameters?
     20 * http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery/1404100#1404100
     21 */
    1622function getURLParameter(name) {
    1723  return decodeURI(
     
    2531  var nodelist = new Array();
    2632
    27   // add colour picker
     33  /**
     34   * Adds colourpicker for layer colour.
     35   * Function set in: 'colourpicker.js'
     36   */
    2837  $("#colour").colorPicker();
    2938
    30   // add date picker for start date
     39  /**
     40   * Adds datepicker for start & end date
     41   * Function set in: 'jquery-ui-1.8.13.custom.min.js'
     42   */
    3143  $("#start_date").datepicker({
    3244    dateFormat: "dd/mm/yy",
     
    3547    }
    3648  });
    37 
    38   // add date picker for end date
    3949  $("#end_date").datepicker({
    4050    dateFormat: "dd/mm/yy",
    4151  });
    4252
    43   // add slider for signal strength filter
     53  /**
     54   * Adds slider for signal strength layer.
     55   * Function set in: 'jquery-ui-1.8.13.custom.min.js'
     56   */
    4457  $("#slider").slider({
    4558    range: true,
     
    6174  });
    6275
    63   // toggle layer visibility
     76  /**
     77   * Toggles layer visibility on checkbox use from layerswitcher.
     78   */
    6479  $("#togglelayer").live('click', function(){
    6580    status = $(this).attr("checked");
     
    6984  });
    7085
    71   // toggle layer visibility per category
     86  /**
     87   * Toggles layer visibility per category on checkbox use from layerswitcher.
     88   */
    7289  $("#togglecat").live("click", function(){
    7390    if($(this).attr("checked")){
     
    87104  });
    88105
    89   // remove layer
     106  /**
     107   * Removes layer from map and layerswitcher.
     108   */
    90109  $("#rmvlayer").live("click", function(){
    91110    layername = $(this).closest('span').attr('id');
     
    95114  });
    96115
    97   // menu toggle
     116  /**
     117   * Toggles text shown on website.
     118   * 'info' shows info text.
     119   * 'filter' page shows text on filters & filter options.
     120   */
    98121  $("#menu_filter").click(function(){
    99122    $("#filter").slideToggle("fast");
     
    105128  });
    106129
    107   // switcher toggle
     130  /**
     131   * Toggles layerswitcher visibility.
     132   * On 'off', toggler shows a '+'.
     133   * On 'on', toggler shows a '-'.
     134   */
    108135  $("#layer_switcher_toggle").click(function(){
    109136    $("#layer_switcher").toggle();
     
    116143  });
    117144
    118   // Fastest?: http://stackoverflow.com/questions/170986/what-is-the-best-way-to-add-options-to-a-select-from-an-array-with-jquery
     145  /**
     146   * Fastest?
     147   * http://stackoverflow.com/questions/170986/what-is-the-best-way-to-add-options-to-a-select-from-an-array-with-jquery
     148   */
    119149  $.getJSON("/website/filters/",
    120150    function(json) {
     
    123153        userlist.push(json.gebruiker);
    124154        $.each(json.meetrondje, function(m, meetrondje){
     155          console.log(meetrondje.datum);
    125156          $("#select_dataset").append($("<option/>").attr({"class":json.gebruiker, "value":meetrondje.naam}).text(meetrondje.naam));
    126157          $.each(meetrondje.nodes, function(n, nodes){
     
    138169  );
    139170
    140   // add filter per user
     171  /**
     172   * Earlier process got all users in JSON and put them in array.
     173   * For each user in array, new layer is added with username as parameter.
     174   * Layercolour is randomized.
     175   * If button is pressed again, layers will be deleted.
     176   */
    141177  $('#user_filter').click(function(){
    142178    if(this.text=='(Add all users)'){
     
    169205  });
    170206
    171   // add filter per node
     207  /**
     208   * Earlier process got all nodes in JSON and put them in array.
     209   * For each node in array, new layer is added with node as parameter.
     210   * Layercolour is randomized.
     211   * If button is pressed again, layers will be deleted.
     212   */
    172213  $('#node_filter').click(function(){
    173214    if(this.text=='(Add all nodes)'){
     
    201242  });
    202243
    203   // add custom filter
     244  /**
     245   * Adds a new layer when clicked.
     246   * Filters set by user are used as layer parameters.
     247   * Colour is either chosen or randomized.
     248   * Blank parameters are ignored.
     249   */
    204250  $('#add_filter').click(function(){
    205     //get values from elements
     251    // get values from elements
    206252    user = $('#select_user option:selected').text();
    207253    dataset = $('#select_dataset option:selected').text();
     
    212258    lname = encodeURIComponent(document.getElementById("lname").value);
    213259
    214     // HEX to RGB: http://stackoverflow.com/questions/5798868/need-some-tips-with-how-to-convert-a-hexadecimal-color-value-to-a-rgb-one/5798900#5798900
    215     // '#' comes out as '%23', so substr() starts at char 3
     260    /**
     261     * On HEX to RGB:
     262     * http://stackoverflow.com/questions/5798868/need-some-tips-with-how-to-convert-a-hexadecimal-color-value-to-a-rgb-one/5798900#5798900
     263     * Note that '#' comes out as '%23', so substr() starts at char 3
     264     */
    216265    colour = parseInt((colour.substr(3, 2)),16) + ',' + parseInt((colour.substr(5, 2)),16) + ',' + parseInt((colour.substr(7, 2)),16);
    217266
Note: See TracChangeset for help on using the changeset viewer.