traque/static/admin.html

167 lines
6.7 KiB
HTML
Raw Normal View History

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">
2023-06-11 13:44:11 +02:00
#map {
position: fixed;
top: 0px;
left: 0px;
height: 100%;
width: 50%;
}
#right {
position: fixed;
width: 49%;
height: 98%;
top: 1%;
right: 0.5%;
}
2023-06-13 18:14:49 +02:00
.vieux { color: DarkOrchid; }
2023-06-16 20:56:58 +02:00
.tableFixHead { overflow: auto; height: 60%; }
2023-06-11 15:19:03 +02:00
.tableFixHead thead th { position: sticky; top: 0; z-index: 1; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 16px; }
2023-06-13 18:14:49 +02:00
th { background: Grey; }
tr:nth-child(even) { background-color: Silver; }
2022-09-13 23:18:13 +02:00
</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>
2023-06-11 13:44:11 +02:00
<div id="map"></div>
2022-09-13 23:18:13 +02:00
2023-06-11 13:44:11 +02:00
<div id="right">
2023-06-11 15:19:03 +02:00
<div class="tableFixHead">
<table>
<thead><tr>
<th>ID</th>
2023-09-05 14:46:13 +02:00
<th>Mallette</th>
2023-06-16 20:56:58 +02:00
<th>Invisible</th>
<th>Brouillé</th>
2023-06-11 15:19:03 +02:00
<th>Tracker</th>
2023-06-16 20:56:58 +02:00
<th>Code Invisibilité</th>
<th>Code Broulliage</th>
2023-06-11 15:19:03 +02:00
<th>Npc</th>
<th>Last Update</th>
</tr></thead>
<tbody id="teamInfos">
</tbody>
</table>
</div>
2023-06-11 13:44:11 +02:00
<input id="popup"/><button id="sendPopup">Send popup to all clients</button><br/>
2023-09-11 21:14:52 +02:00
<br/>
<a href="https://dgnum.eu"><img src="/dgnum-logo.png" height=20px /></a><br/>
<span style="font-size: 0.8em">Merci à la <a href="https://dgnum.eu">Délégation Générale NUMérique de l'ENS</a>, qui héberge ce site.</span>
2023-06-11 13:44:11 +02:00
</div>
2022-09-13 23:18:13 +02:00
<script type="text/javascript">
//////////////////////////////////////////////////////////////////////////////
2022-09-14 10:52:29 +02:00
// SETUP MAP
setup_map();
2022-09-13 23:18:13 +02:00
map.on("dblclick", function(data){
socket.emit("newTracker", {"position": [data.latlng.lat, data.latlng.lng]});
});
2022-09-13 23:18:13 +02:00
//////////////////////////////////////////////////////////////////////////////
// UPDATE MAP
2023-09-05 14:46:13 +02:00
socket = io({rejectUnauthorized: false, auth: {type:"Admin"}});
2022-09-13 23:18:13 +02:00
2023-09-06 18:13:40 +02:00
setup_socket_common();
2022-09-13 23:18:13 +02:00
//////////////////////////////////////////////////////////////////////////////
// INTERACTION
2023-06-11 15:19:03 +02:00
var equipes = {};
var info_table = document.getElementById("teamInfos");
function sendUpdate(id){
var state = {};
2023-09-05 14:46:13 +02:00
state.mallette = document.getElementById(`${id}.mallette`).checked;
2023-06-16 20:56:58 +02:00
state.invisibility = document.getElementById(`${id}.invisibility`).checked;
state.blurred = document.getElementById(`${id}.blurred`).checked;
2023-06-11 15:19:03 +02:00
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)){
2023-06-13 18:14:49 +02:00
var row = `<td class="${data.vieux?"vieux":"conscrit"}">${id}</td>`;
2023-09-05 14:46:13 +02:00
row += `<td><input type="checkbox"
id="${id}.mallette"
onchange="sendUpdate('${id}')" /></td>`
row += `<td><input type="checkbox"
2023-06-16 20:56:58 +02:00
id="${id}.invisibility"
onchange="sendUpdate('${id}')" /></td>`
row += `<td><input type="checkbox"
id="${id}.blurred"
onchange="sendUpdate('${id}')" /></td>`
row += `<td><input type="checkbox"
id="${id}.tracker"
onchange="sendUpdate('${id}')" /></td>`
2023-06-16 21:17:58 +02:00
row += `<td><span id="${id}.code.invisi"></span>
2023-06-16 20:56:58 +02:00
<button onclick="socket.emit('newCode', {id:'${id}', code:'invisibility'})">
Add
</button>
</td>`;
2023-06-16 21:17:58 +02:00
row += `<td><span id="${id}.code.blurred"></span>
2023-06-16 20:56:58 +02:00
<button onclick="socket.emit('newCode', {id:'${id}', code:'blurred'})">
Add
</button>
</td>`;
2023-09-11 17:47:08 +02:00
row += `<td><input type="number" min=0 max=9 style="width: 40px"
2023-06-11 15:19:03 +02:00
id="${id}.npc"
onchange="sendUpdate('${id}')" /></td>`
2023-06-16 21:17:58 +02:00
row += `<td><span id="${id}.time"></span></td>`
2023-06-13 18:14:49 +02:00
info_table.innerHTML += `<tr>${row}</tr>`
for(i in equipes){
var equipe = equipes[i];
2023-09-05 14:46:13 +02:00
document.getElementById(`${i}.mallette`).checked = equipe.state.mallette;
2023-06-16 20:56:58 +02:00
document.getElementById(`${i}.invisibility`).checked = equipe.state.invisibility;
2023-06-13 18:14:49 +02:00
document.getElementById(`${i}.blurred`).checked = equipe.state.blurred;
document.getElementById(`${i}.tracker`).checked = equipe.state.tracker;
document.getElementById(`${i}.npc`).value = equipe.state.npc;
}
2023-06-11 15:19:03 +02:00
}
2023-06-13 18:14:49 +02:00
equipes[id] = data;
2023-09-05 14:46:13 +02:00
document.getElementById(`${id}.mallette`).checked = data.state.mallette;
2023-06-16 20:56:58 +02:00
document.getElementById(`${id}.invisibility`).checked = data.state.invisibility;
document.getElementById(`${id}.blurred`).checked = data.state.blurred;
2023-06-11 15:19:03 +02:00
document.getElementById(`${id}.tracker`).checked = data.state.tracker;
2023-06-16 20:56:58 +02:00
document.getElementById(`${id}.code.invisi`).innerHTML = data.codes.invisibility;
document.getElementById(`${id}.code.blurred`).innerHTML = data.codes.blurred;
2023-06-11 15:19:03 +02:00
document.getElementById(`${id}.npc`).value = data.state.npc;
var now = new Date();
document.getElementById(`${id}.time`).innerHTML =
`${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
});
2022-09-13 23:18:13 +02:00
document.querySelector('#sendPopup').addEventListener('click', function(){
const input = document.querySelector('#popup');
socket.emit("popup", {"content": input.value});
});
</script>
</body>
</html>