From ecdcd7e5451288408b4b7e06b897e8be1b0be6d1 Mon Sep 17 00:00:00 2001 From: Sylvain Gay Date: Wed, 6 Sep 2023 18:13:40 +0200 Subject: [PATCH] fini self-icons --- static/admin.html | 2 +- static/tracking/conscrit.html | 2 +- static/tracking/vieux.html | 2 +- static/utils.js | 14 ++++++++++---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/static/admin.html b/static/admin.html index f303f1f..550a40c 100644 --- a/static/admin.html +++ b/static/admin.html @@ -83,7 +83,7 @@ socket = io({rejectUnauthorized: false, auth: {type:"Admin"}}); - setup_socket_common(-1); + setup_socket_common(); ////////////////////////////////////////////////////////////////////////////// // INTERACTION diff --git a/static/tracking/conscrit.html b/static/tracking/conscrit.html index a87c991..64d8127 100644 --- a/static/tracking/conscrit.html +++ b/static/tracking/conscrit.html @@ -45,7 +45,7 @@ id = "%ID"; // %ID will be replaced by the real id. socket = io({rejectUnauthorized: false, auth: {id: id, type:"conscrit"}}); - setup_socket_common(id); + setup_socket_common(); ////////////////////////////////////////////////////////////////////////////// // SETTINGS -- CODE diff --git a/static/tracking/vieux.html b/static/tracking/vieux.html index 239ad16..560e487 100644 --- a/static/tracking/vieux.html +++ b/static/tracking/vieux.html @@ -65,7 +65,7 @@ id = "%ID"; // %ID will be replaced by the real id. socket = io({rejectUnauthorized: false, auth: {id: id, type:"vieux"}}); - setup_socket_common(id); + setup_socket_common(); ////////////////////////////////////////////////////////////////////////////// // SETTINGS -- State diff --git a/static/utils.js b/static/utils.js index 1cfbc15..ed9f11a 100644 --- a/static/utils.js +++ b/static/utils.js @@ -72,13 +72,19 @@ function setup_socket_common(){ socket.on("moving", function(data){ console.log("moving", data); if(!(data.id in markers)){ - markers[data.id] = L.marker(data.position, {"icon": icons[data.color]}).addTo(map); - if(data.id == id) - markers[data.id].setZIndexOffset(10000); + if(data.id == id){ + markers[data.id] = L.marker(data.position, {"icon": self_icons[data.color]}).addTo(map); + markers[data.id].setZIndexOffset(10000); + } + else + markers[data.id] = L.marker(data.position, {"icon": icons[data.color]}).addTo(map); markers[data.id].bindPopup(data.id); } else{ markers[data.id].setLatLng(data.position); - markers[data.id].setIcon(icons[data.color]); + if(data.id == id) + markers[data.id].setIcon(self_icons[data.color]); + else + markers[data.id].setIcon(icons[data.color]); } });