Clean up API calls in JS

This commit is contained in:
30hours 2023-12-19 09:37:42 +00:00
parent 2eef96e3d9
commit 396a36bf90
4 changed files with 27 additions and 17 deletions

View file

@ -6,18 +6,20 @@ var range_x = [];
var range_y = []; var range_y = [];
// setup API // setup API
var urlTimestamp = ''; var urlTimestamp;
var urlDetection;
if (isLocalHost) { if (isLocalHost) {
urlTimestamp = '//' + host + ':3000/api/timestamp?timestamp=' + Date.now(); urlTimestamp = '//' + host + ':3000/api/timestamp';
} else { } else {
urlTimestamp = '//' + host + '/api/timestamp?timestamp=' + Date.now(); urlTimestamp = '//' + host + '/api/timestamp';
} }
var urlDetection = '';
if (isLocalHost) { if (isLocalHost) {
urlDetection = '//' + host + ':3000/stash/detection?timestamp=' + Date.now(); urlDetection = '//' + host + ':3000/stash/detection';
} else { } else {
urlDetection = '//' + host + '/stash/detection?timestamp=' + Date.now(); urlDetection = '//' + host + '/stash/detection';
} }
urlTimestamp = urlTimestamp + '?timestamp=' + Date.now();
urlDetection = urlDetection + '?timestamp=' + Date.now();
// setup plotly // setup plotly
var layout = { var layout = {

View file

@ -6,13 +6,13 @@ var range_x = [];
var range_y = []; var range_y = [];
// setup API // setup API
var urlTimestamp = ''; var urlTimestamp;
var urlDetection;
if (isLocalHost) { if (isLocalHost) {
urlTimestamp = '//' + host + ':3000/api/timestamp?timestamp='; urlTimestamp = '//' + host + ':3000/api/timestamp';
} else { } else {
urlTimestamp = '//' + host + '/api/timestamp?timestamp='; urlTimestamp = '//' + host + '/api/timestamp';
} }
var urlDetection = '';
if (isLocalHost) { if (isLocalHost) {
urlDetection = '//' + host + ':3000/api/detection'; urlDetection = '//' + host + ':3000/api/detection';
} else { } else {
@ -23,6 +23,9 @@ if (isLocalHost) {
} else { } else {
urlMap = '//' + host + urlMap; urlMap = '//' + host + urlMap;
} }
urlTimestamp = urlTimestamp + '?timestamp=' + Date.now();
urlDetection = urlDetection + '?timestamp=' + Date.now();
urlMap = urlMap + '?timestamp=' + Date.now();
// setup plotly // setup plotly
var layout = { var layout = {

View file

@ -6,7 +6,8 @@ var range_x = [];
var range_y = []; var range_y = [];
// setup API // setup API
var urlTimestamp = ''; var urlTimestamp;
var urlMap;
if (isLocalHost) { if (isLocalHost) {
urlTimestamp = '//' + host + ':3000/api/timestamp'; urlTimestamp = '//' + host + ':3000/api/timestamp';
} else { } else {
@ -17,6 +18,8 @@ if (isLocalHost) {
} else { } else {
urlMap = '//' + host + '/stash/iqdata'; urlMap = '//' + host + '/stash/iqdata';
} }
urlTimestamp = urlTimestamp + '?timestamp=' + Date.now();
urlMap = urlMap + '?timestamp=' + Date.now();
// setup plotly // setup plotly
var layout = { var layout = {

View file

@ -4,18 +4,20 @@ var host = window.location.hostname;
var isLocalHost = (host === "localhost" || host === "127.0.0.1" || host === "192.168.0.112"); var isLocalHost = (host === "localhost" || host === "127.0.0.1" || host === "192.168.0.112");
// setup API // setup API
var urlTimestamp = ''; var urlTimestamp;
var urlTiming;
if (isLocalHost) { if (isLocalHost) {
urlTimestamp = '//' + host + ':3000/api/timestamp?timestamp=' + Date.now(); urlTimestamp = '//' + host + ':3000/api/timestamp';
} else { } else {
urlTimestamp = '//' + host + '/api/timestamp?timestamp=' + Date.now(); urlTimestamp = '//' + host + '/api/timestamp';
} }
var urlDetection = '';
if (isLocalHost) { if (isLocalHost) {
urlDetection = '//' + host + ':3000/stash/detection?timestamp=' + Date.now(); urlTiming = '//' + host + ':3000/stash/timing';
} else { } else {
urlDetection = '//' + host + '/stash/timing?timestamp=' + Date.now(); urlTiming = '//' + host + '/stash/timing';
} }
urlTimestamp = urlTimestamp + '?timestamp=' + Date.now();
urlTiming = urlTiming + '?timestamp=' + Date.now();
// setup plotly // setup plotly
var layout = { var layout = {