2024-06-10 09:43:35 +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>
|
|
|
|
|
|
|
|
<style type="text/css">
|
|
|
|
#map {
|
|
|
|
position: fixed;
|
|
|
|
top: 0px;
|
|
|
|
left: 0px;
|
|
|
|
height: 100%;
|
|
|
|
width: 50%;
|
|
|
|
}
|
|
|
|
#right {
|
|
|
|
position: fixed;
|
|
|
|
width: 49%;
|
|
|
|
height: 98%;
|
|
|
|
top: 1%;
|
|
|
|
right: 0.5%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.vieux { color: DarkOrchid; }
|
|
|
|
.code_count { width: 90%; }
|
|
|
|
|
|
|
|
.tableFixHead { overflow: auto; height: 60%; }
|
|
|
|
.tableFixHead thead th { position: sticky; top: 0; z-index: 1; }
|
|
|
|
table { border-collapse: collapse; width: 100%; }
|
|
|
|
th, td { padding: 8px 16px; }
|
|
|
|
th { background: Grey; }
|
|
|
|
tr:nth-child(even) { background-color: Silver; }
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="utils.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="map"></div>
|
|
|
|
|
2024-06-17 09:51:44 +02:00
|
|
|
<div id="right">
|
|
|
|
<div class="tableFixHead">
|
2024-09-06 12:39:22 +02:00
|
|
|
<table id="teamTable">
|
2024-06-17 09:51:44 +02:00
|
|
|
<thead><tr>
|
2024-09-06 12:39:22 +02:00
|
|
|
<th onclick="sortTeams(0)">Nom</th>
|
2024-09-11 14:50:47 +02:00
|
|
|
<th>Last Update</th>
|
2024-06-17 09:51:44 +02:00
|
|
|
<th>Mallette</th>
|
|
|
|
<th>Tracker</th>
|
|
|
|
<th>Invisible</th>
|
|
|
|
<th>Brouillé</th>
|
|
|
|
<th>Code Invisibilité</th>
|
|
|
|
<th>Code Brouillage</th>
|
|
|
|
<th>Couleur</th>
|
|
|
|
</tr></thead>
|
|
|
|
<tbody id="teamInfos">
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
2024-06-10 09:43:35 +02:00
|
|
|
|
2024-06-17 09:51:44 +02:00
|
|
|
<input id="popup"/><button id="sendPopup">Send popup to all clients</button><br/>
|
|
|
|
<br/>
|
|
|
|
<a href="https://dgnum.eu"><img src="/dgnum-logo.png" height=50px /></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>
|
|
|
|
</div>
|
2024-06-10 09:43:35 +02:00
|
|
|
|
2024-09-06 12:39:22 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
// from https://www.w3schools.com/howto/howto_js_sort_table.asp
|
|
|
|
function sortTeams(n) {
|
|
|
|
var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0;
|
|
|
|
table = document.getElementById("teamTable");
|
|
|
|
switching = true;
|
|
|
|
// Set the sorting direction to ascending:
|
|
|
|
dir = "asc";
|
|
|
|
/* Make a loop that will continue until
|
|
|
|
no switching has been done: */
|
|
|
|
while (switching) {
|
|
|
|
// Start by saying: no switching is done:
|
|
|
|
switching = false;
|
|
|
|
rows = table.rows;
|
|
|
|
/* Loop through all table rows (except the
|
|
|
|
first, which contains table headers): */
|
|
|
|
for (i = 1; i < (rows.length - 1); i++) {
|
|
|
|
// Start by saying there should be no switching:
|
|
|
|
shouldSwitch = false;
|
|
|
|
/* Get the two elements you want to compare,
|
|
|
|
one from current row and one from the next: */
|
|
|
|
x = rows[i].getElementsByTagName("TD")[n];
|
|
|
|
y = rows[i + 1].getElementsByTagName("TD")[n];
|
|
|
|
/* Check if the two rows should switch place,
|
|
|
|
based on the direction, asc or desc: */
|
|
|
|
if (dir == "asc") {
|
|
|
|
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
|
|
|
|
// If so, mark as a switch and break the loop:
|
|
|
|
shouldSwitch = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (dir == "desc") {
|
|
|
|
if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) {
|
|
|
|
// If so, mark as a switch and break the loop:
|
|
|
|
shouldSwitch = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (shouldSwitch) {
|
|
|
|
/* If a switch has been marked, make the switch
|
|
|
|
and mark that a switch has been done: */
|
|
|
|
rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
|
|
|
|
switching = true;
|
|
|
|
// Each time a switch is done, increase this count by 1:
|
|
|
|
switchcount ++;
|
|
|
|
} else {
|
|
|
|
/* If no switching has been done AND the direction is "asc",
|
|
|
|
set the direction to "desc" and run the while loop again. */
|
|
|
|
if (switchcount == 0 && dir == "asc") {
|
|
|
|
dir = "desc";
|
|
|
|
switching = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2024-06-10 09:43:35 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
setup_map();
|
|
|
|
|
|
|
|
// map.on("dblclick", function(data){
|
|
|
|
// socket.emit("newTracker", {"position": [data.latlng.lat, data.latlng.lng]});
|
|
|
|
// });
|
|
|
|
|
|
|
|
var equipes = {};
|
|
|
|
var equipes_markers = {};
|
|
|
|
var info_table = document.getElementById("teamInfos");
|
2024-09-06 12:58:38 +02:00
|
|
|
var bigTeam = "";
|
2024-06-10 09:43:35 +02:00
|
|
|
|
|
|
|
function show_update(id){
|
|
|
|
var equipe = equipes[id];
|
|
|
|
var state = equipe.state;
|
|
|
|
if("Vieux" in state){
|
|
|
|
state = state.Vieux;
|
|
|
|
document.getElementById(`${id}.invisibility`).checked = state.invisible;
|
|
|
|
document.getElementById(`${id}.color`).value = state.color;
|
|
|
|
} else {
|
|
|
|
state = state.Conscrit;
|
|
|
|
document.getElementById(`${id}.mallette`).checked = state.mallette;
|
|
|
|
document.getElementById(`${id}.invisibility`).checked = state.invisible;
|
|
|
|
document.getElementById(`${id}.blurred`).checked = state.blurred;
|
|
|
|
document.getElementById(`${id}.tracker`).checked = state.captured;
|
|
|
|
document.getElementById(`${id}.bonus.invisi`).value = state.invisibility_codes;
|
|
|
|
document.getElementById(`${id}.bonus.blurred`).value = state.blur_codes;
|
|
|
|
}
|
2024-09-11 14:50:47 +02:00
|
|
|
document.getElementById(`${id}.elapsed`).innerHTML = equipe.last_pos.secs + " sec";
|
2024-06-10 09:43:35 +02:00
|
|
|
equipes_markers[id].setLatLng(equipe.pos);
|
2024-09-06 12:58:38 +02:00
|
|
|
equipes_markers[id].setIcon((id == bigTeam ? big_icons : icons)[equipe.color]);
|
2024-06-10 09:43:35 +02:00
|
|
|
}
|
|
|
|
|
2024-09-06 12:58:38 +02:00
|
|
|
function over(id){
|
|
|
|
bigTeam = id;
|
|
|
|
show_update(id);
|
|
|
|
};
|
|
|
|
function leave(id){
|
|
|
|
bigTeam = "";
|
|
|
|
show_update(id);
|
|
|
|
};
|
|
|
|
|
2024-06-10 09:43:35 +02:00
|
|
|
evtSource = new EventSource("/admin/events?tok={{tok}}");
|
|
|
|
function update(data) {
|
|
|
|
{{#if dbg}}console.log(data);{{/if}}
|
|
|
|
var id = data.id;
|
|
|
|
if(!(id in equipes)){
|
|
|
|
var row = "";
|
|
|
|
if("Vieux" in data.state){
|
|
|
|
row = `<td class="vieux">${data.name}</td>`;
|
2024-09-11 14:50:47 +02:00
|
|
|
row += `<td><span id="${id}.elapsed"></span></td>`;
|
2024-06-10 09:43:35 +02:00
|
|
|
row += `<td></td>`;
|
|
|
|
row += `<td></td>`;
|
|
|
|
row += `<td><input type="checkbox"
|
|
|
|
id="${id}.invisibility"
|
|
|
|
onchange="modifyVieux('${id}')" /></td>`;
|
|
|
|
row += `<td></td>`;
|
|
|
|
row += `<td></td>`;
|
|
|
|
row += `<td></td>`;
|
|
|
|
row += `<td><select id="${id}.color"
|
|
|
|
onchange="modifyVieux('${id}')" >
|
|
|
|
<option value=1>1- Tracker</option>
|
|
|
|
<option value=3>3- <img src="/icons/3.png" height=15px></option>
|
|
|
|
<option value=4>4- <img src="/icons/4.png" height=15px></option>
|
|
|
|
<option value=5>5- <img src="/icons/5.png" height=15px></option>
|
|
|
|
<option value=6>6- <img src="/icons/6.png" height=15px></option>
|
|
|
|
<option value=7>7- <img src="/icons/7.png" height=15px></option>
|
|
|
|
<option value=8>8- <img src="/icons/8.png" height=15px></option>
|
|
|
|
<option value=9>9- <img src="/icons/9.png" height=15px></option>
|
|
|
|
<option value=10>10- <img src="/icons/10.png" height=15px></option>
|
|
|
|
<option value=11>11- <img src="/icons/11.png" height=15px></option>
|
|
|
|
</select></td>`;
|
|
|
|
} else {
|
|
|
|
row = `<td class="conscrit">${data.name}</td>`;
|
2024-09-11 14:50:47 +02:00
|
|
|
row += `<td><span id="${id}.elapsed"></span></td>`;
|
2024-06-10 09:43:35 +02:00
|
|
|
row += `<td><input type="checkbox"
|
|
|
|
id="${id}.mallette"
|
|
|
|
onchange="modifyConscrit('${id}')" /></td>`
|
|
|
|
row += `<td><input type="checkbox"
|
|
|
|
id="${id}.tracker"
|
|
|
|
onchange="modifyConscrit('${id}')" /></td>`
|
|
|
|
row += `<td><input type="checkbox"
|
|
|
|
id="${id}.invisibility"
|
|
|
|
onchange="modifyConscrit('${id}')" /></td>`;
|
|
|
|
row += `<td><input type="checkbox"
|
|
|
|
id="${id}.blurred"
|
|
|
|
onchange="modifyConscrit('${id}')" /></td>`
|
|
|
|
row += `<td><input type="number" min="0"
|
|
|
|
id="${id}.bonus.invisi"
|
|
|
|
class="code_count"
|
|
|
|
onchange="modifyConscrit('${id}')" />
|
|
|
|
</td>`;
|
|
|
|
row += `<td><input type="number" min="0"
|
|
|
|
id="${id}.bonus.blurred"
|
|
|
|
class="code_count"
|
|
|
|
onchange="modifyConscrit('${id}')" />
|
|
|
|
</td>`;
|
|
|
|
row += `<td></td>`;
|
|
|
|
}
|
2024-09-06 12:58:38 +02:00
|
|
|
info_table.innerHTML += `<tr onmouseover="over('${id}')" onmouseout="leave('${id}')">${row}</tr>`
|
2024-06-10 09:43:35 +02:00
|
|
|
equipes[id] = data;
|
|
|
|
equipes_markers[id] = L.marker([0,0], {"icon": icons[0] }).addTo(map);
|
|
|
|
equipes_markers[id].bindPopup(data.name);
|
|
|
|
setTimeout(function (){
|
|
|
|
for(i in equipes){
|
|
|
|
show_update(i);
|
|
|
|
}
|
|
|
|
}, 10);
|
|
|
|
} else {
|
|
|
|
equipes[id] = data;
|
|
|
|
show_update(id);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
evtSource.addEventListener("update", (event) => {
|
|
|
|
data = JSON.parse(event.data);
|
|
|
|
update(data);
|
|
|
|
});
|
|
|
|
evtSource.addEventListener("full_update", (event) => {
|
|
|
|
data = JSON.parse(event.data);
|
2024-09-11 14:50:47 +02:00
|
|
|
// info_table.innerHTML = "";
|
|
|
|
// equipes = {};
|
|
|
|
// for(i in equipes_markers){
|
|
|
|
// equipes_markers[i].remove();
|
|
|
|
// }
|
|
|
|
// equipes_markers = {};
|
2024-06-10 09:43:35 +02:00
|
|
|
for (tracked of data) {
|
|
|
|
update(tracked);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function modifyVieux(id){
|
|
|
|
state = {
|
|
|
|
Vieux: {
|
|
|
|
invisible: document.getElementById(`${id}.invisibility`).checked,
|
|
|
|
color: document.getElementById(`${id}.color`).value - 0,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
fetch(`/admin/${id}?tok={{tok}}`, {
|
|
|
|
method: "PATCH",
|
|
|
|
body: JSON.stringify(state)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function modifyConscrit(id){
|
|
|
|
state = {
|
|
|
|
Conscrit: {
|
|
|
|
mallette: document.getElementById(`${id}.mallette`).checked,
|
|
|
|
invisible: document.getElementById(`${id}.invisibility`).checked,
|
|
|
|
blurred: document.getElementById(`${id}.blurred`).checked,
|
|
|
|
captured: document.getElementById(`${id}.tracker`).checked,
|
|
|
|
invisibility_codes: document.getElementById(`${id}.bonus.invisi`).value - 0,
|
|
|
|
blur_codes: document.getElementById(`${id}.bonus.blurred`).value - 0,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
fetch(`/admin/${id}?tok={{tok}}`, {
|
|
|
|
method: "PATCH",
|
|
|
|
body: JSON.stringify(state)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|