Changeset 9225 for src


Ignore:
Timestamp:
May 31, 2011, 2:23:09 PM (13 years ago)
Author:
dennisw
Message:

It seems Rick's foo_filter is exactly what I needed. Added date to it.

Got User & Dataset chained with this, going for date now.

Location:
src/django_gheat/website
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/django_gheat/website/filters.py

    r9224 r9225  
    11#!/usr/bin/env python
    22#
    3 # View serving available WirelessLeiden Nodes in list on mouseover.
     3# View serving filter values.
    44#
    55# Dennis Wagenaar
     
    7373        {
    7474          'naam' : mr.naam,
     75          'date' : mr.datum.strftime('%Y-%m-%d'),
    7576          'nodes' : list(wirelessleiden_ssid)
    7677        }
  • src/django_gheat/website/static/heatmap_extensions_test.js

    r9223 r9225  
    11// Base stolen from http://java.sun.com/developer/technicalArticles/J2EE/AJAX/RealtimeValidation/
    2 var json_dataset;
     2var json;
    33function AjaxRequest(url, callback, filter, field) {
    44
     
    4141
    4242function setNodeList(responseText) {
    43   json=eval('(' + responseText + ')');
    44   if (json.length>0){
     43  json_nodelist=eval('(' + responseText + ')');
     44  if (json_nodelist.length>0){
    4545    list = 'Wireless Leiden nodes on mouseposition:<br /><b>';
    46     for (var i=0; i<json.length; i++){
    47       list += json[i].fields.ssid + '<br />';
     46    for (var i=0; i<json_nodelist.length; i++){
     47      list += json_nodelist[i].fields.ssid + '<br />';
    4848    }
    4949    list += '</b>';
     
    6363  var layername = '<input type="text" id="lname" name="lname" size="10"/> Layername<br />';
    6464  var colour = '<input type="text" id="colour" name="colour" size="10"/> Colour<br />';
    65   var user = '<select id="user" style="width:104px" onchange="update_dataset()"><option></option></select> User<br />';
     65  var user = '<select id="user" style="width:104px" onchange=update_dataset()><option></option></select> User<br />';
    6666  var dataset = '<select id="dataset" style="width:104px"><option></option></select> Dataset<br />';
    6767  var node = '<select id="node" style="width:104px"><option></option></select> Node<br />';
     
    7272  document.getElementById('filter_list').innerHTML+=(formstart + user + dataset + node + enc + date + colour + layername + formend);
    7373 
    74   // Get values for select boxes
    75   // filters[] first value is what to get, second value is which field values will be shown in select box
    76   get_user();
    77   get_dataset();
    78 }
    79 
    80 
    81 function get_user() {
    82   var url = "/website/filter/filter_user";
     74  // Request JSON with filter values
     75  var url = "/website/foofilter";
    8376  var ajax = new AjaxRequest(url, set_user);
    8477  ajax.doGet();
    8578}
    8679
    87 function get_dataset() {
    88   var url = "/website/filter/filter_dataset";
    89   var ajax = new AjaxRequest(url, update_dataset);
    90   ajax.doGet();
     80function set_user(responseText) {
     81  json=eval('(' + responseText + ')');
     82  var options = '<option value="All">All</option>';
     83  for (var i=0; i<json.length; i++){
     84    options += '<option>' + json[i].gebruiker + '</option>';
     85  }
     86  document.getElementById('user').innerHTML=options;
     87
     88  update_dataset();
    9189}
    9290
    9391
     92function update_dataset(){
     93  var options = '';
     94  var user_value = $('#user option:selected').text();
    9495
    95 function set_user(responseText) {
    96   json_user=eval('(' + responseText + ')');
    97   var options = '<option value="All">All</option>';
    98   for (var i=0; i<json_user.length; i++){
    99     options += '<option value="' + json_user[i].pk + '">' + json_user[i].fields.naam + '</option>';
    100   }
    101   document.getElementById('user').innerHTML=options;
    102 }
    103 
    104 
    105 function update_dataset(responseText){
    106   if (!json_dataset){
    107     json_dataset=eval('(' + responseText + ')');
    108   }
    109   else{
    110   }
    111   var options = '';
    112 
    113   var e = document.getElementById('user');
    114   var user_value = e.options[e.selectedIndex].value;
    115 
    116   for (var i=0; i<json_dataset.length; i++){
    117     if (user_value != 'All'){
    118       if (json_dataset[i].fields.gebruiker == user_value){
    119         options += '<option value="' + json_dataset[i].fields.gebruiker + '">' + json_dataset[i].fields.naam + '</option>';
     96  for (var i=0; i<json.length; i++){
     97    for (m in json[i].meetrondje){
     98      if (user_value != 'All'){
     99        if (json[i].gebruiker == user_value){
     100          options += '<option>' + json[i].meetrondje[m].naam + '</option>';
     101        }
     102        else{
     103          continue;
     104        }
    120105      }
    121106      else{
    122         continue;
     107        options += '<option>' + json[i].meetrondje[m].naam + '</option>';
    123108      }
    124     }
    125     else{
    126       options += '<option value="' + json_dataset[i].fields.gebruiker + '">' + json_dataset[i].fields.naam + '</option>';
    127109    }
    128110  }
     
    143125  var user = $('#user option:selected').text();
    144126  var dataset = $('#dataset option:selected').text();
    145   var wlnode = encodeURIComponent(document.getElementById("node").value);
    146   var enc = encodeURIComponent(document.getElementById("enc").value);
    147   var date = encodeURIComponent(document.getElementById("date").value);
     127  var wlnode = $('#wlnode option:selected').text();
     128  var enc = $('#enc option:selected').text();
     129  var date = $('#date option:selected').text();
    148130  var colour = encodeURIComponent(document.getElementById("colour").value);
    149131  var lname = encodeURIComponent(document.getElementById("lname").value);
Note: See TracChangeset for help on using the changeset viewer.