From b10bbe1fa0b264fa4a237e97ac016223c447b690 Mon Sep 17 00:00:00 2001 From: gvanem Date: Thu, 30 Jan 2025 07:07:52 +0100 Subject: [PATCH] Updates from: https://github.com/wiedehopf/tar1090.git --- web_root-Tar1090/layers.js | 12 +++++ web_root-Tar1090/planeObject.js | 12 ++++- web_root-Tar1090/script.js | 95 +++++++++++++++++---------------- web_root-Tar1090/style.css | 6 +++ 4 files changed, 78 insertions(+), 47 deletions(-) diff --git a/web_root-Tar1090/layers.js b/web_root-Tar1090/layers.js index a2333d7..3b60946 100644 --- a/web_root-Tar1090/layers.js +++ b/web_root-Tar1090/layers.js @@ -61,6 +61,18 @@ function createBaseLayers() { })); } + if (0) { + let stylefunction = ol.stylefunction; + let openfreemap = new ol.layer.VectorTile({ + type: 'base', + name: 'openfreemap', + title: 'openfreemap', + }); + // ol-mapbox-style plugin packed in with ol ... (kinda ugly) + ol.applyStyle(openfreemap, "https://tiles.openfreemap.org/styles/liberty"); + world.push(openfreemap); + } + world.push(new ol.layer.Tile({ source: new ol.source.OSM({ maxZoom: 17, diff --git a/web_root-Tar1090/planeObject.js b/web_root-Tar1090/planeObject.js index e00f872..9375394 100644 --- a/web_root-Tar1090/planeObject.js +++ b/web_root-Tar1090/planeObject.js @@ -853,6 +853,11 @@ PlaneObject.prototype.updateIcon = function() { if (useRouteAPI && this.routeString) callsign += ' - ' + this.routeString; + if (!extendedLabels && this.type == "ais") { + // show registration instead for ships as callsign is less useful + callsign = this.registration; + } + const unknown = NBSP+NBSP+"?"+NBSP+NBSP; let alt; @@ -1984,7 +1989,10 @@ PlaneObject.prototype.updateLines = function() { const date = new Date(seg.ts * 1000); let refDate = showTrace ? traceDate : new Date(); if (replay) { refDate = replay.ts }; - if (getDay(refDate) == getDay(date)) { + if (useLocal && historic) { + timestamp1 = lDateString(date); + timestamp1 += '\n'; + } else if (getDay(refDate) == getDay(date)) { timestamp1 = ""; } else { if (useLocal) { @@ -2001,7 +2009,7 @@ PlaneObject.prototype.updateLines = function() { timestamp2 += zuluTime(date); } - if (traces_high_res) { + if (traces_high_res || debugTracks) { timestamp2 += '.' + (Math.floor((seg.ts*10)) % 10); } diff --git a/web_root-Tar1090/script.js b/web_root-Tar1090/script.js index 0adae20..a3348d3 100644 --- a/web_root-Tar1090/script.js +++ b/web_root-Tar1090/script.js @@ -100,7 +100,7 @@ let userScale = 1; let iconScale = 1; let labelScale = 1; let newWidth = lineWidth; -let SiteOverride = false; +let SiteOverride = (SiteLat != null && SiteLon != null); let onJumpInput = null; let labelFill = null; let blackFill = null; @@ -148,7 +148,6 @@ const renderBuffer = 60; let shareLink = ''; - let CenterLat = 0; let CenterLon = 0; let zoomLvl = 5; @@ -508,6 +507,7 @@ function afterFirstFetch() { func(); } + geoMag = geoMagFactory(cof2Obj()); db_load_type_cache().always(function() { @@ -712,13 +712,10 @@ function initialize() { trace_hist_only = true; if (receiverJson.json_trace_interval < 2) traces_high_res = true; - if (receiverJson.lat != null) { + if (receiverJson.lat != null && !SiteOverride) { //console.log("receiver.json lat: " + receiverJson.lat) SiteLat = receiverJson.lat; SiteLon = receiverJson.lon; - SitePosition = [SiteLon, SiteLat]; - DefaultCenterLat = receiverJson.lat; - DefaultCenterLon = receiverJson.lon; } if (receiverJson.jaeroTimeout) { jaeroTimeout = receiverJson.jaeroTimeout * 60; @@ -730,6 +727,13 @@ function initialize() { altitudeFilter = false; } } + + if (SiteLat && SiteLon) { + SitePosition = [SiteLon, SiteLat]; + DefaultCenterLat = SiteLat; + DefaultCenterLon = SiteLon; + } + configureReceiver = null; // Initialize stuff @@ -836,11 +840,9 @@ function initPage() { let lat = parseFloat(usp.get('SiteLat')); let lon = parseFloat(usp.get('SiteLon')); if (!isNaN(lat) && !isNaN(lon)) { - if (true || usp.has('SiteNosave')) { - SiteLat = CenterLat = DefaultCenterLat = lat; - SiteLon = CenterLon = DefaultCenterLon = lon; - SiteOverride = true; - } + SiteLat = CenterLat = DefaultCenterLat = lat; + SiteLon = CenterLon = DefaultCenterLon = lon; + SiteOverride = true; loStore['SiteLat'] = lat; loStore['SiteLon'] = lon; } @@ -1710,12 +1712,8 @@ jQuery('#selected_altitude_geom1') if (hideButtons) { - jQuery('#header_top').hide(); - jQuery('#header_side').hide(); - jQuery('#tabs').hide(); - jQuery('#filterButton').hide(); - jQuery('.ol-control').hide(); - jQuery('.ol-attribution').show(); + showHideButtons(); + runAfterLoad(showHideButtons); } } @@ -2054,14 +2052,17 @@ function setIntervalTimers() { } function updateDrones() { - let req = jQuery.ajax({ - url: droneJson, - dataType: 'json', - }); + let jsons = Array.isArray(droneJson) ? droneJson : [ droneJson ]; + for (let i in jsons) { + let req = jQuery.ajax({ + url: jsons[i], + dataType: 'json', + }); - req.done(function(data) { - handleDrones(data); - }); + req.done(function(data) { + handleDrones(data); + }); + } } function handleDrones(data) { @@ -2084,7 +2085,7 @@ function processDrone(drone, now, last) { plane = new PlaneObject(hex); } - let ac = {}; + let ac = drone; ac.type = 'other'; ac.t = 'DRON'; @@ -2640,6 +2641,25 @@ function initMapEarly() { }); } +function showHideButtons() { + if (hideButtons) { + jQuery('#header_top').hide(); + jQuery('#header_side').hide(); + jQuery('#splitter').hide(); + jQuery('#tabs').hide(); + jQuery('#filterButton').hide(); + jQuery('.ol-zoom').hide(); + jQuery('.layer-switcher').hide(); + } else { + jQuery('#header_top').show(); + jQuery('#header_side').show(); + jQuery('#splitter').show(); + jQuery('#tabs').show(); + jQuery('#filterButton').show(); + jQuery('.ol-zoom').show(); + jQuery('.layer-switcher').show(); + } +} // Initalizes the map and starts up our timers to call various functions function initMap() { @@ -2964,26 +2984,8 @@ function initMap() { resetMap(); break; case "H": - if (!hideButtons) { - jQuery('#header_top').hide(); - jQuery('#header_side').hide(); - jQuery('#splitter').hide(); - jQuery('#tabs').hide(); - jQuery('#filterButton').hide(); - jQuery('.ol-control').hide(); - jQuery('.ol-attribution').show(); - } else { - jQuery('#header_top').show(); - jQuery('#header_side').show(); - jQuery('#splitter').show(); - jQuery('#tabs').show(); - jQuery('#filterButton').show(); - jQuery('.ol-control').show(); - jQuery('#expand_sidebar_control').hide(); - toggles['sidebar_visible'].restore(); - TAR.altitudeChart.render(); - } hideButtons = !hideButtons; + showHideButtons(); break; case "f": toggleFollow(); @@ -6661,6 +6663,9 @@ function setLineWidth() { } let lastCallLocationChange = 0; function onLocationChange(position) { + if (SiteOverride) { + return; + } lastCallLocationChange = new Date().getTime(); changeCenter(); const moveMap = (Math.abs(SiteLat - CenterLat) < 0.000001 && Math.abs(SiteLon - CenterLon) < 0.000001); @@ -6829,7 +6834,7 @@ function initSitePos() { if (SitePosition) { TAR.planeMan.cols.sitedist.sort(); } else { - planeMan.sortAscending = false; + TAR.planeMan.sortAscending = false; TAR.planeMan.cols.altitude.sort(); } } diff --git a/web_root-Tar1090/style.css b/web_root-Tar1090/style.css index f8807c5..ffd4844 100644 --- a/web_root-Tar1090/style.css +++ b/web_root-Tar1090/style.css @@ -286,6 +286,12 @@ select { background-color: var(--ACCENT); color: #FFFFFF; cursor: pointer; + position: sticky; + top: 0; + z-index: 10; + box-shadow: + 0 -2px 2px -1px rgba(0, 0, 0, 0.5), + 0 2px 2px -1px rgba(0, 0, 0, 0.7); } .aircraft_table_header td { font-size: smaller;