Merge pull request #3 from drakeapps/map_enhancements

Add ability to select/deselect all planes
This commit is contained in:
Carlos Salaverria 2016-08-19 17:01:14 -05:00 committed by GitHub
commit 876e6874b4
2 changed files with 87 additions and 13 deletions

View file

@ -60,6 +60,12 @@
<span id="reset_map_button" class="pointer" onclick="resetMap();">[ Reset Map ]</span> <span id="reset_map_button" class="pointer" onclick="resetMap();">[ Reset Map ]</span>
<span id="show_map_button" class="pointer" onclick="showMap();">[ Show Map ]</span> <span id="show_map_button" class="pointer" onclick="showMap();">[ Show Map ]</span>
</td> </td>
<td style="width: 150px; text-align: center;" class="pointer">
[ <span onclick="selectAllPlanes();">Select All</span> ]
</td>
<td style="width: 150px; text-align: center;" class="pointer">
[ <span onclick="deselectAllPlanes();">Select None</span> ]
</td>
</tr> </tr>
</table> </table>
</div> <!-- sudo_buttons --> </div> <!-- sudo_buttons -->

View file

@ -9,6 +9,7 @@ var PlaneTrailFeatures = new ol.Collection();
var Planes = {}; var Planes = {};
var PlanesOrdered = []; var PlanesOrdered = [];
var SelectedPlane = null; var SelectedPlane = null;
var SelectedAllPlanes = false;
var FollowSelected = false; var FollowSelected = false;
var SpecialSquawks = { var SpecialSquawks = {
@ -129,6 +130,7 @@ function fetchData() {
plane.updateTick(now, LastReceiverTimestamp); plane.updateTick(now, LastReceiverTimestamp);
} }
selectNewPlanes();
refreshTableInfo(); refreshTableInfo();
refreshSelected(); refreshSelected();
@ -896,6 +898,11 @@ function sortBy(id,sc,se) {
function selectPlaneByHex(hex,autofollow) { function selectPlaneByHex(hex,autofollow) {
//console.log("select: " + hex); //console.log("select: " + hex);
// If SelectedPlane has something in it, clear out the selected // If SelectedPlane has something in it, clear out the selected
if (SelectedAllPlanes) {
deselectAllPlanes();
}
if (SelectedPlane != null) { if (SelectedPlane != null) {
Planes[SelectedPlane].selected = false; Planes[SelectedPlane].selected = false;
Planes[SelectedPlane].clearLines(); Planes[SelectedPlane].clearLines();
@ -931,6 +938,67 @@ function selectPlaneByHex(hex,autofollow) {
refreshSelected(); refreshSelected();
} }
// loop through the planes and mark them as selected to show the paths for all planes
function selectAllPlanes() {
// if all planes are already selected, deselect them all
if (SelectedAllPlanes) {
deselectAllPlanes();
} else {
// If SelectedPlane has something in it, clear out the selected
if (SelectedPlane != null) {
Planes[SelectedPlane].selected = false;
Planes[SelectedPlane].clearLines();
Planes[SelectedPlane].updateMarker();
$(Planes[SelectedPlane].tr).removeClass("selected");
}
SelectedPlane = null;
for(var key in Planes) {
if (Planes[key].visible !== false) {
Planes[key].selected = true;
Planes[key].updateLines();
Planes[key].updateMarker();
}
}
SelectedAllPlanes = true;
}
refreshSelected();
}
// on refreshes, try to find new planes and mark them as selected
function selectNewPlanes() {
if (SelectedAllPlanes) {
for (var key in Planes) {
if (Planes[key].visible === false) {
Planes[key].selected = false;
Planes[key].clearLines();
Planes[key].updateMarker();
} else {
if (Planes[key].selected !== true) {
Planes[key].selected = true;
Planes[key].updateLines();
Planes[key].updateMarker();
}
}
}
}
}
// deselect all the planes
function deselectAllPlanes() {
for(var key in Planes) {
Planes[key].selected = false;
Planes[key].clearLines();
Planes[key].updateMarker();
$(Planes[key].tr).removeClass("selected");
}
SelectedPlane = null;
SelectedAllPlanes = false;
refreshSelected();
}
function toggleFollowSelected() { function toggleFollowSelected() {
FollowSelected = !FollowSelected; FollowSelected = !FollowSelected;
if (FollowSelected && OLMap.getView().getZoom() < 8) if (FollowSelected && OLMap.getView().getZoom() < 8)