Changeset 9218 for src/django_gheat/website
- Timestamp:
- May 27, 2011, 4:16:09 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/website/static/heatmap_extensions.js
r9217 r9218 1 1 // Base stolen from http://java.sun.com/developer/technicalArticles/J2EE/AJAX/RealtimeValidation/ 2 function AjaxRequest(url, callback ) {2 function AjaxRequest(url, callback, filter) { 3 3 4 4 var req = init(); … … 16 16 if (req.readyState == 4) { 17 17 if (req.status == 200) { 18 if (callback) callback(req.responseText); 18 if (callback) { 19 if (filter) callback(filter, req.responseText); 20 else callback(req.responseText); 21 } 19 22 } 20 23 } … … 26 29 } 27 30 } 31 28 32 29 33 // Uses zoomlevel en mouseposition to call the nodelist.py view. View returns nodes in json format which is read and printed in document element. … … 51 55 52 56 53 function filter_node() { 54 var url = "/website/filter/filter_node"; 55 var ajax = new AjaxRequest(url, set_filter_node); 57 function get_filters() { 58 var formstart = '<form method="get" action="">'; 59 var formend = '<input type="button" value="Add filter" onClick="addFilter()"/></form>'; 60 61 document.getElementById('filter_list').innerHTML+=formstart; 62 63 var filters = new Array('user', 'dataset'); 64 for (var i=0; i<filters.length; i++) { 65 get_json(filters[i]); 66 } 67 68 // todo: Fix formend, it is called before the 'for' filter is completed, making the form look silly. 69 document.getElementById('filter_list').innerHTML+=formend; 70 } 71 72 73 function get_json(filter) { 74 var url = "/website/filter/filter_" + filter; 75 var ajax = new AjaxRequest(url, set_filter, filter); 56 76 ajax.doGet(); 57 77 } 58 78 59 79 60 function set_filter _node(responseText) {80 function set_filter(filter, responseText) { 61 81 json=eval('(' + responseText + ')'); 62 list = '<form method="get" action=""><select id="wlnode"style="width:104px"><option></option>';82 var options = '<select id=' + filter + ' style="width:104px"><option></option>'; 63 83 for (var i=0; i<json.length; i++){ 64 list += '<option>' + json[i].fields.ssid+ '</option>';65 } 66 list += '</select> WLnode<br /><input type="button" value="Add filter" onClick="addFilter()"/></form>';67 document.getElementById('filter_list').innerHTML =list;84 options += '<option>' + json[i].fields.naam + '</option>'; 85 } 86 options += '</select> ' + filter + '<br />'; 87 document.getElementById('filter_list').innerHTML+=options; 68 88 } 69 89 … … 71 91 function addFilter(){ 72 92 73 var user = '';93 var user = encodeURIComponent(document.getElementById("user").value); 74 94 var dataset = ''; 75 var wlnode = encodeURIComponent(document.getElementById("wlnode").value);95 var wlnode = ''; 76 96 var enc =''; 77 97 var date = ''; … … 79 99 var lname = ''; 80 100 81 if (user != ''){user='& accespoint__id='+user;}101 if (user != ''){user='&gebruiker__naam='+user;} 82 102 if (dataset != ''){dataset='&meetrondje__naam='+dataset;} 83 103 if (wlnode != ''){wlnode='&accespoint__ssid='+wlnode;}
Note:
See TracChangeset
for help on using the changeset viewer.