| 1 | // 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 | $.getJSON("/website/nodelist/" + zoomlevel + "," + mousepos.lat + "," + mousepos.lon,
|
|---|
| 4 | function(json) {
|
|---|
| 5 | content = 'Wireless Leiden nodes on mouseposition:<br /><b>';
|
|---|
| 6 | $.each(json, function(i,json){
|
|---|
| 7 | content += json.fields.ssid;
|
|---|
| 8 | });
|
|---|
| 9 | content += '</br>';
|
|---|
| 10 | $("#node_list").html(content);
|
|---|
| 11 | }
|
|---|
| 12 | );
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | // set filter values
|
|---|
| 16 | $(document).ready(function() {
|
|---|
| 17 |
|
|---|
| 18 | // Fastest?: http://stackoverflow.com/questions/170986/what-is-the-best-way-to-add-options-to-a-select-from-an-array-with-jquery
|
|---|
| 19 | $.getJSON("/website/foofilter/",
|
|---|
| 20 | function(json) {
|
|---|
| 21 | $.each(json, function(i,json){
|
|---|
| 22 | // $("<option value='" + json.gebruiker + "'>" + json.gebruiker + "</option>").appendTo("#select_user");
|
|---|
| 23 | $("#select_user").append($("<option/>").attr("value",json.gebruiker).text(json.gebruiker));
|
|---|
| 24 | $.each(json.meetrondje, function(m, meetrondje){
|
|---|
| 25 | $("<option class='" + json.gebruiker + "' value='" + meetrondje.naam + "'>"+ meetrondje.naam + "</option>").appendTo("#select_dataset");
|
|---|
| 26 | $.each(meetrondje.nodes, function(n, nodes){
|
|---|
| 27 | $("<option class='" + meetrondje.naam + "' value='" + nodes + "'>" + nodes + "</option>").appendTo("#select_node");
|
|---|
| 28 | });
|
|---|
| 29 | // $("<option>" + meetrondje.datum + "</option>").appendTo("#select_date");
|
|---|
| 30 | });
|
|---|
| 31 | });
|
|---|
| 32 | // Initiate the chain
|
|---|
| 33 | $("#select_dataset").chained("#select_user");
|
|---|
| 34 | $("#select_node").chained("#select_dataset");
|
|---|
| 35 | }
|
|---|
| 36 | );
|
|---|
| 37 | });
|
|---|
| 38 |
|
|---|
| 39 | // add filter
|
|---|
| 40 | $(function(){
|
|---|
| 41 | $('#add_filter').click(function(){
|
|---|
| 42 |
|
|---|
| 43 | user = $('#select_user option:selected').text();
|
|---|
| 44 | dataset = $('#select_dataset option:selected').text();
|
|---|
| 45 | wlnode = $('#select_node option:selected').text();
|
|---|
| 46 | enc = $('#select_enc option:selected').text();
|
|---|
| 47 | date = $('#select_date option:selected').text();
|
|---|
| 48 | colour = encodeURIComponent(document.getElementById("colour").value);
|
|---|
| 49 | lname = encodeURIComponent(document.getElementById("lname").value);
|
|---|
| 50 |
|
|---|
| 51 | if (user != ''){user='&meetrondje__gebruiker__naam='+user;}
|
|---|
| 52 | else{user='';}
|
|---|
| 53 | if (dataset != ''){dataset='&meetrondje__naam='+dataset;}
|
|---|
| 54 | else{dataset='';}
|
|---|
| 55 | if (wlnode != ''){wlnode='&accespoint__ssid='+wlnode;}
|
|---|
| 56 | else{wlnode='';}
|
|---|
| 57 | if (enc != ''){enc='&accespoint__encryptie='+enc;}
|
|---|
| 58 | if (date != ''){date='&meetrondje__datum='+date;}
|
|---|
| 59 | else{date='';}
|
|---|
| 60 | if (colour != ''){colour='colour='+colour;}
|
|---|
| 61 | else {colour = '&colour='+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256);}
|
|---|
| 62 | if (lname != ''){lname=lname;}
|
|---|
| 63 | else {lname = 'Custom Filter';}
|
|---|
| 64 |
|
|---|
| 65 | var baseurl = "/website/tile/${z}/${x},${y}.png?";
|
|---|
| 66 |
|
|---|
| 67 | OpenLayers.Layer.OSM.Overlay = OpenLayers.Class(OpenLayers.Layer.OSM, {
|
|---|
| 68 | initialize: function(name, options) {
|
|---|
| 69 | var url = [
|
|---|
| 70 | baseurl + colour + user + dataset + wlnode + enc + date
|
|---|
| 71 | ];
|
|---|
| 72 | document.getElementById('filter_text').innerHTML+="<br />Added: " + url;
|
|---|
| 73 | options = OpenLayers.Util.extend({ numZoomLevels: 21 }, options);
|
|---|
| 74 | var newArguments = [name, url, options];
|
|---|
| 75 | OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
|
|---|
| 76 | },
|
|---|
| 77 | CLASS_NAME: "OpenLayers.Layer.Overlay"
|
|---|
| 78 | });
|
|---|
| 79 |
|
|---|
| 80 | filterlayer = new OpenLayers.Layer.OSM.Overlay(lname, {isBaseLayer: false, visibility: true});
|
|---|
| 81 | map.addLayer(filterlayer);
|
|---|
| 82 | });
|
|---|
| 83 | });
|
|---|