Changeset 9231 for src/django_gheat/website/static
- Timestamp:
- Jun 6, 2011, 6:51:42 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/website/static/heatmap_extensions_test.js
r9229 r9231 56 56 57 57 function get_filters() { 58 59 58 // Create form 60 59 var formstart = '<form method="get" action="">'; … … 62 61 var layername = '<input type="text" id="lname" name="lname" size="10"/> Layername<br />'; 63 62 var colour = '<input type="text" id="colour" name="colour" size="10"/> Colour<br />'; 64 var user = '<select id="user" style="width:104px" onchange= update_filters(this.id)><option></option></select> User<br />';65 var dataset = '<select id="dataset" style="width:104px" onchange= update_filters(this.id)><option></option></select> Dataset<br />';66 var node = '<select id="node" style="width:104px" onchange=update_filters(this.id)>< option></option></select> Node<br />';67 var enc = '<select id="enc" style="width:104px">< option></option></select> Encryption<br />';68 var date = '<select id="date" style="width:104px" onchange= update_filters(this.id)><option></option></select> Date<br />';63 var user = '<select id="user" style="width:104px" onchange=filter_user()></select> User<br />'; 64 var dataset = '<select id="dataset" style="width:104px" onchange=filter_node()></select> Dataset<br />'; 65 var node = '<select id="node" style="width:104px" onchange=update_filters(this.id)></select> Node<br />'; 66 var enc = '<select id="enc" style="width:104px"></select> Encryption<br />'; 67 var date = '<select id="date" style="width:104px" onchange=filter_date()></select> Date<br />'; 69 68 70 69 // Write form to document … … 77 76 } 78 77 78 79 79 80 function set_filters(responseText) { 81 // set global var json with responText 80 82 json=eval('(' + responseText + ')'); 81 var user = '<option value="empty"></option>'; 82 var dataset = '<option value="empty"></option>'; 83 var date = '<option value="empty"></option>'; 83 84 // set initial options 85 var date = '<option>Select date</option><option>All</option>'; 86 87 // set initial options 84 88 for (var i=0; i<json.length; i++){ 85 user += '<option value="user">' + json[i].gebruiker + '</option>';86 89 for (m in json[i].meetrondje){ 87 dataset += '<option value="dataset">' + json[i].meetrondje[m].naam + '</option>';88 90 date += '<option value="date">' + json[i].meetrondje[m].datum + '</option>'; 89 91 } 90 92 } 93 94 // write options 95 document.getElementById('date').innerHTML=date; 96 document.getElementById('user').disabled=true; 97 document.getElementById('dataset').disabled=true; 98 document.getElementById('node').disabled=true; 99 100 // call filter_date once to set users 101 filter_date(); 102 } 103 104 // get date value and set options for next filter (user) 105 function filter_date(){ 106 var user = '<option>Select user</option><option>All</option>'; 107 var date = $('#date option:selected').text(); 108 109 // date is none 110 if(date=='Select date'){ 111 document.getElementById('user').innerHTML=''; 112 document.getElementById('user').disabled=true; 113 } 114 // date is all 115 else if(date=='All'){ 116 for (var i=0; i<json.length; i++){ 117 user += '<option>' + json[i].gebruiker + '</option>'; 118 } 91 119 document.getElementById('user').innerHTML=user; 92 document.getElementById('dataset').innerHTML=dataset; 93 document.getElementById('date').innerHTML=date; 94 } 95 96 97 98 99 function update_filters(filter_id){ 100 var user_text = $('#user option:selected').text(); 101 var user_val = $('#user option:selected').val(); 102 var dataset_text = $('#dataset option:selected').text(); 103 var user = '<option value="empty"></option>'; 104 var dataset = '<option value="empty"></option>'; 105 106 if (filter_id=='user'){ 107 if (!user_text){ 120 document.getElementById('user').disabled=false; 121 } 122 // date not all 123 else{ 124 for (var i=0; i<json.length; i++){ 125 for (m in json[i].meetrondje){ 126 if (json[i].meetrondje[m].datum == date){ 127 user += '<option>' + json[i].gebruiker + '</option>'; 128 } 129 } 130 } 131 document.getElementById('user').innerHTML=user; 132 document.getElementById('user').disabled=false; 133 } 134 } 135 136 137 // get user value and set options for next filter (dataset) 138 function filter_user(){ 139 var dataset = '<option>Select dataset</option><option>All</option>'; 140 var date = $('#date option:selected').text(); 141 var user = $('#user option:selected').text(); 142 143 // user is none 144 if(user=='Select user'){ 145 document.getElementById('dateset').innerHTML=''; 146 document.getElementById('dataset').disabled=true; 147 } 148 // user is all 149 else if(user=='All'){ 150 if(date=='All'){ 108 151 for (var i=0; i<json.length; i++){ 109 152 for (m in json[i].meetrondje){ 110 dataset += '<option value="dataset">' + json[i].meetrondje[m].naam + '</option>';153 dataset += '<option>' + json[i].meetrondje[m].naam + '</option>'; 111 154 } 112 155 } … … 115 158 for (var i=0; i<json.length; i++){ 116 159 for (m in json[i].meetrondje){ 117 if (json[i].gebruiker == user_text){ 118 dataset += '<option value="dataset">' + json[i].meetrondje[m].naam + '</option>'; 119 } 160 dataset += '<option>' + json[i].meetrondje[m].naam + '</option>'; 120 161 } 121 162 } 122 163 } 123 164 document.getElementById('dataset').innerHTML=dataset; 124 } 125 } 126 127 128 165 document.getElementById('dataset').disabled=false; 166 } 167 // user not all 168 else{ 169 for (var i=0; i<json.length; i++){ 170 if (json[i].gebruiker == user){ 171 for (m in json[i].meetrondje){ 172 dataset += '<option>' + json[i].meetrondje[m].naam + '</option>'; 173 } 174 } 175 } 176 document.getElementById('dataset').innerHTML=dataset; 177 document.getElementById('dataset').disabled=false; 178 } 179 } 129 180 130 181 … … 139 190 var lname = encodeURIComponent(document.getElementById("lname").value); 140 191 141 if (user != ''){user='&meetrondje__gebruiker__naam='+user;} 142 if (dataset != ''){dataset='&meetrondje__naam='+dataset;} 143 if (wlnode != ''){wlnode='&accespoint__ssid='+wlnode;} 192 if ((user != 'Select user') && (user != 'All')){user='&meetrondje__gebruiker__naam='+user;} 193 else{user='';} 194 if ((dataset != 'Select dataset') && (dataset != 'All')){dataset='&meetrondje__naam='+dataset;} 195 else{dataset='';} 196 if ((wlnode != 'Select node') && (dataset != 'All')){wlnode='&accespoint__ssid='+wlnode;} 197 else{wlnode='';} 144 198 if (enc != ''){enc='&accespoint__encryptie='+enc;} 145 if (date != ''){date='&meetrondje__datum='+date;} 199 if ((date != 'Select date') && (date != 'All')){date='&meetrondje__datum='+date;} 200 else{date='';} 146 201 if (colour != ''){colour='colour='+colour;} 147 202 else {colour = '&colour='+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256);} … … 156 211 baseurl + colour + user + dataset + wlnode + enc + date 157 212 ]; 213 document.getElementById('filter_text').innerHTML+="<br />Added: " + url; 158 214 options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options); 159 215 var newArguments = [name, url, options];
Note:
See TracChangeset
for help on using the changeset viewer.