diff options
Diffstat (limited to 'car2go-ptv')
-rw-r--r-- | car2go-ptv/README | 1 | ||||
-rw-r--r-- | car2go-ptv/bookmarklet.html | 2 | ||||
-rw-r--r-- | car2go-ptv/ptv.js | 27 |
3 files changed, 29 insertions, 1 deletions
diff --git a/car2go-ptv/README b/car2go-ptv/README deleted file mode 100644 index e965047..0000000 --- a/car2go-ptv/README +++ /dev/null @@ -1 +0,0 @@ -Hello diff --git a/car2go-ptv/bookmarklet.html b/car2go-ptv/bookmarklet.html new file mode 100644 index 0000000..708e9dd --- /dev/null +++ b/car2go-ptv/bookmarklet.html @@ -0,0 +1,2 @@ +Add this Link to your bookmarks: +<a href="javascript:(function(){var%20btnFilter=document.createElement(%22button%22);btnFilter.innerHTML=%22Nur%20%3C%2025%25%20anzeigen%22;btnFilter.onclick=function(){ptvMap.clearVectorLayer();var%20d=[];for(var%20c%20in%20ptvMap.data.vehicles){var%20a=ptvMap.data.vehicles[c];if(typeof(a.tooltip)===%22undefined%22){continue}var%20b=a.tooltip.data[3].value.match(/\d+/)[0];if(parseInt(b)%3C25){d.push(a)}}ptvMap.addVehicles(d)};document.getElementById(%22content%22).appendChild(btnFilter);var%20btnUnfilter=document.createElement(%22button%22);btnUnfilter.innerHTML=%22Alle%20Anzeigen%22;btnUnfilter.onclick=function(){ptvMap.clearVectorLayer();ptvMap.addVehicles(ptvMap.data.vehicles)};document.getElementById(%22content%22).appendChild(btnUnfilter);})();">Car2Go Tankfüllungsfilter</a> diff --git a/car2go-ptv/ptv.js b/car2go-ptv/ptv.js new file mode 100644 index 0000000..3b08523 --- /dev/null +++ b/car2go-ptv/ptv.js @@ -0,0 +1,27 @@ +var btnFilter = document.createElement("button"); +btnFilter.innerHTML = "Nur < 25% anzeigen"; +btnFilter.onclick = function() { + ptvMap.clearVectorLayer(); + var selectedVehicles = []; + + for (var i in ptvMap.data.vehicles) { + var v = ptvMap.data.vehicles[i]; + if (typeof(v.tooltip) === "undefined") + continue; + var tank = v.tooltip.data[3].value.match(/\d+/)[0]; + if (parseInt(tank) < 25) { + selectedVehicles.push(v); + } + } + ptvMap.addVehicles(selectedVehicles); +} +document.getElementById("content").appendChild(btnFilter); + +var btnUnfilter = document.createElement("button"); +btnUnfilter.innerHTML = "Alle Anzeigen"; +btnUnfilter.onclick = function() { + ptvMap.clearVectorLayer(); + ptvMap.addVehicles(ptvMap.data.vehicles); +} +document.getElementById("content").appendChild(btnUnfilter); + |