Un jour je serais le meilleur dresseur
This commit is contained in:
parent
fd1fb9736a
commit
7e97165435
4 changed files with 143 additions and 60 deletions
17
index.js
17
index.js
|
@ -620,23 +620,6 @@ fastify.post('/isGolden', async (request, reply) => {
|
|||
}
|
||||
})
|
||||
|
||||
fastify.get('/lastActivity', async (request, reply) => {
|
||||
let curr_date = new Date()
|
||||
for(acti in ActivityData) {
|
||||
if(acti.type == "event" && curr_date < acti.start) {
|
||||
return {
|
||||
success: true,
|
||||
activity: acti
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
why: "No next activity"
|
||||
}
|
||||
})
|
||||
|
||||
function saveData(path, data) {
|
||||
fs.writeFileSync(path, JSON.stringify(data));
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ a:hover {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
#spacer {
|
||||
.spacer {
|
||||
padding: 1px;
|
||||
margin: 30px 0 30px 0;
|
||||
background-color: #00000054;
|
||||
|
@ -149,7 +149,7 @@ a:hover {
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.login-form-control {
|
||||
.form-control {
|
||||
width: 100%;
|
||||
border: none;
|
||||
border-bottom: 1px solid #d75b00;
|
||||
|
@ -158,7 +158,7 @@ a:hover {
|
|||
padding: 5px;
|
||||
}
|
||||
|
||||
.login-form-control:focus {
|
||||
.form-control:focus {
|
||||
outline: none;
|
||||
border-bottom: 2px solid #923e01;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ button[type="submit"]:hover {
|
|||
border-left: 3px solid black;
|
||||
}
|
||||
|
||||
.activity-uid, .prank-uid, .prank-date, .treasure-uid, .treasure-date {
|
||||
.activity-uid, .prank-uid, .prank-date, .treasure-uid, .treasure-date, #activite-place {
|
||||
color: #00000078;
|
||||
margin-top: 5px;
|
||||
font-size: 12px;
|
||||
|
@ -284,7 +284,7 @@ button[type="submit"]:hover {
|
|||
#logo > img {
|
||||
width: 150px;
|
||||
}
|
||||
#spacer {
|
||||
.spacer {
|
||||
display: none;
|
||||
}
|
||||
.row-section {
|
||||
|
|
|
@ -38,17 +38,18 @@
|
|||
</div>
|
||||
<div class="column-section">
|
||||
<h1>Prochaine activité</h1>
|
||||
<span id="timer">00:00:10</span>
|
||||
<h2 id="active-title">Mongolfière</h2>
|
||||
<p id="activite-desc">Lorem ipsum dolor sit, amet consectetur adipisicing elit. Dicta tenetur tempora similique. A id esse expedita atque dolor eum itaque fugiat enim nisi dicta. Architecto mollitia quasi sed voluptatibus? Veniam.</p>
|
||||
<span id="timer">2 jours 00:00:10</span>
|
||||
<h2 id="activite-title"></h2>
|
||||
<p id="activite-desc"></p>
|
||||
<p id="activite-place"></p>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row-section">
|
||||
<div class="column-section">
|
||||
<h1>Planning des activité</h1>
|
||||
<h1>Planning des activités</h1>
|
||||
<img src="img/schedule.png" id="schedule" alt="Planning des activité" srcset="">
|
||||
</div>
|
||||
<div id="spacer" class="column-section"></div>
|
||||
<div class="sapcer column-section"></div>
|
||||
<div class="column-section">
|
||||
<h1>Ordre de mission</h1>
|
||||
<a id="prank-button">
|
||||
|
@ -95,10 +96,10 @@
|
|||
<div class="column-section">
|
||||
<div id="login-form">
|
||||
<div class="form-group">
|
||||
<input type="text" class="login-form-control" placeholder="Nom d'espion" name="login" id="login"/>
|
||||
<input type="text" class="form-control" placeholder="Nom d'espion" name="login" id="login"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="password" class="login-form-control" placeholder="Mot de passe secret" name="password" id="password" />
|
||||
<input type="password" class="form-control" placeholder="Mot de passe secret" name="password" id="password" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary" id="login-button">Se connecter</button>
|
||||
|
@ -110,7 +111,7 @@
|
|||
</div>
|
||||
<hr/>
|
||||
<div class="row banner">
|
||||
<h2>Notice de l'espion</h2>
|
||||
<h2>Notice pour l'espion</h2>
|
||||
<p id="notice-espion">
|
||||
Seul les espions reconnus par le Rézo pourrons se connecter pour jouer des tours à leurs camarrades.
|
||||
Si tu n'es pas encore un espion reconnu, tu peux le devenir <a href="https://re2o.rezo-rm.fr/users/new_user" target="_blank">ici</a>.
|
||||
|
@ -118,8 +119,42 @@
|
|||
</div>
|
||||
</div> <!-- end login page -->
|
||||
|
||||
<div id="demande-page" style="display: none">
|
||||
|
||||
<div id="demande-page" class="container" style="display: none">
|
||||
<div class="column-section">
|
||||
<h1>Demandes</h1>
|
||||
<p>Ici vous pouvez demandez à un espion aguerri de faire une mission pour vous comme commander des crêpes. Aussi, vous pouvez tentez de valider la chasse au trésor du jour !
|
||||
Pour cela il suffit d'envoyer une photo du ticket avec l'endroit où vous l'avez trouvé.
|
||||
</p>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row-section">
|
||||
<div class="column-section" id="demande-form">
|
||||
<h2>Crêpes</h2>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="Lieu de livraison" id="demande-where">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="number" class="form-control" placeholder="Quantité" id="demande-amount">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="Supplément" id="demande-supp">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="textarea" class="form-control" placeholder="Notes" id="demande-notes">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary" id="demande-button">Envoyer</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="spacer colum-section"></div>
|
||||
<div class="column-section">
|
||||
<h2>Chasse au trésor</h2>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="column-section">
|
||||
<h1>Vos demandes en cours</h1>
|
||||
</div>
|
||||
</div> <!-- end demande page -->
|
||||
</div>
|
||||
|
||||
|
|
|
@ -514,6 +514,85 @@ function refreshListener() {
|
|||
})
|
||||
}
|
||||
|
||||
$('#demande-button').click(function () {
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: base_url + "addPrank",
|
||||
data: JSON.stringify({
|
||||
uid: localStorage.getItem('user'),
|
||||
token: localStorage.getItem('token'),
|
||||
type: "crêpe",
|
||||
amount: $('#demande-amount').val(),
|
||||
where: $('#demande-where').val(),
|
||||
supplement: $('#demande-supplement').val(),
|
||||
note: $('#demande-note').val()
|
||||
}),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
|
||||
success: function(data) {
|
||||
if(data.success) {
|
||||
$('#demande-form input').val("");
|
||||
} else {
|
||||
alert(data.why);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function updateNextActivity() {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: base_url + "get",
|
||||
data: JSON.stringify({
|
||||
token: "",
|
||||
uid: "",
|
||||
type: "activity",
|
||||
}),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: (data) => {
|
||||
if(data.success) {
|
||||
let curr_date = new Date();
|
||||
let ad = data.activityData;
|
||||
var candidate = [];
|
||||
var next_acti = {title: "Pas encore d'activité", desc: "Encore aucune activité n'a été renseigné, faite le vite !"};
|
||||
for(const uid in ad) {
|
||||
if(ad[uid].type == "event" && curr_date < new Date( ad[uid].start )) {
|
||||
candidate.push(ad[uid]);
|
||||
}
|
||||
}
|
||||
|
||||
next_acti = candidate.reduce(function(prev, curr) {
|
||||
return new Date(prev.start) < new Date(curr.Cost) ? prev : curr;
|
||||
});
|
||||
|
||||
var opt = {speed: 100};
|
||||
new TypeIt("#activite-title", opt)
|
||||
.type(next_acti.title)
|
||||
.go();
|
||||
new TypeIt("#activite-desc", opt)
|
||||
.type(next_acti.desc)
|
||||
.go();
|
||||
new TypeIt("#activite-place", opt)
|
||||
.type("Lieu : " + next_acti.where)
|
||||
.go();
|
||||
let diff = Math.ceil( (new Date(next_acti.start) - new Date()) / 1000 )
|
||||
let days = Math.trunc(diff / (3600*24) )
|
||||
let h = Math.trunc(diff / 3600) - days*24
|
||||
let m = Math.trunc(diff / 60) - (h + days*24)*60
|
||||
let s = diff - h*3600 - m*60 - days*24*3600
|
||||
$('#timer').text(days + " jours " + (new Date('December 17, 1995 ' + [h, m, s].join(':'))).toLocaleTimeString('default', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
}));
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$(window).on("load", function() {
|
||||
/* Register the Service Worker */
|
||||
if ('serviceWorker' in navigator) {
|
||||
|
@ -524,37 +603,15 @@ $(window).on("load", function() {
|
|||
$(page[i]).css('z-index', page.length - i);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: base_url + "lastActivity",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: (data) => {
|
||||
if(data.success) {
|
||||
opt = {speed: 100, likeLike: true};
|
||||
new TypeIt("#activite-title", opt)
|
||||
.type(data.activity.title)
|
||||
.go();
|
||||
new TypeIt("#activite-desc", opt)
|
||||
.type(data.activity.desc)
|
||||
.go();
|
||||
let diff = Math.ceil( (data.activity.start - new Date()) / 1000 )
|
||||
let h = Math.round(diff / 3600)
|
||||
let m = Math.round(diff / 60) - h*60
|
||||
let s = diff - m*60
|
||||
$("#timer").text((new Date('December 17, 1995 ' + [h, m, s].join(':'))).toLocaleTimeString('default', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
}));
|
||||
}
|
||||
}
|
||||
})
|
||||
updateNextActivity();
|
||||
|
||||
/* load timer */
|
||||
window.setInterval(function() {
|
||||
var time = $("#timer").text();
|
||||
var b = $("#timer").text().split(' jours ');
|
||||
var time = b[1];
|
||||
var days = b[0];
|
||||
var t = time.split(":").map(t => parseInt(t));
|
||||
|
||||
t[2] -= 1;
|
||||
if (t[2] < 0) {
|
||||
t[2] = 59;
|
||||
|
@ -565,11 +622,19 @@ $(window).on("load", function() {
|
|||
t[0] -= 1;
|
||||
}
|
||||
if (t[0] < 0) {
|
||||
t[0] = 23;
|
||||
t[1] = 59;
|
||||
t[2] = 59;
|
||||
days -= 1;
|
||||
}
|
||||
if (days < 0) {
|
||||
t[0] = 0;
|
||||
t[1] = 0;
|
||||
t[2] = 0;
|
||||
days = 0;
|
||||
updateNextActivity();
|
||||
}
|
||||
$('#timer').text((new Date('December 17, 1995 ' + t.join(':'))).toLocaleTimeString('default', {
|
||||
$('#timer').text(days + " jours " +(new Date('December 17, 1995 ' + t.join(':'))).toLocaleTimeString('default', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
|
|
Loading…
Reference in a new issue