Changeset 9232 for src/django_gheat/website
- Timestamp:
- Jun 6, 2011, 7:01:29 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/website/static/heatmap_extensions_test.js
r9231 r9232 77 77 78 78 79 80 79 function set_filters(responseText) { 81 // set global var json with responText82 80 json=eval('(' + responseText + ')'); 83 84 // set initial options81 var user = '<option>Select user</option><option>All</option>'; 82 var dataset = '<option>Select dataset</option><option>All</option>'; 85 83 var date = '<option>Select date</option><option>All</option>'; 86 87 // set initial options 84 var node = '<option>Select node</option><option>All</option>'; 88 85 for (var i=0; i<json.length; i++){ 86 user += '<option>' + json[i].gebruiker + '</option>'; 89 87 for (m in json[i].meetrondje){ 90 date += '<option value="date">' + json[i].meetrondje[m].datum + '</option>'; 88 dataset += '<option>' + json[i].meetrondje[m].naam + '</option>'; 89 date += '<option>' + json[i].meetrondje[m].datum + '</option>'; 90 for (n in json[i].meetrondje[m].nodes){ 91 node += '<option>' + json[i].meetrondje[m].nodes[n] + '</option>'; 92 } 91 93 } 92 94 } 93 94 // write options95 document.getElementById('user').innerHTML=user; 96 document.getElementById('dataset').innerHTML=dataset; 95 97 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 } 119 document.getElementById('user').innerHTML=user; 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'){ 151 for (var i=0; i<json.length; i++){ 152 for (m in json[i].meetrondje){ 153 dataset += '<option>' + json[i].meetrondje[m].naam + '</option>'; 154 } 155 } 156 } 157 else{ 158 for (var i=0; i<json.length; i++){ 159 for (m in json[i].meetrondje){ 160 dataset += '<option>' + json[i].meetrondje[m].naam + '</option>'; 161 } 162 } 163 } 164 document.getElementById('dataset').innerHTML=dataset; 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 } 98 document.getElementById('node').innerHTML=node; 179 99 } 180 100
Note:
See TracChangeset
for help on using the changeset viewer.