From 4458bfe02fbeeb4973cd92772c6dd703a54172eb Mon Sep 17 00:00:00 2001 From: MarioSwitch Date: Fri, 31 May 2024 13:00:19 +0200 Subject: [PATCH] [2.0.57] Countdown fixes + misc. --- countdown.js | 49 +++++++++++++++++++------------------------ views/about.php | 2 +- views/leaderboard.php | 4 ++-- views/prediction.php | 4 ++-- 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/countdown.js b/countdown.js index c01715b..2b91b59 100644 --- a/countdown.js +++ b/countdown.js @@ -1,16 +1,4 @@ /* -1000 days = 86,400,000,000 ms -2 years (730.5 days) = 63,115,200,000 ms -1 year (365.25 days) = 31,557,600,000 ms -1 year (365 days) = 31,536,000,000 ms -1 month = 365 / 12 = 30.417 days = 2,628,000,000 ms -100 hours = 4d 4h = 360,000,000 ms -1 day = 86,400,000 ms -100 mins = 1h 40m = 6,000,000 ms -1 hour = 3,600,000 ms -1 minute = 60,000 ms -1 second = 1,000 ms - ----- ENGLISH ----- Parameters: goal parameter must be in YYYY-MM-DDTHH:ii:ssZ format (YYYY for year, MM for month, DD for day, HH for hours, ii for minutes and ss for seconds. "T" and "Z" must be left as is. Example: "2022-07-04T14:43:58Z" for July 4th, 2022 at 2:43:58 PM UTC) @@ -36,31 +24,38 @@ Utilisation : Mettez l'identifiant de l'élément que vous souhaitez transformer en compte à rebours sur un identifiant relié à un compteur. */ +var year = 31556952000; //1 year = 365.2425 days = 31,556,952,000 ms +var month = year/12; //1 month = 30.436875 days = 2,629,746,000 ms +var day = 86400000; //1 day = 86,400,000 ms +var hour = day/24; //1 hour = 3,600,000 ms +var minute = hour/60; //1 minute = 60,000 ms +var second = minute/60; //1 second = 1,000 ms + function countdownTo(goal, formatBefore = "%countdown", formatAfter = "", id = "countdown"){ var nowDate = new Date(); var goalDate = new Date(goal); var gap = Math.abs(goalDate - nowDate); //Formatting count - if(gap>=63115200000){ //if more than 2 years - var countString = Math.floor(gap/31557600000)+" ans"; + if(gap>=2*year){ //if more than 2 years + var countString = Math.floor(gap/year)+" ans"; } - if(gap<63115200000 && gap>=31536000000){ //if between 1 and 2 years - var countString = Math.floor(gap/31557600000)+" an"; + if(gap<2*year && gap>=year){ //if between 1 and 2 years + var countString = Math.floor(gap/year)+" an"; } - if(gap<31536000000 && gap>=2628000000){ //if between 1 month and 1 year - var countString = Math.floor(gap/2628000000)+" mois"; + if(gap=month){ //if between 1 month and 1 year + var countString = Math.floor(gap/month)+" mois"; } - if(gap<2628000000 && gap>=360000000){ //if between 100 hours (4d 4h) and 1 month - var countString = Math.floor(gap/86400000)+" jours"; + if(gap=100*hour){ //if between 100 hours (4d 4h) and 1 month + var countString = Math.floor(gap/day)+" jours"; } - if(gap<360000000 && gap>=3600000){ //if between 1 hour and 100 hours (4d 4h) - var countString = Math.floor(gap/3600000)+"h "+("0"+Math.floor(gap/60000)%60).slice(-2)+"m"; + if(gap<100*hour && gap>=hour){ //if between 1 hour and 100 hours (4d 4h) + var countString = Math.floor(gap/hour)+"h "+("0"+Math.floor(gap/minute)%60).slice(-2)+"m"; } - if(gap<3600000 && gap>=60000){ //if between 1 min and 1 hour - var countString = Math.floor(gap/60000)+"' "+("0"+Math.floor(gap/1000)%60).slice(-2)+"''"; + if(gap=minute){ //if between 1 min and 1 hour + var countString = Math.floor(gap/minute)+"' "+("0"+Math.floor(gap/second)%60).slice(-2)+"''"; } - if(gap<60000 && gap>=0){ //if less than 1 min - var countString = Math.floor(gap/1000)+"''"; + if(gap=0){ //if less than 1 min + var countString = Math.floor(gap/second)+"''"; } //Choosing the right format if(goalDate > nowDate){ @@ -68,6 +63,6 @@ function countdownTo(goal, formatBefore = "%countdown", formatAfter = "", id = " }else{ var finalString = formatAfter.replace('%countup',countString); } - setTimeout(countdownTo, 1000, goal, formatBefore, formatAfter, id); + setTimeout(countdownTo, second, goal, formatBefore, formatAfter, id); document.getElementById(id).innerHTML = finalString; } \ No newline at end of file diff --git a/views/about.php b/views/about.php index def8350..adcc48c 100644 --- a/views/about.php +++ b/views/about.php @@ -118,5 +118,5 @@ v1.0 (juin 2022) par MarioSwitch et Yosh
v1.1 (mai 2023) par MarioSwitch
v2.0 (actuelle, juin 2023) par MarioSwitch

-Version 2.0.56 du 15 mai 2024 +Version 2.0.57 du 31 mai 2024

\ No newline at end of file diff --git a/views/leaderboard.php b/views/leaderboard.php index 41d6724..d567689 100644 --- a/views/leaderboard.php +++ b/views/leaderboard.php @@ -17,7 +17,7 @@ $myPoints = intSQL("SELECT `points` FROM `users` WHERE `username` = ?;", [$_COOKIE["username"]]); $myRank = intSQL("SELECT COUNT(*) FROM `users` WHERE `points` > " . $myPoints . ";") + 1; $myTop = ($myRank / $accounts)*100; - echo "

Vous êtes " . displayOrdinal($myRank) . " sur " . displayInt($accounts) . " (top " . displayFloat($myTop) . " %).

"; + echo "

Vous êtes " . displayOrdinal($myRank) . " sur " . displayInt($accounts) . " (top " . displayFloat($myTop) . " %).

"; }else{ echo "

Total : " . displayInt($accounts) . " utilisateurs

"; } @@ -30,7 +30,7 @@ $user = $classement[$i]["username"]; $points = $classement[$i]["points"]; $rank = intSQL("SELECT COUNT(*) FROM `users` WHERE `points` > " . $points . ";") + 1; - echo "" . displayInt($rank, false) . "

" . displayUsername($user) . "

" . displayInt($points) . ""; + echo "" . displayOrdinal($rank) . "

" . displayUsername($user) . "

" . displayInt($points) . ""; } } echo ""; diff --git a/views/prediction.php b/views/prediction.php index 2e345fc..de24f8b 100644 --- a/views/prediction.php +++ b/views/prediction.php @@ -126,8 +126,8 @@

Fin des votes " . $prediEnd . " UTC

"); if($prediAnswered != NULL){ echo("

Réponse donnée " . $prediAnswered . " UTC

"); -}else if($mode == "waitingAnswer"){ - echo("

En attente de réponse...

"); +}else if($prediEnd < stringSQL("SELECT NOW();")){ + echo("

En attente de réponse…

"); } echo("

" . $prediNumberOfAnswers . " réponses possibles