8c5680fd11
There is now a "blurred" status that does nothing.
148 lines
5.3 KiB
HTML
148 lines
5.3 KiB
HTML
<!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 {
|
|
position: fixed;
|
|
top: 0px;
|
|
left: 0px;
|
|
height: 100%;
|
|
width: 50%;
|
|
}
|
|
#right {
|
|
position: fixed;
|
|
width: 49%;
|
|
height: 98%;
|
|
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; }
|
|
</style>
|
|
|
|
<script type="text/javascript" src="utils.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="map"></div>
|
|
|
|
<div id="right">
|
|
<div class="tableFixHead">
|
|
<table>
|
|
<thead><tr>
|
|
<th>ID</th>
|
|
<th>Visible</th>
|
|
<th>Brouillé</th>
|
|
<th>Tracker</th>
|
|
<th>Npc</th>
|
|
<th>Last Update</th>
|
|
</tr></thead>
|
|
<tbody id="teamInfos">
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<input id="popup"/><button id="sendPopup">Send popup to all clients</button><br/>
|
|
<button id="genCode">Generate invisibility code</button><div id="code"></div>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// SETUP MAP
|
|
function makeCode() {
|
|
var result = '';
|
|
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
var charactersLength = characters.length;
|
|
for ( var i = 0; i < 10; i++ ) {
|
|
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
}
|
|
return result;
|
|
}
|
|
setup_map();
|
|
|
|
map.on("dblclick", function(data){
|
|
socket.emit("newTracker", {"position": [data.latlng.lat, data.latlng.lng]});
|
|
});
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// UPDATE MAP
|
|
|
|
socket = io({rejectUnauthorized: false, auth: {type:"Admin"}});
|
|
|
|
setup_socket_common();
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// INTERACTION
|
|
|
|
var equipes = {};
|
|
var info_table = document.getElementById("teamInfos");
|
|
|
|
function sendUpdate(id){
|
|
var state = {};
|
|
state.shown = document.getElementById(`${id}.shown`).checked;
|
|
state.blurred = document.getElementById(`${id}.blurred`).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 = `<td>${id}</td>`;
|
|
row += `<td><input type="checkbox"
|
|
id="${id}.shown"
|
|
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>`
|
|
row += `<td><input type="number" min=0 max=3
|
|
id="${id}.npc"
|
|
onchange="sendUpdate('${id}')" /></td>`
|
|
row += `<td id="${id}.time"></td>`
|
|
info_table.innerHTML = info_table.innerHTML + `<tr>${row}</tr>`
|
|
}
|
|
equipes[id] = data.state;
|
|
document.getElementById(`${id}.shown`).checked = data.state.shown;
|
|
document.getElementById(`${id}.blurred`).checked = data.state.blurred;
|
|
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});
|
|
});
|
|
|
|
document.querySelector('#genCode').addEventListener('click', function(){
|
|
var code = makeCode();
|
|
socket.emit('newCode', {"code":code});
|
|
document.getElementById("code").innerHTML = code;
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|