diff --git a/.gitignore b/.gitignore index f91ec08..450048e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,7 @@ *.swp *.pyc *.log -js/mobile.js -js/init_plot.js -js/version.json -css/mobile.css +/index.html +/js/version.json cache.manifest -tiles/ \ No newline at end of file +tiles/ diff --git a/DEVELOPER_README.md b/DEVELOPER_README.md index 3272308..2cf294a 100644 --- a/DEVELOPER_README.md +++ b/DEVELOPER_README.md @@ -4,6 +4,6 @@ To get a copy of the code and run a test web server: 1. [Fork the repository](https://github.com/projecthorus/sondehub-tracker/fork) by visiting [https://github.com/projecthorus/sondehub-tracker/fork](https://github.com/projecthorus/sondehub-tracker/fork). 2. Clone the repository with your git tool of choice. -3. Run `build.sh` to compile the javascript files. (This requires Java to be installed and in your path.) +3. Run `build.sh` to generate `index.html` and `js/version.json`. 4. Run `python serve.py` to run a simple web server to (This requires python 3.x) 5. Visit [http://localhost:8000](http://localhost:8000) to view the local version of the server! diff --git a/Dockerfile b/Dockerfile index fbb1bdb..53107d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:latest -RUN apk add --no-cache python3 openjdk11 sed git +RUN apk add --no-cache python3 sed git WORKDIR /app ADD . . diff --git a/README.md b/README.md index 2a812de..42427be 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,6 @@ Pull requests are welcome. ## Installation -Requirements: Java - $ git clone https://github.com/projecthorus/sondehub-tracker.git $ ./build.sh $ python serve.py diff --git a/build.sh b/build.sh index ecabd0e..096c1c0 100755 --- a/build.sh +++ b/build.sh @@ -1,50 +1,18 @@ #!/bin/bash -# compile stylesheet -echo -n "Compiling CSS... " -cd css -rm -f mobile.css -cat base.css skeleton.css layout.css habitat-font.css main.css leaflet.css leaflet.fullscreen.css skewt.css > mobile.tmp -java -jar "../tools/yuicompressor-2.4.8.jar" --type=css mobile.tmp > mobile.css -rm -f mobile.tmp -cd .. -echo "Done!" - -#compile javascript -echo -n "Compiling JavaScript... " -cd js -rm -f mobile.js init_plot.js -# precompiled libs -cat jquery* >> mobile.js +set -e VERSION="`git rev-parse --short HEAD`" - BUILD_DATE="`date -u +%Y-%m-%dT%H:%M:%SZ`" -# compile the rest -java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge iscroll.js >> mobile.js -java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge chasecar.lib.js | sed "s/{VER}/$VERSION/" >> mobile.js -java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge tracker.js >> mobile.js -java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge app.js | sed "s/{VER}/$VERSION/" | sed "s/{BUILD_DATE}/$BUILD_DATE/" >> mobile.js -java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge colour-map.js >> mobile.js -java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge xdata.js >> mobile.js -java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge station.js >> mobile.js -java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge format.js >> mobile.js - -#compile plot lib and config -java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge _jquery.flot.js >> init_plot.js -java -jar "../tools/yuicompressor-2.4.8.jar" --type=js --disable-optimizations --nomunge plot_config.js >> init_plot.js - # create version check file -echo "{\"build_date\": \"$BUILD_DATE\", \"version\": \"$VERSION\", \"refresh\": 86400}" > version.json - -cd .. +echo -n "Generating js/version.json... " +echo "{\"build_date\": \"$BUILD_DATE\", \"version\": \"$VERSION\", \"refresh\": 86400}" > js/version.json echo "Done!" # cache fixes -sed -i'' "s/{VER}/$VERSION/" index.html -sed -i'' "s/{VER}/$VERSION/" service-worker.js - +echo -n "Generating index.html... " +sed -e "s/{VER}/$VERSION/" -e "s/{BUILD_DATE}/$BUILD_DATE/" index.template.html > index.html echo "Done!" echo "Build version: $VERSION Build date: $BUILD_DATE" diff --git a/img/markers/balloon-adafruit.png b/img/markers/balloon-adafruit.png deleted file mode 100644 index 4c715f2..0000000 Binary files a/img/markers/balloon-adafruit.png and /dev/null differ diff --git a/img/markers/balloon-blue.png b/img/markers/balloon-blue.png deleted file mode 100644 index 9888487..0000000 Binary files a/img/markers/balloon-blue.png and /dev/null differ diff --git a/img/markers/balloon-buzz.png b/img/markers/balloon-buzz.png deleted file mode 100644 index 17097b5..0000000 Binary files a/img/markers/balloon-buzz.png and /dev/null differ diff --git a/img/markers/balloon-cyan.png b/img/markers/balloon-cyan.png deleted file mode 100644 index 9eae707..0000000 Binary files a/img/markers/balloon-cyan.png and /dev/null differ diff --git a/img/markers/balloon-green.png b/img/markers/balloon-green.png deleted file mode 100644 index 126a0b0..0000000 Binary files a/img/markers/balloon-green.png and /dev/null differ diff --git a/img/markers/balloon-invisible.png b/img/markers/balloon-invisible.png deleted file mode 100644 index 19464e9..0000000 Binary files a/img/markers/balloon-invisible.png and /dev/null differ diff --git a/img/markers/balloon-iss.png b/img/markers/balloon-iss.png deleted file mode 100644 index 23d2a49..0000000 Binary files a/img/markers/balloon-iss.png and /dev/null differ diff --git a/img/markers/balloon-orange.png b/img/markers/balloon-orange.png deleted file mode 100644 index b0c5d09..0000000 Binary files a/img/markers/balloon-orange.png and /dev/null differ diff --git a/img/markers/balloon-purple.png b/img/markers/balloon-purple.png deleted file mode 100644 index e129b1c..0000000 Binary files a/img/markers/balloon-purple.png and /dev/null differ diff --git a/img/markers/balloon-red.png b/img/markers/balloon-red.png deleted file mode 100644 index f079bfe..0000000 Binary files a/img/markers/balloon-red.png and /dev/null differ diff --git a/img/markers/balloon-rob.png b/img/markers/balloon-rob.png deleted file mode 100644 index 819a558..0000000 Binary files a/img/markers/balloon-rob.png and /dev/null differ diff --git a/img/markers/balloon-rpi.png b/img/markers/balloon-rpi.png deleted file mode 100644 index c340631..0000000 Binary files a/img/markers/balloon-rpi.png and /dev/null differ diff --git a/img/markers/balloon-shockpink.png b/img/markers/balloon-shockpink.png deleted file mode 100644 index 49ad112..0000000 Binary files a/img/markers/balloon-shockpink.png and /dev/null differ diff --git a/img/markers/balloon-thereg.png b/img/markers/balloon-thereg.png deleted file mode 100644 index f26068f..0000000 Binary files a/img/markers/balloon-thereg.png and /dev/null differ diff --git a/img/markers/balloon-yellow.png b/img/markers/balloon-yellow.png deleted file mode 100644 index 66fc042..0000000 Binary files a/img/markers/balloon-yellow.png and /dev/null differ diff --git a/img/markers/balloon.svg b/img/markers/balloon.svg new file mode 100755 index 0000000..8966505 --- /dev/null +++ b/img/markers/balloon.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/img/markers/car-blue.png b/img/markers/car-blue.png deleted file mode 100644 index 09192f0..0000000 Binary files a/img/markers/car-blue.png and /dev/null differ diff --git a/img/markers/car-green.png b/img/markers/car-green.png deleted file mode 100644 index c42da50..0000000 Binary files a/img/markers/car-green.png and /dev/null differ diff --git a/img/markers/car-purple.png b/img/markers/car-purple.png deleted file mode 100644 index a281513..0000000 Binary files a/img/markers/car-purple.png and /dev/null differ diff --git a/img/markers/car-red.png b/img/markers/car-red.png deleted file mode 100644 index ce44c92..0000000 Binary files a/img/markers/car-red.png and /dev/null differ diff --git a/img/markers/car-teal.png b/img/markers/car-teal.png deleted file mode 100644 index f0e6fe8..0000000 Binary files a/img/markers/car-teal.png and /dev/null differ diff --git a/img/markers/car-yellow.png b/img/markers/car-yellow.png deleted file mode 100644 index 5c35476..0000000 Binary files a/img/markers/car-yellow.png and /dev/null differ diff --git a/img/markers/car.svg b/img/markers/car.svg new file mode 100644 index 0000000..c277ce8 --- /dev/null +++ b/img/markers/car.svg @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/img/markers/parachute-blue.png b/img/markers/parachute-blue.png deleted file mode 100644 index ff4dc5d..0000000 Binary files a/img/markers/parachute-blue.png and /dev/null differ diff --git a/img/markers/parachute-cyan.png b/img/markers/parachute-cyan.png deleted file mode 100644 index bf83a49..0000000 Binary files a/img/markers/parachute-cyan.png and /dev/null differ diff --git a/img/markers/parachute-green.png b/img/markers/parachute-green.png deleted file mode 100644 index f41d7e1..0000000 Binary files a/img/markers/parachute-green.png and /dev/null differ diff --git a/img/markers/parachute-orange.png b/img/markers/parachute-orange.png deleted file mode 100644 index e3f2d16..0000000 Binary files a/img/markers/parachute-orange.png and /dev/null differ diff --git a/img/markers/parachute-purple.png b/img/markers/parachute-purple.png deleted file mode 100644 index adae959..0000000 Binary files a/img/markers/parachute-purple.png and /dev/null differ diff --git a/img/markers/parachute-red.png b/img/markers/parachute-red.png deleted file mode 100644 index 603c60f..0000000 Binary files a/img/markers/parachute-red.png and /dev/null differ diff --git a/img/markers/parachute-rpi.png b/img/markers/parachute-rpi.png deleted file mode 100644 index ad421b6..0000000 Binary files a/img/markers/parachute-rpi.png and /dev/null differ diff --git a/img/markers/parachute-yellow.png b/img/markers/parachute-yellow.png deleted file mode 100644 index 4d85a51..0000000 Binary files a/img/markers/parachute-yellow.png and /dev/null differ diff --git a/img/markers/parachute.svg b/img/markers/parachute.svg new file mode 100644 index 0000000..8b10853 --- /dev/null +++ b/img/markers/parachute.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/img/markers/payload-blue.png b/img/markers/payload-blue.png deleted file mode 100644 index c03caee..0000000 Binary files a/img/markers/payload-blue.png and /dev/null differ diff --git a/img/markers/payload-cyan.png b/img/markers/payload-cyan.png deleted file mode 100644 index 226bfa8..0000000 Binary files a/img/markers/payload-cyan.png and /dev/null differ diff --git a/img/markers/payload-green.png b/img/markers/payload-green.png deleted file mode 100644 index f524a73..0000000 Binary files a/img/markers/payload-green.png and /dev/null differ diff --git a/img/markers/payload-orange.png b/img/markers/payload-orange.png deleted file mode 100644 index 20e5b05..0000000 Binary files a/img/markers/payload-orange.png and /dev/null differ diff --git a/img/markers/payload-purple.png b/img/markers/payload-purple.png deleted file mode 100644 index 80e1e1a..0000000 Binary files a/img/markers/payload-purple.png and /dev/null differ diff --git a/img/markers/payload-red.png b/img/markers/payload-red.png deleted file mode 100644 index 7ad8acc..0000000 Binary files a/img/markers/payload-red.png and /dev/null differ diff --git a/img/markers/payload-rpi.png b/img/markers/payload-rpi.png deleted file mode 100644 index 9f533fb..0000000 Binary files a/img/markers/payload-rpi.png and /dev/null differ diff --git a/img/markers/payload-yellow.png b/img/markers/payload-yellow.png deleted file mode 100644 index e9b7bb5..0000000 Binary files a/img/markers/payload-yellow.png and /dev/null differ diff --git a/img/markers/payload.svg b/img/markers/payload.svg new file mode 100644 index 0000000..b89d7d6 --- /dev/null +++ b/img/markers/payload.svg @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/img/markers/target-blue.png b/img/markers/target-blue.png deleted file mode 100644 index fae5796..0000000 Binary files a/img/markers/target-blue.png and /dev/null differ diff --git a/img/markers/target-cyan.png b/img/markers/target-cyan.png deleted file mode 100644 index ba30743..0000000 Binary files a/img/markers/target-cyan.png and /dev/null differ diff --git a/img/markers/target-green.png b/img/markers/target-green.png deleted file mode 100644 index 56b4682..0000000 Binary files a/img/markers/target-green.png and /dev/null differ diff --git a/img/markers/target-orange.png b/img/markers/target-orange.png deleted file mode 100644 index 4b353b6..0000000 Binary files a/img/markers/target-orange.png and /dev/null differ diff --git a/img/markers/target-purple.png b/img/markers/target-purple.png deleted file mode 100644 index 4510158..0000000 Binary files a/img/markers/target-purple.png and /dev/null differ diff --git a/img/markers/target-red.png b/img/markers/target-red.png deleted file mode 100644 index 5987df9..0000000 Binary files a/img/markers/target-red.png and /dev/null differ diff --git a/img/markers/target-yellow.png b/img/markers/target-yellow.png deleted file mode 100644 index 8dc2d08..0000000 Binary files a/img/markers/target-yellow.png and /dev/null differ diff --git a/img/markers/target.svg b/img/markers/target.svg new file mode 100644 index 0000000..e80875e --- /dev/null +++ b/img/markers/target.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/index.html b/index.template.html similarity index 93% rename from index.html rename to index.template.html index f214f36..c0e8eaf 100644 --- a/index.html +++ b/index.template.html @@ -19,10 +19,39 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - +
@@ -417,27 +446,9 @@

Report Recovery

- - - - - - - - - - - - - + + + diff --git a/js/app.js b/js/app.js index 351cf18..8c87e0f 100644 --- a/js/app.js +++ b/js/app.js @@ -207,7 +207,9 @@ function trackerInit() { if(is_mobile || wvar.enabled) $(".nav .wvar").hide(); if(!is_mobile) { - $.getScript("js/init_plot.js", function() { checkSize(); if(!map) load(); }); + $.getScript("js/_jquery.flot.js", function() { + $.getScript("js/plot_config.js", function() { checkSize(); if(!map) load(); }); + }); if(wvar.graph) $('#telemetry_graph').attr('style',''); return; @@ -445,6 +447,25 @@ var format_time_friendly = function(start, end) { } }; +var format_coordinates = function(lat, lon, name) { + var coords_text; + var ua = navigator.userAgent.toLowerCase(); + + // determine how to link the coordinates to a native app, if on a mobile device + if(ua.indexOf('iphone') > -1) { + coords_text = '' + + roundNumber(lat, 5) + ', ' + roundNumber(lon, 5) +''; + } else if(ua.indexOf('android') > -1) { + coords_text = '' + + roundNumber(lat, 5) + ', ' + roundNumber(lon, 5) +''; + } else { + coords_text = '' + + roundNumber(lat, 5) + ', ' + roundNumber(lon, 5) +''; + } + + return coords_text; +}; + // runs every second var updateTime = function(date) { // update timebox @@ -466,8 +487,6 @@ var updateTime = function(date) { } }; -const version = "{VER}"; - $(window).ready(function() { // refresh timebox setInterval(function() { @@ -475,8 +494,8 @@ $(window).ready(function() { }, 1000); // Update Tracker version info - $('#build_version').text(version); - $('#build_date').text("{BUILD_DATE}"); + $('#build_version').text(document.body.dataset.version); + $('#build_date').text(document.body.dataset.buildDate); // resize elements if needed checkSize(); @@ -553,12 +572,6 @@ $(window).ready(function() { $("#main").removeClass("drag"); }); - // confirm dialog when launchnig a native map app with coordinates - //$('#main').on('click', '#launch_mapapp', function() { - // var answer = confirm("Launch your maps app?"); - // return answer; - //}); - // follow vehicle by clicking on data $('#main').on('click', '.row .data', function() { var e = $(this).parent(); @@ -654,7 +667,7 @@ $(window).ready(function() { if(currentPosition && currentPosition.marker) map.addLayer(currentPosition.marker); // turning the switch on } else { - if(callsign.length == null || callsign.length < 3) { alert('Please enter a valid callsign, at least 3 characters'); return; } + if(callsign == null || callsign.length < 3) { alert('Please enter a valid callsign, at least 3 characters'); return; } if(!callsign.match(/^[a-zA-Z0-9\_\-]+$/)) { alert('Invalid characters in callsign (use only a-z,0-9,-,_)'); return; } field.attr('disabled','disabled'); @@ -1020,7 +1033,7 @@ function check_version(){ fetch(updateRequest) .then(function(response){ return response.json()}) .then(function(response){ - if (response['version'] != version) { + if (response['version'] != document.body.dataset.version) { window.clearInterval(update_check) reload_timer = window.setTimeout(update_site, response['refresh']*1000) reload_end_time = new Date().getTime() +response['refresh']*1000 diff --git a/js/chasecar.lib.js b/js/chasecar.lib.js index 4dd198c..23b706c 100644 --- a/js/chasecar.lib.js +++ b/js/chasecar.lib.js @@ -24,7 +24,7 @@ ChaseCar.updatePosition = function(callsign, position) { var _doc = { "software_name": "SondeHub Tracker", - "software_version": "{VER}", + "software_version": document.body.dataset.version, "uploader_callsign": callsign, "uploader_position": [position.coords.latitude, position.coords.longitude, _position_alt], "uploader_antenna": "Mobile Station", diff --git a/js/tracker.js b/js/sondehub.js similarity index 97% rename from js/tracker.js rename to js/sondehub.js index e518415..1edbc00 100644 --- a/js/tracker.js +++ b/js/sondehub.js @@ -73,9 +73,8 @@ var manual_pan = false; // due to complaints it was not visible enough. - 2023-06-03 var car_index = 0; -var car_colors = ["blue", "red", "green", "yellow", "teal", "purple"]; -var balloon_colors_name = ["red", "blue", "green", "purple", "orange", "cyan"]; -var balloon_colors = ["#f00", "blue", "green", "#c700e6", "#ff8a0f", "#0fffca"]; +var car_colors = ["#a6cee3", "#1f78b4", "#fb9a99", "#e31a1c", "#fdbf6f", "#ff7f00", "#cab2d6"]; +var balloon_colors = ["#d95f02", "#7570b3", "#e7298a", "#e6ab02", "#a6761d", "#666666", "blue", "lime", "magenta", "#ffb300", "rebeccapurple"]; var nyan_color_index = 0; var nyan_colors = ['nyan', 'nyan-coin', 'nyan-mon', 'nyan-pirate', 'nyan-cool', 'nyan-tothemax', 'nyan-pumpkin', 'nyan-afro', 'nyan-coin', 'nyan-mummy']; @@ -1653,7 +1652,7 @@ function updateVehicleInfo(vcallsign, newPosition) { vehicle.marker.setLatLng(latlng); if(!!vehicle.marker.setCourse) { - if (vehicle.curr_position.gps_heading) { + if (vehicle.curr_position.gps_heading && vehicle.marker.rotated) { vehicle.marker.setCourse((vehicle.curr_position.gps_heading !== "") ? parseInt(vehicle.curr_position.gps_heading) : 90); } } @@ -1800,23 +1799,7 @@ function updateVehicleInfo(vcallsign, newPosition) { hrate_text = imp ? (vehicle.horizontal_rate * 196.850394).toFixed(1) + ' ft/min' : vehicle.horizontal_rate.toFixed(1) + ' m/s'; } - var coords_text; - var ua = navigator.userAgent.toLowerCase(); - - // determine how to link the vehicle coordinates to a native app, if on a mobile device - if(ua.indexOf('iphone') > -1) { - coords_text = '' + - roundNumber(newPosition.gps_lat, 5) + ', ' + roundNumber(newPosition.gps_lon, 5) +'' + - ' '; - } else if(ua.indexOf('android') > -1) { - coords_text = '' + - roundNumber(newPosition.gps_lat, 5) + ', ' + roundNumber(newPosition.gps_lon, 5) +'' + - ' '; - } else { - coords_text = '' + - roundNumber(newPosition.gps_lat, 5) + ', ' + roundNumber(newPosition.gps_lon, 5) +'' + - ' '; - } + var coords_text = format_coordinates(newPosition.gps_lat, newPosition.gps_lon, vcallsign) + ' '; // format altitude strings var text_alt = Number((imp) ? Math.floor(3.2808399 * parseInt(newPosition.gps_alt)) : parseInt(newPosition.gps_alt)).toLocaleString("us"); @@ -2260,16 +2243,20 @@ function set_polyline_visibility(vcallsign, val) { if(vehicle.prediction_polyline) { if (val) { - map.addLayer(vehicle.prediction_polyline); + map.addLayer(vehicle.prediction_polyline[0]); + map.addLayer(vehicle.prediction_polyline[1]); } else { - map.removeLayer(vehicle.prediction_polyline); + map.removeLayer(vehicle.prediction_polyline[0]); + map.removeLayer(vehicle.prediction_polyline[1]); } } if(vehicle.prediction_launch_polyline) { if (val) { - map.addLayer(vehicle.prediction_launch_polyline); + map.addLayer(vehicle.prediction_launch_polyline[0]); + map.addLayer(vehicle.prediction_launch_polyline[1]); } else { - map.removeLayer(vehicle.prediction_launch_polyline); + map.removeLayer(vehicle.prediction_launch_polyline[0]); + map.removeLayer(vehicle.prediction_launch_polyline[1]); } } if(vehicle.prediction_target) { @@ -2292,7 +2279,8 @@ function set_polyline_visibility(vcallsign, val) { function removePrediction(vcallsign) { if(vehicles[vcallsign].prediction_polyline) { - map.removeLayer(vehicles[vcallsign].prediction_polyline); + map.removeLayer(vehicles[vcallsign].prediction_polyline[0]); + map.removeLayer(vehicles[vcallsign].prediction_polyline[1]); vehicles[vcallsign].prediction_polyline = null; } if(vehicles[vcallsign].prediction_target) { @@ -2321,19 +2309,42 @@ function drawLaunchPrediction(vcallsign) { vehicle.prediction_launch_path = line; - vehicle.prediction_launch_polyline = new L.Polyline(line, { + vehicle.prediction_launch_polyline = [new L.Polyline(line, { color: balloon_colors[vehicle.color_index], - opacity: 0.4, + opacity: 0.8, weight: 3, - })//.addTo(map); - - vehicle.prediction_launch_polyline.on('click', function (e) { + }), + new L.Polyline(line, { + color: "#000", + opacity: 0.1, + weight: 6, +}) +]//.addTo(map); + + vehicle.prediction_launch_polyline[0].on('click', function (e) { + mapInfoBox_handle_prediction_path(e); + }); + vehicle.prediction_launch_polyline[1].on('click', function (e) { mapInfoBox_handle_prediction_path(e); }); vehicle.prediction_launch_polyline.path_length = path_length; } +// Takes in an SVG for a balloon, parachute, target, car, etc and sets a dynamic-color +// variable which that SVG can use to recolor any relevant elements. +// See balloon.svg, target.svg, etc for examples +function recolorSVG(svg_path, color) { + const xhr = new XMLHttpRequest(); + xhr.open('GET', svg_path, false); + xhr.send(); + + const parser = new DOMParser(); + const svgDocument = parser.parseFromString(xhr.responseText, 'image/svg+xml'); + svgDocument.documentElement.style.setProperty("--dynamic-color", color); + return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svgDocument.documentElement.outerHTML); + } + function redrawPrediction(vcallsign) { var vehicle = vehicles[vcallsign]; var data = vehicle.prediction.data; @@ -2373,16 +2384,27 @@ function redrawPrediction(vcallsign) { vehicle.prediction_path = line; if(vehicle.prediction_polyline !== null) { - vehicle.prediction_polyline.setLatLngs(line); + vehicle.prediction_polyline[0].setLatLngs(line); + vehicle.prediction_polyline[1].setLatLngs(line); } else { - vehicle.prediction_polyline = new L.Polyline(line, { + vehicle.prediction_polyline = [new L.Polyline(line, { color: balloon_colors[vehicle.color_index], - opacity: 0.5, // Was 0.4 + opacity: 0.8, // Was 0.4 weight: 3, - })//.addTo(map); - vehicle.prediction_polyline.on('click', function (e) { + }), + new L.Polyline(line, { + color: "#000", + opacity: 0.1, // Was 0.4 + weight: 6, + }) + + ]//.addTo(map); + vehicle.prediction_polyline[0].on('click', function (e) { mapInfoBox_handle_prediction_path(e); }); + vehicle.prediction_polyline[1].on('click', function (e) { + mapInfoBox_handle_prediction_path(e); + }) } vehicle.prediction_polyline.path_length = path_length; @@ -2393,7 +2415,7 @@ function redrawPrediction(vcallsign) { if(vehicle.prediction_target) { vehicle.prediction_target.setLatLng(latlng); } else { - image_src = host_url + markers_url + "target-" + balloon_colors_name[vehicle.color_index] + ".png"; + image_src = recolorSVG(host_url + markers_url + "target.svg", balloon_colors[vehicle.color_index]); predictionIcon = new L.icon({ iconUrl: image_src, iconSize: [20,20], @@ -2684,7 +2706,7 @@ function mapInfoBox_handle_path_old(vehicle, id) { html = "
"; html += "
"+data.serial+" ("+data.datetime+")
"; html += "
"; - html += "
 "+roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5)+"
"; + html += "
 "+format_coordinates(data.lat, data.lon, data.serial)+"
"; var imp = offline.get('opt_imperial'); var text_alt = Number((imp) ? Math.floor(3.2808399 * parseInt(data.alt)) : parseInt(data.alt)).toLocaleString("us"); @@ -2759,7 +2781,7 @@ function mapInfoBox_handle_path_new(data, vehicle, date) { html = "
"; html += "
"+data.serial+" ("+date+")
"; html += "
"; - html += "
 "+roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5)+"
"; + html += "
 "+format_coordinates(data.lat, data.lon, data.serial)+"
"; var imp = offline.get('opt_imperial'); var text_alt = Number((imp) ? Math.floor(3.2808399 * parseInt(data.alt)) : parseInt(data.alt)).toLocaleString("us"); @@ -2893,20 +2915,7 @@ function mapInfoBox_handle_prediction(event) { altitude = Math.round(data.alt) + " m"; } - var coords_text; - var ua = navigator.userAgent.toLowerCase(); - - // determine how to link the vehicle coordinates to a native app, if on a mobile device - if(ua.indexOf('iphone') > -1) { - coords_text = '' + - roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5) + ''; - } else if(ua.indexOf('android') > -1) { - coords_text = '' + - roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5) +''; - } else { - coords_text = '' + - roundNumber(data.lat, 5) + ', ' + roundNumber(data.lon, 5) +''; - } + var coords_text = format_coordinates(data.lat, data.lon, "Prediction"); mapInfoBox.setContent("
" +
                         formatDate(new Date(parseInt(data.time) * 1000), true) + "\n\n" +
@@ -2987,10 +2996,10 @@ var marker_rotate_setup = function(marker, image_src) {
     else {
         marker.iconImg = new Image();
         icon_cache[image_src] = marker.iconImg;
-        marker.iconImg.onload = function() {
+        marker.iconImg.addEventListener("load", function() {
             if(!marker.rotated) marker.setCourse(90);
             marker.setLatLng(marker.getLatLng());
-        };
+        })
         marker.iconImg.src = image_src;
     }
 };
@@ -3023,7 +3032,7 @@ function addPosition(position) {
         if(vcallsign.search(/(chase)/i) != -1) {
             vehicle_type = "car";
             color_index = car_index++ % car_colors.length;
-            image_src = host_url + markers_url + "car-" + car_colors[color_index] + ".png";
+            image_src = recolorSVG(host_url + markers_url + "car.svg", car_colors[color_index]);
             image_src_size = [55,25];
             image_src_offset = [0,-25];
 
@@ -3064,26 +3073,6 @@ function addPosition(position) {
                     weight: 3,
                 })
             ];
-        }
-        else if(vcallsign == "XX") {
-            vehicle_type = "xmark";
-            image_src = host_url + markers_url + "balloon-xmark.png";
-            image_src_size = [48,38];
-            image_src_offset = [0,-38];
-
-            xmarkIcon = new L.icon({
-                iconUrl: image_src,
-                iconSize: image_src_size,
-                iconAnchor: [24, 18],
-            });
-
-            marker = new L.Marker(point, {
-                icon: xmarkIcon,
-                title: vcallsign,
-                zIndexOffset: Z_CAR,
-            });
-
-            marker.addTo(map);
         } else {
             vehicle_type = "balloon";
             let colorHash = 0;
@@ -3096,9 +3085,7 @@ function addPosition(position) {
                 // All the balloon are red.
                 color_index = 0;
             }
-
-            image_src = host_url + markers_url + "balloon-" +
-                        ((vcallsign == "PIE") ? "rpi" : balloon_colors_name[color_index]) + ".png";
+            image_src = recolorSVG(host_url + markers_url + "balloon.svg", balloon_colors[color_index]);
             image_src_size = [46,84];
             image_src_offset = [-35,-46];
 
@@ -3143,7 +3130,7 @@ function addPosition(position) {
             };
 
             marker.shadow = marker_shadow;
-            marker.balloonColor = (vcallsign == "PIE") ? "rpi" : balloon_colors_name[color_index];
+            marker.balloonColor = balloon_colors[color_index];
             marker.mode = 'balloon';
             marker.setMode = function(mode) {
                 if(this.mode == mode) return;
@@ -3156,9 +3143,9 @@ function addPosition(position) {
                     map.removeLayer(vehicle.subhorizon_circle);
                     map.removeLayer(vehicle.horizon_circle_title);
                     map.removeLayer(vehicle.subhorizon_circle_title);
-
+                    img_src = recolorSVG(host_url + markers_url + "payload.svg", this.balloonColor);
                     img = new L.icon ({
-                        iconUrl: host_url + markers_url + "payload-" + this.balloonColor + ".png",
+                        iconUrl: img_src,
                         iconSize: [17,18],
                         iconAnchor: [8,14],
                         tooltipAnchor: [0,-20],
@@ -3174,15 +3161,17 @@ function addPosition(position) {
                     }
 
                     if(mode == "parachute") {
+                        img_src = recolorSVG(host_url + markers_url + "parachute.svg", this.balloonColor);
                         img = new L.icon ({
-                            iconUrl: host_url + markers_url + "parachute-" + this.balloonColor + ".png",
+                            iconUrl: img_src,
                             iconSize: [46,84],
                             tooltipAnchor: [0,-98],
                             iconAnchor: [23,90],
                         });
                     } else {
+                        img_src = recolorSVG(host_url + markers_url + "balloon.svg", this.balloonColor);
                         img = new L.icon ({
-                            iconUrl: host_url + markers_url + "balloon-" + this.balloonColor + ".png",
+                            iconUrl: img_src,
                             iconSize: [46,84],
                             tooltipAnchor: [0,-98],
                             iconAnchor: [23,90],
@@ -3290,6 +3279,11 @@ function addPosition(position) {
                     color: balloon_colors[color_index],
                     opacity: 1,
                     weight: 3,
+                }),
+                new L.Polyline(point, {
+                    color: "#fff",
+                    opacity: 0.6,
+                    weight: 6,
                 })
             ];
         }
@@ -3401,11 +3395,13 @@ function addPosition(position) {
         vehicle_info.kill = function() {
             $(".vehicle"+vehicle_info.uuid).remove();
             potentialobjects = [marker, marker_shadow, landing_marker, horizon_circle, horizon_circle_title, subhorizon_circle, subhorizon_circle_title, polyline];
-            if (map.hasLayer(vehicle_info["prediction_polyline"])) { 
-                map.removeLayer(vehicle_info["prediction_polyline"]);
+            if (vehicle_info["prediction_polyline"] && map.hasLayer(vehicle_info["prediction_polyline"][0])) { 
+                map.removeLayer(vehicle_info["prediction_polyline"][0]);
+                map.removeLayer(vehicle_info["prediction_polyline"][1]);
             }
-            if (map.hasLayer(vehicle_info["prediction_launch_polyline"])) { 
-                map.removeLayer(vehicle_info["prediction_launch_polyline"]);
+            if (vehicle_info["prediction_launch_polyline"] && map.hasLayer(vehicle_info["prediction_launch_polyline"][0])) { 
+                map.removeLayer(vehicle_info["prediction_launch_polyline"][0]);
+                map.removeLayer(vehicle_info["prediction_launch_polyline"][1]);
             }
             if (map.hasLayer(vehicle_info["prediction_target"])) { 
                 map.removeLayer(vehicle_info["prediction_target"]);
@@ -4640,7 +4636,7 @@ function updateRecoveryMarker(recovery) {
       html = "
"; html += "
"+recovery.serial+(recovery.recovered ? " Recovered" : " Not Recovered")+"
"; html += "
"; - html += "
 "+roundNumber(recovery.lat, 5) + ', ' + roundNumber(recovery.lon, 5)+"
"; + html += "
 "+format_coordinates(recovery.lat, recovery.lon, recovery.serial)+"
"; var imp = offline.get('opt_imperial'); var text_alt = Number((imp) ? Math.floor(3.2808399 * parseInt(recovery.alt)) : parseInt(recovery.alt)).toLocaleString("us"); @@ -4752,7 +4748,7 @@ function updateRecoveryPane(r){ html += "
"; html += "
"+r[i].serial+(r[i].recovered ? " Recovered by " : " Not Recovered by ")+r[i].recovered_by+"
"; - html += "
 "+roundNumber(lat, 5) + ', ' + roundNumber(lon, 5)+"
"; + html += "
 "+format_coordinates(lat, lon, r[i].serial)+"
"; var imp = offline.get('opt_imperial'); var text_alt = Number((imp) ? Math.floor(3.2808399 * parseInt(alt)) : parseInt(alt)).toLocaleString("us"); diff --git a/js/station.js b/js/station.js index 3a2f4a5..74f053c 100644 --- a/js/station.js +++ b/js/station.js @@ -179,7 +179,7 @@ function drawHistorical (data, station) { html = "
"; html += "
"+serial+" ("+time+")
"; html += "
"; - html += "
Last Position: "+roundNumber(landing.lat, 5) + ', ' + roundNumber(landing.lon, 5)+"
"; + html += "
Last Position: "+format_coordinates(landing.lat, landing.lon, serial)+"
"; var imp = offline.get('opt_imperial'); var text_alt = Number((imp) ? Math.floor(3.2808399 * parseInt(landing.alt)) : parseInt(landing.alt)).toLocaleString("us"); diff --git a/service-worker.js b/service-worker.js index fc7d456..6416051 100644 --- a/service-worker.js +++ b/service-worker.js @@ -1,59 +1,47 @@ self.addEventListener('install', function(event) { event.waitUntil( - caches.open("{VER}").then(function(cache) { + caches.open(document.body.dataset.version).then(function(cache) { return cache.addAll( [ - '/css/mobile.css', + '/css/base.css', + '/css/skeleton.css', + '/css/layout.css', + '/css/habitat-font.css', + '/css/main.css', '/css/leaflet.css', '/css/leaflet.fullscreen.css', + '/css/skewt.css', + '/js/skewt.js', + '/js/aws-sdk-2.1029.0.min.js', '/js/leaflet.js', '/js/Leaflet.fullscreen.min.js', '/js/L.Terminator.js', - '/js/mobile.js', + '/js/L.TileLayer.NoGap.js', + '/js/paho-mqtt.js', + '/js/jquery-1.12.4-min.js', + '/js/iscroll.js', + '/js/chasecar.lib.js', + '/js/tracker.js', + '/js/app.js', + '/js/colour-map.js', + '/js/xdata.js', + '/js/station.js', + '/js/format.js', '/js/rbush.js', - '/js/leaflet.canvas-markers.js', '/js/pwa.js', - '/js/init_plot.js', - '/img/markers/antenna-green.png', - '/img/markers/balloon-blue.png', - '/img/markers/balloon-cyan.png', - '/img/markers/balloon-green.png', - '/img/markers/balloon-orange.png', - '/img/markers/balloon-purple.png', - '/img/markers/balloon-red.png', - '/img/markers/balloon-yellow.png', - '/img/markers/car-blue.png', - '/img/markers/car-green.png', - '/img/markers/car-red.png', - '/img/markers/car-yellow.png', - '/img/markers/parachute-yellow.png', - '/img/markers/parachute-blue.png', - '/img/markers/parachute-cyan.png', - '/img/markers/parachute-green.png', - '/img/markers/parachute-orange.png', - '/img/markers/parachute-purple.png', - '/img/markers/parachute-red.png', - '/img/markers/payload-blue.png', - '/img/markers/payload-cyan.png', - '/img/markers/payload-green.png', + '/js/_jquery.flot.js', + '/js/plot_config.js', + '/img/markers/balloon.svg', + '/img/markers/car.svg', + '/img/markers/parachute.svg', + '/img/markers/payload.svg', '/img/markers/payload-not-recovered.png', - '/img/markers/payload-orange.png', - '/img/markers/payload-purple.png', '/img/markers/payload-recovered.png', - '/img/markers/payload-red.png', - '/img/markers/payload-yellow.png', - '/img/markers/target-blue.png', - '/img/markers/target-cyan.png', - '/img/markers/target-green.png', - '/img/markers/target-orange.png', - '/img/markers/target-purple.png', - '/img/markers/target-red.png', - '/img/markers/target-yellow.png', + '/img/markers/target.svg', '/img/markers/shadow.png', '/img/markers/balloon-pop.png', '/img/hab-spinner.gif', - '/img/marker-you.gif', - '/img/sondehub_logo.gif', + '/img/sondehub_logo.png', '/favicon.ico', '/font/HabitatFont.woff', '/font/Roboto-regular.woff', diff --git a/tools/pngout.exe b/tools/pngout.exe deleted file mode 100755 index c72d567..0000000 Binary files a/tools/pngout.exe and /dev/null differ diff --git a/tools/yuicompressor-2.4.8.jar b/tools/yuicompressor-2.4.8.jar deleted file mode 100755 index a1cf0a0..0000000 Binary files a/tools/yuicompressor-2.4.8.jar and /dev/null differ