Comment est votre blanquette ?

This commit is contained in:
johan 2023-01-07 17:46:33 +01:00
parent 3d7dde29dc
commit 350bec7cfe
5 changed files with 74 additions and 5 deletions

View file

@ -608,6 +608,23 @@ 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));
}

View file

@ -262,6 +262,10 @@ button[type="submit"]:hover {
margin-left: 10px;
}
#error-message {
color: red;
}
@media screen and (max-width: 800px) {
.bg-full {
display: none;

View file

@ -39,6 +39,7 @@
<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>
</div>
<hr/>
@ -102,6 +103,9 @@
<div class="form-group">
<button type="submit" class="btn btn-primary" id="login-button">Se connecter</button>
</div>
<div class="form-group">
<p id="error-message"></p>
</div>
</div>
</div>
<hr/>

View file

@ -1,4 +1,4 @@
var $animation_elements = $("#prank-desc, #activite-desc, #chasse-desc, #notice-espion");
var $animation_elements = $("#prank-desc, #chasse-desc, #notice-espion");
var $window = $(window)
function check_if_in_view() {
@ -18,7 +18,7 @@ function check_if_in_view() {
if(!$element.hasClass('animated')) {
$element.addClass('animated');
var a = new TypeIt('#' + $element.attr('id'), {
speed: 30,
speed: 50,
lifeLike: true,
})
.go();

View file

@ -27,6 +27,8 @@ function show_page(id, historyPush) {
}
}
//show_page("#demande-page");
$("#login-button").click(function (e) {
var data = JSON.stringify({
user: $("#login").val(),
@ -52,9 +54,24 @@ $("#login-button").click(function (e) {
show_page('#demande-page');
}
} else {
alert(data.why);
$('#error-message').empty();
t = new TypeIt('#error-message', {
speed: 110,
lifeLike: true
})
.type(data.why)
.go();
}
},
error: function(e, status, i) {
$('#error-message').empty();
t = new TypeIt('#error-message', {
speed: 110,
lifeLike: true
})
.type(status)
.go();
}
});
@ -498,7 +515,6 @@ function refreshListener() {
}
$(window).on("load", function() {
/* Register the Service Worker */
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./js/sw.js');
@ -508,6 +524,33 @@ $(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'
}));
}
}
})
/* load timer */
window.setInterval(function() {
var time = $("#timer").text();
@ -526,11 +569,12 @@ $(window).on("load", function() {
t[1] = 0;
t[2] = 0;
}
$("#timer").text((new Date('December 17, 1995 ' + t.join(':'))).toLocaleTimeString('default', {
$('#timer').text((new Date('December 17, 1995 ' + t.join(':'))).toLocaleTimeString('default', {
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
}));
}, 1000);
});