diff --git a/static/admin.html b/static/admin.html index 1745355..bcd61d9 100644 --- a/static/admin.html +++ b/static/admin.html @@ -31,6 +31,11 @@ top: 1%; right: 0.5%; } + .tableFixHead { overflow: auto; height: 40%; } + .tableFixHead thead th { position: sticky; top: 0; z-index: 1; } + table { border-collapse: collapse; width: 100%; } + th, td { padding: 8px 16px; } + th { background:#eee; } @@ -39,6 +44,20 @@
@@ -71,6 +90,42 @@ ////////////////////////////////////////////////////////////////////////////// // INTERACTION + var equipes = {}; + var info_table = document.getElementById("teamInfos"); + + function sendUpdate(id){ + var state = {}; + state.shown = document.getElementById(`${id}.shown`).checked; + state.tracker = document.getElementById(`${id}.tracker`).checked; + state.npc = document.getElementById(`${id}.npc`).value; + socket.emit('setState', { id: id, state: state }); + } + + socket.on('update', function(data){ + var id = data.id; + if(!(id in equipes)){ + var row = `${id}`; + row = row + `` + row = row + `` + row = row + `` + row = row + `` + info_table.innerHTML = info_table.innerHTML + `${row}` + } + equipes[id] = data.state; + document.getElementById(`${id}.shown`).checked = data.state.shown; + document.getElementById(`${id}.tracker`).checked = data.state.tracker; + document.getElementById(`${id}.npc`).value = data.state.npc; + var now = new Date(); + document.getElementById(`${id}.time`).innerHTML = + `${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`; + }); + document.querySelector('#sendPopup').addEventListener('click', function(){ const input = document.querySelector('#popup'); socket.emit("popup", {"content": input.value}); diff --git a/static/utils.js b/static/utils.js index fefd1fd..da2ec2a 100644 --- a/static/utils.js +++ b/static/utils.js @@ -56,13 +56,11 @@ function setup_socket_common(){ console.log("moving", data); if(!(data.id in markers)){ markers[data.id] = L.marker(data.position, {"icon": icons[data.color]}).addTo(map); - markers[data.id].color = data.color; //do we really need to store this ? if(data.id == id) markers[data.id].setZIndexOffset(10000); markers[data.id].bindPopup(data.id); } else{ markers[data.id].setLatLng(data.position); - markers[data.id].color = data.color; markers[data.id].setIcon(icons[data.color]); } }); diff --git a/traque.js b/traque.js index c25f248..ff9962b 100644 --- a/traque.js +++ b/traque.js @@ -161,6 +161,7 @@ function emit_update(team_id) { tracking.except(team_id).emit('moving', apparent_info(equipe)); // the team and the admins always have the real informations admin.to(team_id).emit('moving', {"id": team_id, "color": color(equipe), "position": equipe.pos}); + admin.emit('update', equipe); } // produces a team object populated with default values @@ -248,9 +249,15 @@ io.on('connection', function(socket){ io.emit('newTracker', d); }); + socket.on('setState', function(d){ + equipes[d.id].state = d.state; + emit_update(d.id);//TODO update vieux + }); + for(i in equipes){ var equipe = equipes[i]; socket.emit('moving', {"id": equipe.id, "color": color(equipe), "position": equipe.pos}); + socket.emit('update', equipe); } }