Skip to content

Commit

Permalink
Ugly double ()() to refer to uav
Browse files Browse the repository at this point in the history
  • Loading branch information
Anne van Rossum committed Mar 13, 2013
1 parent 0f7393f commit 6e8d4c3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions static/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function DroneViewModel() {
self.points = ko.observableArray([]);
self.droneparameters = ko.observableArray([]); // Used by html
self.dronecommands = ko.observableArray([]); // Used by html
var initialized=false;

var areaLine = new google.maps.Polyline({
title: "area",
Expand All @@ -157,6 +158,7 @@ function DroneViewModel() {
self.chosenUAV().startLanding();
};

// when click in the table this updates the selected UAV
self.goToUAV = function(uav) {
self.chosenUAVId(uav.name);
self.chosenUAV(uav);
Expand Down Expand Up @@ -251,7 +253,7 @@ function DroneViewModel() {
var name = "UAV " + id;

if (self.uavExists(name)) {
// Update uav
// Update of the uav is done below
} else {
// Add uav
self.addUAV(name, droneparam.uav_x, droneparam.uav_y);
Expand All @@ -260,7 +262,17 @@ function DroneViewModel() {
var uav = self.getUAV(name);
uav.parameters = droneparam;
uav.update();
self.loadParameters(droneparam);

if (!initialized) {
self.goToUAV(uav );
initialized = true;
}

if (name == self.chosenUAVId()() ) {
self.goToUAV(uav );
} else {
//alert ("Current name " + name + " does not match " + self.chosenUAVId()() );
}
}

/*
Expand Down

0 comments on commit 6e8d4c3

Please sign in to comment.