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/>
|
<div id="map"></div><br/>
|
||||||
|
|
||||||
<input id="popup"/><button id="sendPopup">Send popup to all clients</button><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">
|
<script type="text/javascript">
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
// SETUP MAP
|
// 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();
|
setup_map();
|
||||||
|
|
||||||
map.on("dblclick", function(data){
|
map.on("dblclick", function(data){
|
||||||
|
@ -74,10 +83,15 @@
|
||||||
|
|
||||||
document.querySelector('#sendPopup').addEventListener('click', function(){
|
document.querySelector('#sendPopup').addEventListener('click', function(){
|
||||||
const input = document.querySelector('#popup');
|
const input = document.querySelector('#popup');
|
||||||
|
|
||||||
socket.emit("popup", {"content": input.value});
|
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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
10
traque.js
10
traque.js
|
@ -20,14 +20,14 @@ Les messages à transmettre par le serveur :
|
||||||
// Textes d'interaction avec les conscrits
|
// Textes d'interaction avec les conscrits
|
||||||
var PWD_TRACKED = "tracked";
|
var PWD_TRACKED = "tracked";
|
||||||
var PWD_TRACKER = "tracker";
|
var PWD_TRACKER = "tracker";
|
||||||
var PWD_INVISIBLE = "invisible";
|
var MSG_BAD = "Code Incorrect";
|
||||||
var MSG_BAD = "La base n'a pas compris votre message...";
|
|
||||||
var MSG_TRACKED = "Vous êtes maintenant traqué.e.s !"
|
var MSG_TRACKED = "Vous êtes maintenant traqué.e.s !"
|
||||||
var MSG_TRACKER = "Vous pouvez maintenant traquer !";
|
var MSG_TRACKER = "Vous pouvez maintenant traquer !";
|
||||||
var MSG_INVISIBLE = "Les autres équipes ne peuvent plus vous voir !";
|
var MSG_INVISIBLE = "Les autres équipes ne peuvent plus vous voir !";
|
||||||
|
|
||||||
var equipes = [];
|
var equipes = [];
|
||||||
var admins = [];
|
var admins = [];
|
||||||
|
var invisi = {};
|
||||||
|
|
||||||
// require = include
|
// require = include
|
||||||
var http = require('https');//require('http');
|
var http = require('https');//require('http');
|
||||||
|
@ -118,7 +118,8 @@ io.sockets.on('connection', function(socket){
|
||||||
d.color = 1;
|
d.color = 1;
|
||||||
socket.emit('popup', {"content": MSG_TRACKER});
|
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;
|
d.color = -1;
|
||||||
socket.emit('popup', {"content": MSG_INVISIBLE});
|
socket.emit('popup', {"content": MSG_INVISIBLE});
|
||||||
} else {
|
} else {
|
||||||
|
@ -146,6 +147,9 @@ io.sockets.on('connection', function(socket){
|
||||||
for(i in equipes)
|
for(i in equipes)
|
||||||
equipes[i].emit('setName', {"id": socket.id, "name": d.name});
|
equipes[i].emit('setName', {"id": socket.id, "name": d.name});
|
||||||
});
|
});
|
||||||
|
socket.on('newCode', function(d){
|
||||||
|
invisi[d.code] = true;
|
||||||
|
});
|
||||||
socket.on("disconnect", function(_){
|
socket.on("disconnect", function(_){
|
||||||
console.log(socket.id + " disconnect");
|
console.log(socket.id + " disconnect");
|
||||||
socket.shown = false;
|
socket.shown = false;
|
||||||
|
|
Loading…
Reference in a new issue