2022-09-13 23:18:13 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<title>Traque | Client admin</title>
|
|
|
|
|
|
|
|
<!-- LEAFLET INCLUDE -->
|
|
|
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css"
|
|
|
|
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ=="
|
|
|
|
crossorigin=""/>
|
|
|
|
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js"
|
|
|
|
integrity="sha512-BB3hKbKWOc9Ez/TAwyWxNXeoV9c1v6FIeYiBieIWkpLjauysF18NzgR1MBNBXf8/KABdlkX68nAhlwcDFLGPCQ=="
|
|
|
|
crossorigin=""></script>
|
|
|
|
|
|
|
|
<!-- SOCKET.IO INCLUDE -->
|
|
|
|
<script src="/socket.io/socket.io.js"></script>
|
|
|
|
|
|
|
|
<style type="text/css">
|
|
|
|
#map { height: 500px; }
|
|
|
|
</style>
|
2022-09-14 10:52:29 +02:00
|
|
|
|
|
|
|
<script type="text/javascript" src="utils.js"></script>
|
2022-09-13 23:18:13 +02:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="map"></div><br/>
|
|
|
|
|
|
|
|
<input id="popup"/><button id="sendPopup">Send popup to all clients</button><br/>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2022-09-14 10:52:29 +02:00
|
|
|
// SETUP MAP
|
2022-09-13 23:18:13 +02:00
|
|
|
|
2022-09-14 10:52:29 +02:00
|
|
|
setup_map();
|
2022-09-13 23:18:13 +02:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// UPDATE MAP
|
|
|
|
|
|
|
|
socket.on("yourId", function(data){
|
|
|
|
console.log("yourId", data);
|
|
|
|
id = data.id;
|
|
|
|
if(!(id in colors))
|
|
|
|
colors[id] = 0;
|
|
|
|
if(id in markers)
|
|
|
|
markers[id].setIcon(self_icons[colors[id]]);
|
|
|
|
|
|
|
|
socket.emit("admin");
|
|
|
|
});
|
|
|
|
|
|
|
|
socket.on("changeColor", function(data){
|
|
|
|
console.log("changeColor", data);
|
|
|
|
if(data.id in colors && colors[data.id] == -1 && data.id in markers)
|
|
|
|
markers[data.id].addTo(map);
|
|
|
|
colors[data.id] = data.color;
|
|
|
|
if(data.id in markers){
|
|
|
|
if(data.id == id)
|
|
|
|
markers[data.id].setOpacity(0);
|
|
|
|
else
|
|
|
|
if(data.color == -1)
|
2022-09-14 14:14:52 +02:00
|
|
|
markers[data.id].setIcon(self_invisible);
|
2022-09-13 23:18:13 +02:00
|
|
|
else
|
|
|
|
markers[data.id].setIcon(icons[data.color]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-09-14 10:52:29 +02:00
|
|
|
setup_socket_common();
|
2022-09-13 23:18:13 +02:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// INTERACTION
|
|
|
|
|
|
|
|
document.querySelector('#sendPopup').addEventListener('click', function(){
|
|
|
|
const input = document.querySelector('#popup');
|
|
|
|
|
|
|
|
socket.emit("popup", {"content": input.value});
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|