mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
feat: add shared observer location with opt-out
This commit is contained in:
@@ -17,10 +17,14 @@
|
||||
{% else %}
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
||||
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/responsive.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/satellite_dashboard.css') }}">
|
||||
</head>
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/responsive.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/satellite_dashboard.css') }}">
|
||||
<script>
|
||||
window.INTERCEPT_SHARED_OBSERVER_LOCATION = {{ shared_observer_location | tojson }};
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/core/observer-location.js') }}"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="grid-bg"></div>
|
||||
<div class="scanline"></div>
|
||||
@@ -313,16 +317,33 @@
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setupEmbeddedMode();
|
||||
initGroundMap();
|
||||
updateClock();
|
||||
setInterval(updateClock, 1000);
|
||||
setInterval(updateCountdown, 1000);
|
||||
setInterval(updateRealTimePositions, 5000);
|
||||
loadAgents();
|
||||
getLocation();
|
||||
});
|
||||
function applySharedObserverLocation() {
|
||||
if (window.ObserverLocation && ObserverLocation.isSharedEnabled()) {
|
||||
const shared = ObserverLocation.getShared();
|
||||
if (shared) {
|
||||
const latInput = document.getElementById('obsLat');
|
||||
const lonInput = document.getElementById('obsLon');
|
||||
if (latInput) latInput.value = shared.lat.toFixed(4);
|
||||
if (lonInput) lonInput.value = shared.lon.toFixed(4);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
setupEmbeddedMode();
|
||||
const usedShared = applySharedObserverLocation();
|
||||
initGroundMap();
|
||||
updateClock();
|
||||
setInterval(updateClock, 1000);
|
||||
setInterval(updateCountdown, 1000);
|
||||
setInterval(updateRealTimePositions, 5000);
|
||||
loadAgents();
|
||||
if (!usedShared) {
|
||||
getLocation();
|
||||
}
|
||||
});
|
||||
|
||||
async function loadAgents() {
|
||||
try {
|
||||
@@ -376,10 +397,13 @@
|
||||
|
||||
if (data.status === 'success' && data.result) {
|
||||
const agentStatus = data.result;
|
||||
if (agentStatus.gps_position) {
|
||||
const gps = agentStatus.gps_position;
|
||||
document.getElementById('obsLat').value = gps.lat.toFixed(4);
|
||||
document.getElementById('obsLon').value = gps.lon.toFixed(4);
|
||||
if (agentStatus.gps_position) {
|
||||
const gps = agentStatus.gps_position;
|
||||
document.getElementById('obsLat').value = gps.lat.toFixed(4);
|
||||
document.getElementById('obsLon').value = gps.lon.toFixed(4);
|
||||
if (window.ObserverLocation && ObserverLocation.isSharedEnabled()) {
|
||||
ObserverLocation.setShared({ lat: gps.lat, lon: gps.lon });
|
||||
}
|
||||
|
||||
// Update observer marker label
|
||||
const agent = agents.find(a => a.id == agentId);
|
||||
@@ -430,16 +454,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
function getLocation() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(pos => {
|
||||
document.getElementById('obsLat').value = pos.coords.latitude.toFixed(4);
|
||||
document.getElementById('obsLon').value = pos.coords.longitude.toFixed(4);
|
||||
calculatePasses();
|
||||
}, () => {
|
||||
calculatePasses();
|
||||
});
|
||||
} else {
|
||||
function getLocation() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(pos => {
|
||||
const lat = pos.coords.latitude;
|
||||
const lon = pos.coords.longitude;
|
||||
document.getElementById('obsLat').value = lat.toFixed(4);
|
||||
document.getElementById('obsLon').value = lon.toFixed(4);
|
||||
if (window.ObserverLocation && ObserverLocation.isSharedEnabled()) {
|
||||
ObserverLocation.setShared({ lat, lon });
|
||||
}
|
||||
calculatePasses();
|
||||
}, () => {
|
||||
calculatePasses();
|
||||
});
|
||||
} else {
|
||||
calculatePasses();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user