From 8974d442678f047a605178fafdf7ced8266ce5f7 Mon Sep 17 00:00:00 2001 From: Sylvain Gay Date: Sun, 11 Jun 2023 17:07:47 +0200 Subject: [PATCH] Issue #14 The URL `/tracking/nolog/my_id` yields a client which doesn't send log updates. --- static/tracking/conscrit.html | 2 +- static/tracking/vieux.html | 2 +- traque.js | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/static/tracking/conscrit.html b/static/tracking/conscrit.html index d949e29..f7d9128 100644 --- a/static/tracking/conscrit.html +++ b/static/tracking/conscrit.html @@ -61,7 +61,7 @@ ////////////////////////////////////////////////////////////////////////////// // GEOLOCALISATION - setup_geoLoc(); + if(%GPSLOG) setup_geoLoc(); diff --git a/static/tracking/vieux.html b/static/tracking/vieux.html index 4360a1c..9de3a53 100644 --- a/static/tracking/vieux.html +++ b/static/tracking/vieux.html @@ -89,7 +89,7 @@ ////////////////////////////////////////////////////////////////////////////// // GEOLOCALISATION - setup_geoLoc(); + if(%GPSLOG) setup_geoLoc(); diff --git a/traque.js b/traque.js index ff9962b..4746a1f 100644 --- a/traque.js +++ b/traque.js @@ -53,6 +53,11 @@ var server = http.createServer(option, function(req, res){ if(q.pathname.startsWith("/tracking/")){ id = q.pathname.substring("/tracking/".length); + gpslog = true; + if(id.startsWith("nolog/")){ + gpslog = false; + id = id.substring("nolog/".length); + } var end_path = ["conscrit.html", "vieux.html", "invalid.html"][config.validator(id)]; filename = "static/tracking/" + end_path; return fs.readFile(filename, 'utf8', function(err, data){ @@ -60,7 +65,7 @@ var server = http.createServer(option, function(req, res){ throw new Error("where " + end_path + " is !?"); res.writeHead(200, {'Content-Type': 'text/html'}); - res.write(data.replaceAll("%ID", id)); + res.write(data.replaceAll("%ID", id).replaceAll("%GPSLOG", gpslog)); return res.end(); }); }