diff --git a/html/controller/index.html b/html/controller/index.html index 24818c9..c30ee9f 100644 --- a/html/controller/index.html +++ b/html/controller/index.html @@ -63,10 +63,11 @@ + + diff --git a/html/display/detection/delay/index.html b/html/display/detection/delay/index.html index 18536d0..3c2ef75 100644 --- a/html/display/detection/delay/index.html +++ b/html/display/detection/delay/index.html @@ -25,5 +25,6 @@ xVariable = "timestamp"; yVariable = "delay"; + diff --git a/html/display/detection/doppler/index.html b/html/display/detection/doppler/index.html index a2d0fb7..d561787 100644 --- a/html/display/detection/doppler/index.html +++ b/html/display/detection/doppler/index.html @@ -25,5 +25,6 @@ xVariable = "timestamp"; yVariable = "doppler"; + diff --git a/html/display/map/index.html b/html/display/map/index.html index 99ac529..02ab703 100644 --- a/html/display/map/index.html +++ b/html/display/map/index.html @@ -22,5 +22,6 @@ + diff --git a/html/display/maxhold/index.html b/html/display/maxhold/index.html index fa42161..5f08382 100644 --- a/html/display/maxhold/index.html +++ b/html/display/maxhold/index.html @@ -22,5 +22,6 @@ + diff --git a/html/display/spectrum/index.html b/html/display/spectrum/index.html index 0c0191b..4eefcfc 100644 --- a/html/display/spectrum/index.html +++ b/html/display/spectrum/index.html @@ -21,6 +21,7 @@ + diff --git a/html/display/timing/index.html b/html/display/timing/index.html index c332809..aa831af 100644 --- a/html/display/timing/index.html +++ b/html/display/timing/index.html @@ -23,5 +23,6 @@ xTitle = "Timestamp"; yTitle = "Time (ms)"; + diff --git a/html/favicon.ico b/html/favicon.ico new file mode 120000 index 0000000..8a5cf41 --- /dev/null +++ b/html/favicon.ico @@ -0,0 +1 @@ +./favicon/favicon-32x32.png \ No newline at end of file diff --git a/html/favicon/favicon-128x128.png b/html/favicon/favicon-128x128.png new file mode 100644 index 0000000..8102ac5 Binary files /dev/null and b/html/favicon/favicon-128x128.png differ diff --git a/html/favicon/favicon-16x16.png b/html/favicon/favicon-16x16.png new file mode 100644 index 0000000..66547fc Binary files /dev/null and b/html/favicon/favicon-16x16.png differ diff --git a/html/favicon/favicon-196x196.png b/html/favicon/favicon-196x196.png new file mode 100644 index 0000000..46900d7 Binary files /dev/null and b/html/favicon/favicon-196x196.png differ diff --git a/html/favicon/favicon-32x32.png b/html/favicon/favicon-32x32.png new file mode 100644 index 0000000..8e206b3 Binary files /dev/null and b/html/favicon/favicon-32x32.png differ diff --git a/html/index.html b/html/index.html index e15a579..2f7c982 100644 --- a/html/index.html +++ b/html/index.html @@ -4,6 +4,10 @@ blah2 + + + + @@ -41,6 +45,7 @@ + diff --git a/html/js/common.js b/html/js/common.js new file mode 100644 index 0000000..02f5c1d --- /dev/null +++ b/html/js/common.js @@ -0,0 +1,18 @@ +function is_localhost(ip) { + + if (ip === 'localhost') { + return true; + } + + const localRanges = ['127.0.0.1', '192.168.0.0/16', '10.0.0.0/8', '172.16.0.0/12']; + + const ipToInt = ip => ip.split('.').reduce((acc, octet) => (acc << 8) + +octet, 0) >>> 0; + + return localRanges.some(range => { + const [rangeStart, rangeSize = 32] = range.split('/'); + const start = ipToInt(rangeStart); + const end = (start | (1 << (32 - +rangeSize))) >>> 0; + return ipToInt(ip) >= start && ipToInt(ip) <= end; + }); + +} \ No newline at end of file diff --git a/html/js/plot_detection.js b/html/js/plot_detection.js index c8d6c78..5c50625 100644 --- a/html/js/plot_detection.js +++ b/html/js/plot_detection.js @@ -1,7 +1,7 @@ -var timestamp = -1; +var timestamp; var nRows = 3; var host = window.location.hostname; -var isLocalHost = (host === "localhost" || host === "127.0.0.1" || host === "192.168.0.112"); +var isLocalHost = is_localhost(host); var range_x = []; var range_y = []; @@ -18,8 +18,6 @@ if (isLocalHost) { } else { urlDetection = '//' + host + '/stash/detection'; } -urlTimestamp = urlTimestamp + '?timestamp=' + Date.now(); -urlDetection = urlDetection + '?timestamp=' + Date.now(); // setup plotly var layout = { diff --git a/html/js/plot_map.js b/html/js/plot_map.js index 690d91e..a2e0517 100644 --- a/html/js/plot_map.js +++ b/html/js/plot_map.js @@ -1,7 +1,7 @@ var timestamp = -1; var nRows = 3; var host = window.location.hostname; -var isLocalHost = (host === "localhost" || host === "127.0.0.1" || host === "192.168.0.112"); +var isLocalHost = is_localhost(host); var range_x = []; var range_y = []; @@ -36,20 +36,17 @@ if (isLocalHost) { } else { urlConfig = '//' + host + '/api/config'; } -urlTimestamp = urlTimestamp + '?timestamp=' + Date.now(); -urlDetection = urlDetection + '?timestamp=' + Date.now(); -urlMap = urlMap + '?timestamp=' + Date.now(); // get truth flag var isTruth = false; -var configData = $.getJSON(urlConfig, function () { }) +$.getJSON(urlConfig, function () { }) .done(function (data_config) { if (data_config.truth.adsb.enabled === true) { isTruth = true; - var adsbLinkData = $.getJSON(urlAdsbLink, function () { }) + $.getJSON(urlAdsbLink, function () { }) .done(function (data) { urlAdsb = data.url; - if (window.location.protocol === 'https:') { + if (!is_localhost(new URL(urlAdsb).hostname)) { urlAdsb = urlAdsb.replace(/^http:/, 'https:'); } }) @@ -120,21 +117,21 @@ Plotly.newPlot('data', data, layout, config); var intervalId = window.setInterval(function () { // check if timestamp is updated - var timestampData = $.get(urlTimestamp, function () { }) + $.get(urlTimestamp, function () { }) .done(function (data) { if (timestamp != data) { timestamp = data; // get detection data (no detection lag) - var detectionData = $.getJSON(urlDetection, function () { }) + $.getJSON(urlDetection, function () { }) .done(function (data_detection) { detection = data_detection; }); // get ADS-B data if enabled in config if (isTruth) { - var adsbData = $.getJSON(urlAdsb, function () { }) + $.getJSON(urlAdsb, function () { }) .done(function (data_adsb) { adsb['delay'] = []; adsb['doppler'] = []; @@ -150,7 +147,7 @@ var intervalId = window.setInterval(function () { } // get new map data - var apiData = $.getJSON(urlMap, function () { }) + $.getJSON(urlMap, function () { }) .done(function (data) { // case draw new plot diff --git a/html/js/plot_spectrum.js b/html/js/plot_spectrum.js index bddde12..1839a6b 100644 --- a/html/js/plot_spectrum.js +++ b/html/js/plot_spectrum.js @@ -1,7 +1,7 @@ var timestamp = -1; var nRows = 3; var host = window.location.hostname; -var isLocalHost = (host === "localhost" || host === "127.0.0.1" || host === "192.168.0.112"); +var isLocalHost = is_localhost(host); var range_x = []; var range_y = []; @@ -18,8 +18,6 @@ if (isLocalHost) { } else { urlMap = '//' + host + '/stash/iqdata'; } -urlTimestamp = urlTimestamp + '?timestamp=' + Date.now(); -urlMap = urlMap + '?timestamp=' + Date.now(); // setup plotly var layout = { @@ -82,14 +80,14 @@ Plotly.newPlot('data', data, layout, config); var intervalId = window.setInterval(function () { // check if timestamp is updated - var timestampData = $.get(urlTimestamp, function () { }) + $.get(urlTimestamp, function () { }) .done(function (data) { if (timestamp != data) { timestamp = data; // get new map data - var apiData = $.getJSON(urlMap, function () { }) + $.getJSON(urlMap, function () { }) .done(function (data) { // case draw new plot diff --git a/html/js/plot_timing.js b/html/js/plot_timing.js index ede471a..2d503c4 100644 --- a/html/js/plot_timing.js +++ b/html/js/plot_timing.js @@ -1,7 +1,7 @@ var timestamp = -1; var nRows = 3; var host = window.location.hostname; -var isLocalHost = (host === "localhost" || host === "127.0.0.1" || host === "192.168.0.112"); +var isLocalHost = is_localhost(host); // setup API var urlTimestamp; @@ -16,8 +16,6 @@ if (isLocalHost) { } else { urlTiming = '//' + host + '/stash/timing'; } -urlTimestamp = urlTimestamp + '?timestamp=' + Date.now(); -urlTiming = urlTiming + '?timestamp=' + Date.now(); // setup plotly var layout = { @@ -89,14 +87,14 @@ Plotly.newPlot('data', data, layout, config); var intervalId = window.setInterval(function () { // check if timestamp is updated - var timestampData = $.get(urlTimestamp, function () { }) + $.get(urlTimestamp, function () { }) .done(function (data) { if (timestamp != data) { timestamp = data; // get new data - var apiData = $.getJSON(urlTiming, function () { }) + $.getJSON(urlTiming, function () { }) .done(function (data) { // case draw new plot