From 8c329e3443204509026c1bb585bea63d0304662b Mon Sep 17 00:00:00 2001 From: Michael Kohler Date: Tue, 19 Nov 2019 22:17:28 +0100 Subject: [PATCH] Get number from github file --- index.html | 2 +- main.js | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 20a2563..16295a1 100644 --- a/index.html +++ b/index.html @@ -25,7 +25,7 @@

Get the respect you deserve

-

0 of 5000 new accounts

+

? of 5000 new accounts

diff --git a/main.js b/main.js index 649c131..6443c7a 100644 --- a/main.js +++ b/main.js @@ -1,7 +1,5 @@ 'use strict'; -console.log('foo'); - const GOAL = 5000; const MAX_HEIGHT = 153; const MIN_HEIGHT = 11; @@ -9,15 +7,20 @@ const MAX_TOP = 142; const MIN_TOP = 0; const RATIO = MAX_TOP/GOAL; -let current = 800; // TODO: actually get it... +getValue(); -if (current > GOAL) { - current = GOAL; -} +async function getValue() { + const response = await fetch('https://raw.githubusercontent.com/mozilla/firefox-accounts-campaign/master/number'); + let current = await response.json(); -const values = calculateValues(current); -setNewValues(values); -setTitle(current); + if (current > GOAL) { + current = GOAL; + } + + const values = calculateValues(current); + setNewValues(values); + setTitle(current); +} function setTitle(current) { const numberElement = document.querySelector('#number');