summaryrefslogtreecommitdiff
path: root/dashboard_website/static
diff options
context:
space:
mode:
Diffstat (limited to 'dashboard_website/static')
-rw-r--r--dashboard_website/static/js/dashboard.js38
1 files changed, 29 insertions, 9 deletions
diff --git a/dashboard_website/static/js/dashboard.js b/dashboard_website/static/js/dashboard.js
index 0248844..a67f85f 100644
--- a/dashboard_website/static/js/dashboard.js
+++ b/dashboard_website/static/js/dashboard.js
@@ -57,12 +57,25 @@ function drawRoute(route_coords_osrm, team_color) {
route_coords_osrm[i][1] = route_coords_osrm[i][0];
route_coords_osrm[i][0] = t;
}
- var route = new L.polyline(route_coords_osrm, {color: team_color}).addTo(map);
+ var route = new L.polyline(route_coords_osrm, {color: team_color});
+ routes_m.addLayer(route);
}
function drawRoutes() {
+ routes_m.clearLayers();
for (var i = 0; i < routes['clusters'].length; i++){
if(routes['clusters'][i].length > 0){
- drawRoute(routes['clusters'][i], i%2 == 0 ? 'red' : 'yellow');
+ var color;
+ var r = Math.floor(Math.random() * 155+100);
+ var g = 0; // no greens -- avoid yellow
+ var b = Math.floor(Math.random() * 155+100);
+ color= "rgb("+r+","+g+","+ b+")";
+ console.log(color);
+ drawRoute(routes['clusters'][i], color);
+ }
+ }
+ for (var i = 0; i < routes['individual_routes'].length; i++){
+ if(routes['individual_routes'][i].length > 0){
+ drawRoute(routes['individual_routes'][i], 'yellow');
}
}
}
@@ -77,10 +90,12 @@ function updateBikeStatus(){
var namecell = document.createElement("td"); namecell.innerHTML = "<a href=\"#\" onclick=\"zoomToBike('"+name+"')\">"+name+"</a>";
var statuscell = document.createElement("td"); statuscell.innerHTML = "<span "+((bike['team_status'] == "ACTIVE")? "style=\"color:lightgreen\"" : "") +">" + bike['team_status'] + " ("+parseInt(bike['time_since_last_contact']).toString()+"s)</span>";
var targetcell = document.createElement("td"); targetcell.innerHTML = "<a href=\"#\" onclick=\"zoomToClue('"+bike['target_clue']+"')\">"+bike['target_clue']+"</a>";
+ var etacell = document.createElement("td"); etacell.innerHTML = "ETA: "+routes['cluster_times'][key];
row.appendChild(namecell);
row.appendChild(statuscell);
row.appendChild(targetcell);
+ row.appendChild(etacell);
table.appendChild(row);
}
}
@@ -138,9 +153,16 @@ function requestLatestInfo(){
if(homemarker)homemarker.setLatLng([homebase['latitude'], homebase['longitude']]);
else homemarker = L.marker([homebase['latitude'], homebase['longitude']], {icon: homeIcon}).addTo(map).bindPopup("Home is where the club is.");
}
+ // process routes
+ if(json['routes_changed']){
+ routes = json['routes'];
+ console.log(routes);
+ drawRoutes();
+ }
// process bikes
if(true || json['bikes_changed']){ // always true since we need constant updates for bikes
- var bikes_t = json['bikes'];
+ bikes_t = json['bikes'];
+
for (var i = 0; i < bikes_t.length; i++){
var name = bikes_t[i]['team_name'];
if(name in bikes) {
@@ -178,11 +200,8 @@ function requestLatestInfo(){
drawClues();
updateClueStats();
}
- // process routes
- if(json['routes_changed']){
- routes = json['routes'];
- drawRoutes();
- }
+
+ document.getElementById("routeinfo").innerText = json['calculating_routes'] ? "ROUTE INFO | (Calculating...)" : "ROUTE INFO";
}
fetch(host+'/getLatestInfo', {
method: "POST",
@@ -196,7 +215,7 @@ function requestLatestInfo(){
}
var intervalId = window.setInterval(function(){
requestLatestInfo();
- }, 5000);
+ }, 3000);
var clockINterval = window.setInterval(function(){
var d = new Date();
@@ -226,6 +245,7 @@ window.onload = function() {
map.addLayer(visited_clues_m);
map.addLayer(unvisited_clues_m);
map.addLayer(bikes_m);
+ map.addLayer(routes_m);
var layerControl = L.control.layers(null,null,{collapsed:false});
layerControl.addOverlay(unvisited_clues_m, "Unvisited Clues");
layerControl.addOverlay(visited_clues_m, "Visited Clues");