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