From d3d1672b2f86a31cf378ace8c4b1c1e1b8191076 Mon Sep 17 00:00:00 2001 From: Marne Date: Thu, 22 Jan 2026 19:45:13 +0100 Subject: [PATCH 1/2] add progression system --- css/base.css | 2 +- css/home.css | 41 ++++++++++++++++++++++++++++++++++++++++- index.html | 14 ++++++++++++-- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/css/base.css b/css/base.css index 6097b96..7cc787e 100644 --- a/css/base.css +++ b/css/base.css @@ -33,7 +33,7 @@ img { } a { - color: var(--accent-yellow); + color: black; text-decoration: none; } diff --git a/css/home.css b/css/home.css index f637eb9..a7235e3 100644 --- a/css/home.css +++ b/css/home.css @@ -15,4 +15,43 @@ justify-content: center; align-items: center; height: 200px; -} \ No newline at end of file +} + +/* Barre de progression */ + +.progression { +animation: 3s loadbar; +width:auto; +background-color: white; +display: inline-block; +padding: 0.7em 0.5em 0.5em 0.5em; +} + +@keyframes loadbar { + 0% { width:0%; } +} + +.bar { +width : 50%; +margin : auto; +border : 2px solid white; +display: inline-block; +} +.progression > span { + +display: inline-block; +width: 100%; +font-family: MonTrappist; +font-size : 1.5em; +} + +.lessthanhalf span { + padding-left: 100%; + color: white; + padding-left: calc(100% + 1em); +} + +.morethanhalf { +text-align : end; +color:black; +} diff --git a/index.html b/index.html index 833d9c0..fcf9de3 100644 --- a/index.html +++ b/index.html @@ -80,8 +80,18 @@ Seule exigence, respecter toutes les marginalités, originalités, bizarreries et normaleries de chacun·es.

- - +

+ Où en est-on ? +

+
+

Il y a

+
50/200
+

places déjà réservées

+
+

Et nous avons reçu

+
52,45%
+

des dons dont nous avons besoin (voir le détail des comptes)

+

Iels y participent

-- 2.30.2 From e18381fc1700dd3934599a7a8388be3899cca7a9 Mon Sep 17 00:00:00 2001 From: Pierre de Lacroix Date: Thu, 22 Jan 2026 23:37:39 +0100 Subject: [PATCH 2/2] plug progression system to camp-api --- css/home.css | 1 + index.html | 9 ++--- js/progress.js | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 js/progress.js diff --git a/css/home.css b/css/home.css index a7235e3..91028e9 100644 --- a/css/home.css +++ b/css/home.css @@ -25,6 +25,7 @@ width:auto; background-color: white; display: inline-block; padding: 0.7em 0.5em 0.5em 0.5em; +text-wrap: nowrap; } @keyframes loadbar { diff --git a/index.html b/index.html index fcf9de3..a856c90 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,7 @@ + Camp Interhack @@ -83,13 +84,13 @@

Où en est-on ?

-
+

Il y a

-
50/200
-

places déjà réservées

+
?/200
+

places déjà réservées. Ouverture prochaine des inscriptions !


Et nous avons reçu

-
52,45%
+
? %

des dons dont nous avons besoin (voir le détail des comptes)

diff --git a/js/progress.js b/js/progress.js new file mode 100644 index 0000000..ea1bdf2 --- /dev/null +++ b/js/progress.js @@ -0,0 +1,91 @@ +const gauge_url = "https://api.camp.interhacker.space/api/gauge" +const fundraising_url = "https://api.camp.interhacker.space/api/fundraising" +const gaugeMax = 250; +const fundraisingTotalMax = 20000; + +async function getGauge() { + // REMOVE WHEN SIGNUP FORM IS OPEN + return 0; + + try { + const response = await fetch(gauge_url); + if (!response.ok) { + throw new Error(`Response status: ${response.status}`); + } + + const result = await response.json(); + + return result.gauge + } catch (error) { + console.error(error.message); + + return null; + } +} + +async function getFundraisingTotal() { + try { + const response = await fetch(fundraising_url); + if (!response.ok) { + throw new Error(`Response status: ${response.status}`); + } + + const result = await response.json(); + + return result.total + } catch (error) { + console.error(error.message); + + return null; + } +} + +function percentRatio(ratio) { + return Math.floor(ratio * 100); +} + +function setAboveHalf(ratio, element) { + if (ratio > 0.5) { + element.classList.remove("lessthanhalf"); + element.classList.add("morethanhalf"); + } +} + +async function setGauge() { + const gauge = await getGauge(); + + if (gauge !== null) { + const gaugeBar = document.getElementById("gauge-bar"); + const gaugeText = document.getElementById("gauge-text"); + + const gaugeRatio = gauge / gaugeMax; + + gaugeBar.style.setProperty("width", percentRatio(gaugeRatio) + "%"); + gaugeText.innerText = gauge + "/" + gaugeMax; + + setAboveHalf(gaugeRatio, gaugeBar); + } +} + +async function setFundraisingTotal() { + const fundraising_total = await getFundraisingTotal(); + + if (fundraising_total !== null) { + const fundraisingBar = document.getElementById("fundraising-bar"); + const fundraisingText = document.getElementById("fundraising-text"); + + const fundraisingRatio = fundraising_total / fundraisingTotalMax; + + fundraisingBar.style.setProperty("width", percentRatio(fundraisingRatio) + "%"); + fundraisingText.innerText = percentRatio(fundraisingRatio) + " %"; + + setAboveHalf(fundraisingRatio, fundraisingBar); + } +} + +async function setProgress() { + setGauge(); + setFundraisingTotal(); +} + +document.addEventListener("DOMContentLoaded", setProgress); -- 2.30.2