🐄🚞 Checkpoint

./public/index.js:1954897/59401
This commit is contained in:
Glitch (glitch-hello-node) committed 2021-11-14 15:29:39 +00:00
1 parent 6598bcd297
commit ec7755bfa5
1 file changed
+9 -5
+9 -5
View File
@@ -33,7 +33,7 @@ const data = getData()
const map = L.map('map', { const map = L.map('map', {
minZoom: 15, minZoom: 15,
maxZoom: 18 maxZoom: 18
}).setView([32.98649, -96.7485], 18) }).setView([32.98613, -96.75042], 18)
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', { L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
@@ -71,7 +71,7 @@ setTimeout(drawRegions, 60 * 1000)
async function drawRegions() { async function drawRegions() {
const data = await getData() const data = await getData()
const ecsw = data.filter(d => d.loc === 'ECSW') const ecsw = data.filter(d => d.loc === 'ECSW' && Date.now() - d.time < 60 * 60 * 1000)
console.log(ecsw) console.log(ecsw)
@@ -95,7 +95,7 @@ function getData() {
async function displayCard(id) { async function displayCard(id) {
const data = (await getData()).filter(d => d.loc === id) const data = (await getData()).filter(d => d.loc === id && Date.now() - d.time < 60 * 60 * 1000)
const card = document.getElementById("card") const card = document.getElementById("card")
await card.animate([ await card.animate([
{ transform: 'translateY(50px)', opacity: "0" }, { transform: 'translateY(50px)', opacity: "0" },
@@ -115,9 +115,13 @@ async function displayCard(id) {
console.log({ avg, current, delta, busy, color }) console.log({ avg, current, delta, busy, color })
const msg = Number.isNaN(delta)
? "No data..."
: (busy ? "Busier than usual": "Not as busy :)")
card.innerHTML = ` card.innerHTML = `
<h1>${buildings[id].name}</h1> <h1>${buildings[id].name}</h1>
<p>${busy ? "Busier than usual" : "Not as busy :)"}</p> <p>${msg}</p>
<canvas id="myChart" height="80"></canvas> <canvas id="myChart" height="80"></canvas>
` `
card.style.setProperty("--region", `'${id}'`) card.style.setProperty("--region", `'${id}'`)
@@ -134,7 +138,7 @@ async function displayCard(id) {
function updateChart(data) { function updateChart(data) {
const parsed = data.map(d => { const parsed = data.map(d => {
const TEN_MINUTES = 1 * 60 * 1000 const TEN_MINUTES = 10 * 60 * 1000
// this is 0-5 // this is 0-5
let ago = Math.floor((Date.now() - d.time) / TEN_MINUTES) let ago = Math.floor((Date.now() - d.time) / TEN_MINUTES)
// if (20 < ago) ago = 20 // if (20 < ago) ago = 20