invisibility code generator
This commit is contained in:
parent
1e11255997
commit
7a397accb9
2 changed files with 23 additions and 5 deletions
|
@ -26,11 +26,20 @@
|
|||
<div id="map"></div><br/>
|
||||
|
||||
<input id="popup"/><button id="sendPopup">Send popup to all clients</button><br/>
|
||||
<button id="genCode">Generate invisibility code</button><div id="code"></div><br/>
|
||||
|
||||
<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){
|
||||
|
@ -74,10 +83,15 @@
|
|||
|
||||
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>
|
||||
|
|
10
traque.js
10
traque.js
|
@ -20,14 +20,14 @@ Les messages à transmettre par le serveur :
|
|||
// Textes d'interaction avec les conscrits
|
||||
var PWD_TRACKED = "tracked";
|
||||
var PWD_TRACKER = "tracker";
|
||||
var PWD_INVISIBLE = "invisible";
|
||||
var MSG_BAD = "La base n'a pas compris votre message...";
|
||||
var MSG_BAD = "Code Incorrect";
|
||||
var MSG_TRACKED = "Vous êtes maintenant traqué.e.s !"
|
||||
var MSG_TRACKER = "Vous pouvez maintenant traquer !";
|
||||
var MSG_INVISIBLE = "Les autres équipes ne peuvent plus vous voir !";
|
||||
|
||||
var equipes = [];
|
||||
var admins = [];
|
||||
var invisi = {};
|
||||
|
||||
// require = include
|
||||
var http = require('https');//require('http');
|
||||
|
@ -118,7 +118,8 @@ io.sockets.on('connection', function(socket){
|
|||
d.color = 1;
|
||||
socket.emit('popup', {"content": MSG_TRACKER});
|
||||
}
|
||||
else if(d.content == PWD_INVISIBLE){
|
||||
else if((d.content in invisi) && invisi[d.content]){
|
||||
invisi[d.content] = false;
|
||||
d.color = -1;
|
||||
socket.emit('popup', {"content": MSG_INVISIBLE});
|
||||
} else {
|
||||
|
@ -146,6 +147,9 @@ io.sockets.on('connection', function(socket){
|
|||
for(i in equipes)
|
||||
equipes[i].emit('setName', {"id": socket.id, "name": d.name});
|
||||
});
|
||||
socket.on('newCode', function(d){
|
||||
invisi[d.code] = true;
|
||||
});
|
||||
socket.on("disconnect", function(_){
|
||||
console.log(socket.id + " disconnect");
|
||||
socket.shown = false;
|
||||
|
|
Loading…
Reference in a new issue