Changeset 9216 for src/django_gheat
- Timestamp:
- May 26, 2011, 5:15:09 PM (13 years ago)
- Location:
- src/django_gheat/website
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/website/static/heatmap_extensions.js
r9214 r9216 1 // Base stolen from http://java.sun.com/developer/technicalArticles/J2EE/AJAX/RealtimeValidation/ 2 function AjaxRequest(url, callback) { 3 4 var req = init(); 5 req.onreadystatechange = processRequest; 6 7 function init() { 8 if (window.XMLHttpRequest) { 9 return new XMLHttpRequest(); 10 } else if (window.ActiveXObject) { 11 return new ActiveXObject("Microsoft.XMLHTTP"); 12 } 13 } 14 15 function processRequest () { 16 if (req.readyState == 4) { 17 if (req.status == 200) { 18 if (callback) callback(req.responseText); 19 } 20 } 21 } 22 23 this.doGet = function() { 24 req.open("GET", url, true); 25 req.send(null); 26 } 27 } 28 1 29 // Uses zoomlevel en mouseposition to call the nodelist.py view. View returns nodes in json format which is read and printed in document element. 2 function getNodeList(zoomlevel, mousepos){ 3 var nodelist; 30 function getNodeList(zoomlevel, mousepos) { 31 var url = "/website/nodelist/" + zoomlevel + "," + mousepos.lat + "," + mousepos.lon; 32 var ajax = new AjaxRequest(url, setNodeList); 33 ajax.doGet(); 34 } 4 35 5 if (window.XMLHttpRequest){ 6 nodelist=new XMLHttpRequest(); 36 37 function setNodeList(responseText) { 38 json=eval('(' + responseText + ')'); 39 var list = 'test'; 40 if (json.length>0){ 41 list = 'Wireless Leiden nodes on mouseposition:<br /><b>'; 42 for (var i=0; i<json.length; i++){ 43 list += json[i].fields.ssid + '<br />'; 44 } 45 list += '</b>'; 7 46 } 8 47 else{ 9 nodelist=new ActiveXObject("Microsoft.XMLHTTP");48 list = 'No nodes to display.'; 10 49 } 11 12 nodelist.onreadystatechange=function(){ 13 if (nodelist.readyState==4 && nodelist.status==200){ 14 json=eval('(' + nodelist.responseText + ')'); 15 var list; 16 if (json.length>0){ 17 list = 'Wireless Leiden nodes on mouseposition:<br /><b>'; 18 for (var i=0; i<json.length; i++){ 19 list += json[i].fields.ssid + '<br />'; 20 } 21 list += '</b>'; 22 } 23 else{ 24 list = 'No nodes to display.'; 25 } 26 document.getElementById('node_list').innerHTML=list; 27 } 28 } 29 nodelist.open("GET","/website/nodelist/" + zoomlevel + "," + mousepos.lat + "," + mousepos.lon,true); 30 nodelist.send(); 50 document.getElementById('node_list').innerHTML=list; 31 51 } 32 52 53 54 55 /* 56 57 The following code is old, broken and for reference purposes. Will be removed when new code is done. 58 The above (new) code was used instead to make everything more easy when adding new pieces. 33 59 34 60 // Get filter values from django view and serve as option list 35 61 function getFilters(){ 36 62 var filterlist; 63 var nodelist; 64 var userlist; 65 var datasetlist; 37 66 38 67 if (window.XMLHttpRequest){ 39 filterlist=new XMLHttpRequest(); 68 nodelist=new XMLHttpRequest(); 69 userlist=new XMLHttpRequest(); 70 datasetlist=new XMLHttpRequest(); 40 71 } 41 72 else{ 42 filterlist=new ActiveXObject("Microsoft.XMLHTTP"); 73 nodelist=new ActiveXObject("Microsoft.XMLHTTP"); 74 userlist=new ActiveXObject("Microsoft.XMLHTTP"); 75 datasetlist=new ActiveXObject("Microsoft.XMLHTTP"); 43 76 } 77 78 var list = '<form method="get" action="">'; 79 80 44 81 // todo: Get new options if one option is selected; every user has different datasets, make sure when user 'John' is selected, you can only choose datasets who are his. 45 filterlist.onreadystatechange=function(){ 46 if (filterlist.readyState==4 && filterlist.status==200){ 47 json=eval('(' + filterlist.responseText + ')'); 48 var list = '<form method="get" action="">'; 49 list += '<input type="text" id="user" name="user" size="10"/> User<br />'; 50 list += '<input type="text" id="dataset" name="dataset" size="10"/> Dataset<br />'; 51 list += '<input type="text" id="date" name="date" size="10"/> Date<br />'; 82 83 userlist.onreadystatechange=function(){ 84 if (userlist.readyState==4 && userlist.status==200){ 85 userlist=eval('(' + userlist.responseText + ')'); 52 86 87 list += '<select id="user" style="width:104px"><option></option>'; 88 for (var i=0; i<userlist.length; i++){ 89 list += '<option>' + userlist[i].fields.naam + '</option>'; 90 } 91 list += '</select> User<br />'; 92 93 document.getElementById('filter_list').innerHTML=list; 94 } 95 } 96 97 98 99 100 nodelist.onreadystatechange=function(){ 101 if (nodelist.readyState==4 && nodelist.status==200){ 102 nodelist=eval('(' + nodelist.responseText + ')'); 103 53 104 list += '<select id="wlnode" style="width:104px"><option></option>'; 54 for (var i=0; i< json.length; i++){55 list += '<option>' + json[i].fields.ssid + '</option>';105 for (var i=0; i<nodelist.length; i++){ 106 list += '<option>' + nodelist[i].fields.ssid + '</option>'; 56 107 } 57 108 list += '</select> WLnode<br />'; 58 109 59 list += '<input type="text" id="enc" name="enc" size="10"/> Encrypted<br />';60 list += '<input type="text" id="colour" name="colour" size="10"/> Colour<br />';61 list += '<input type="text" id="lname" name="lname" size="10"/> Layername<br />';62 list += '<input type="button" value="Add filter" onClick="addFilter()"/>';63 list += '</form>';64 110 document.getElementById('filter_list').innerHTML=list; 65 111 } 66 112 } 67 filterlist.open("GET","/website/filters",true); 68 filterlist.send(); 113 114 115 datasetlist.onreadystatechange=function(){ 116 if (datasetlist.readyState==4 && datasetlist.status==200){ 117 datasetlist=eval('(' + datasetlist.responseText + ')'); 118 119 list += '<select id="dataset" style="width:104px"><option></option>'; 120 for (var i=0; i<datasetlist.length; i++){ 121 list += '<option>' + datasetlist[i].fields.naam + '</option>'; 122 } 123 list += '</select> Dataset<br />'; 124 125 document.getElementById('filter_list').innerHTML=list; 126 } 127 } 128 129 130 list += '<input type="text" id="enc" name="enc" size="10"/> Encrypted<br />'; 131 list += '<input type="text" id="colour" name="colour" size="10"/> Colour<br />'; 132 list += '<input type="text" id="lname" name="lname" size="10"/> Layername<br />'; 133 list += '<input type="button" value="Add filter" onClick="addFilter()"/>'; 134 list += '</form>'; 135 136 137 138 139 140 nodelist.open("GET","/website/filters/1",true); 141 nodelist.send(); 142 userlist.open("GET","/website/filters/2",true); 143 userlist.send(); 144 datasetlist.open("GET","/website/filters/3",true); 145 datasetlist.send(); 69 146 } 70 147 … … 108 185 map.addLayer(filterlayer); 109 186 } 187 */ -
src/django_gheat/website/templates/home.html
r9214 r9216 29 29 30 30 31 <body onload="init() ,getFilters()">31 <body onload="init()"> 32 32 <div id="heatmap"></div> 33 33 <div id="container">
Note:
See TracChangeset
for help on using the changeset viewer.