diff --git a/hackathon_site/event/jinja2/event/landing.html b/hackathon_site/event/jinja2/event/landing.html index 33971b8..058b9e1 100644 --- a/hackathon_site/event/jinja2/event/landing.html +++ b/hackathon_site/event/jinja2/event/landing.html @@ -206,88 +206,62 @@

-
-
-
-
-

Schedule (2026)

-
-
-

- Saturday -

- -
-

8:30AM

-

Participant Registration

-
-
-

10AM

-

Hacking Begins!

-
-
-

10AM

-

Hardware Component Distribution

-
-
-

12PM

-

Lunch

-
-
-

6PM

-

3D printing submissions close

-
-
-

6PM

-

Dinner

-
-
-

8PM

-

Hardware room closes for Saturday (Orders after 8 PM can be picked up 7 AM on Sunday)

-
-
- -
-

- Sunday -

-
-

7AM

-

Hardware room opens for Sunday

-
-
-

8AM

-

Breakfast

-
-
-

9AM

-

Hardware room closes for Sunday

-
-
-

10AM

-

Hacking Ends!

-
-
-

11AM

-

Lunch

-
-
-

12PM

-

Judging Begins

-
-
-

3PM

-

Closing Ceremony

-
-
- - +
+
+

Schedule ({{ event_start_date.year }})

+
+ {% for corner in ['topLeft', 'topRight', 'bottomLeft', 'bottomRight'] %} + + {% endfor %} + {% set days = [ + ('Saturday', 'SAT', '01', [ + ('08:30', '8:30AM', 'Participant Registration', ''), + ('10:00', '10AM', 'Hacking Begins!', ''), + ('10:00', '10AM', 'Hardware Component Distribution', ''), + ('12:00', '12PM', 'Lunch', ''), + ('18:00', '6PM', '3D printing submissions close', ''), + ('18:00', '6PM', 'Dinner', ''), + ('20:00', '8PM', 'Hardware room closes for Saturday', 'Orders after 8 PM can be picked up at 7 AM on Sunday.') + ]), + ('Sunday', 'SUN', '02', [ + ('07:00', '7AM', 'Hardware room opens for Sunday', ''), + ('08:00', '8AM', 'Breakfast', ''), + ('09:00', '9AM', 'Hardware room closes for Sunday', ''), + ('10:00', '10AM', 'Hacking Ends!', ''), + ('11:00', '11AM', 'Lunch', ''), + ('12:00', '12PM', 'Judging Begins', ''), + ('15:00', '3PM', 'Closing Ceremony', '') + ]) + ] %} + {% for day, short_day, number, events in days %} +
+
+
+

{{ short_day }} ยท Day {{ number }}

+

{{ day }}

+
+
+ Live Off +
+
+
    + {% for time, display_time, title, note in events %} +
  1. + +

    {{ title }}

    + Upcoming + {% if note %}

    {{ note }}

    {% endif %} +
  2. + {% endfor %} +
+
+ {% endfor %}
- -
+



@@ -494,6 +468,7 @@

Contact Us

+ diff --git a/hackathon_site/event/static/event/js/landing.js b/hackathon_site/event/static/event/js/landing.js index f9a0557..97b2639 100644 --- a/hackathon_site/event/static/event/js/landing.js +++ b/hackathon_site/event/static/event/js/landing.js @@ -127,3 +127,38 @@ function setCounter(countDownDate) { $("#day2").html(Math.floor(days / 10) % 10); $("#day3").html(days % 10); } + +// Decorative scroll lighting is independent of the future day/time status logic. +function initScheduleLighting() { + const schedule = document.querySelector(".schedule"); + if (!schedule) return; + const pins = Array.from(schedule.querySelectorAll(".schedulePin")); + const reducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)"); + const clamp = (value) => Math.max(0, Math.min(1, value)); + let frame = null; + + function paint() { + frame = null; + const top = schedule.getBoundingClientRect().top; + const start = window.innerHeight * 0.85; + const distance = Math.max(120, window.innerHeight * 0.2); + // All four outer LEDs power on together as the schedule enters view. + // Reduced motion uses an immediate state change, not permanently dark LEDs. + const power = reducedMotion.matches + ? Number(top <= start) + : clamp((start - top) / distance); + pins.forEach((pin) => pin.style.setProperty("--pin-power", power)); + } + + function schedulePaint() { + if (frame === null) frame = window.requestAnimationFrame(paint); + } + + window.addEventListener("scroll", schedulePaint, { passive: true }); + window.addEventListener("resize", schedulePaint); + window.addEventListener("pageshow", schedulePaint); + reducedMotion.addEventListener("change", schedulePaint); + paint(); +} + +$(document).ready(initScheduleLighting); diff --git a/hackathon_site/event/static/event/js/schedule-live.js b/hackathon_site/event/static/event/js/schedule-live.js new file mode 100644 index 0000000..8a35f3c --- /dev/null +++ b/hackathon_site/event/static/event/js/schedule-live.js @@ -0,0 +1,84 @@ +// Calendar-day arithmetic avoids shifting Sunday by an hour across DST changes. +function scheduleDateAtOffset(startDate, offset) { + const [year, month, day] = startDate.split("-").map(Number); + return new Date(Date.UTC(year, month - 1, day + offset)).toISOString().slice(0, 10); +} + +function scheduleClock(now, timeZone) { + const parts = new Intl.DateTimeFormat("en-CA", { + timeZone, + year: "numeric", + month: "2-digit", + day: "2-digit", + hour: "2-digit", + minute: "2-digit", + hourCycle: "h23", + }).formatToParts(now); + const values = Object.fromEntries(parts.map(({ type, value }) => [type, value])); + return { + date: `${values.year}-${values.month}-${values.day}`, + time: `${values.hour}:${values.minute}`, + }; +} + +function scheduleEventReached(clock, date, time, endDate) { + // Accumulate reached milestones across both days, then reset after the weekend. + return ( + clock.date <= endDate && + (clock.date > date || (clock.date === date && clock.time >= time)) + ); +} + +// Controls ui live schedule indicators and status text for each day and event, based on the current time in the event's time zone +function initLiveSchedule() { + const schedule = document.querySelector(".schedule[data-start-date]"); + if (!schedule) return; + const { startDate, timeZone } = schedule.dataset; + const endDate = scheduleDateAtOffset(startDate, 1); + const days = Array.from(schedule.querySelectorAll(".scheduleDay")).map((day) => ({ + date: scheduleDateAtOffset(startDate, Number(day.dataset.dayOffset)), + indicator: day.querySelector(".scheduleIndicator"), + status: day.querySelector(".scheduleStatusValue"), + events: Array.from(day.querySelectorAll(".scheduleEvent")).map((event) => ({ + element: event, + time: event.querySelector("time").getAttribute("datetime"), + status: event.querySelector(".scheduleEventStatus"), + })), + })); + + function update() { + const clock = scheduleClock(new Date(), timeZone); + days.forEach((day) => { + const live = clock.date === day.date; + day.indicator.dataset.state = live ? "on" : "off"; + day.status.textContent = live ? "On" : "Off"; + day.events.forEach((event) => { + const reached = scheduleEventReached( + clock, + day.date, + event.time, + endDate + ); + event.element.dataset.state = reached ? "on" : "off"; + event.status.textContent = reached + ? "Scheduled time reached" + : clock.date > day.date + ? "Day finished" + : "Upcoming"; + }); + }); + } + + update(); + window.setInterval(update, 15000); + window.addEventListener("pageshow", update); + document.addEventListener("visibilitychange", () => { + if (!document.hidden) update(); + }); +} + +if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", initLiveSchedule, { once: true }); +} else { + initLiveSchedule(); +} diff --git a/hackathon_site/event/static/event/styles/scss/styles.scss b/hackathon_site/event/static/event/styles/scss/styles.scss index 01a65be..3dbe6ef 100644 --- a/hackathon_site/event/static/event/styles/scss/styles.scss +++ b/hackathon_site/event/static/event/styles/scss/styles.scss @@ -343,37 +343,252 @@ nav ul a { // End of "About" section // "Schedule" section +.scheduleSection { + background: #fff; + color: #333; + padding: 38px 0; + + > .container { + max-width: 1000px; + width: 90%; + } + + h3 { + color: #333; + font-size: 25px; + letter-spacing: 3px; + margin: 0 0 34px; + } + + #schedule { + scroll-margin-top: 90px; + } +} + .schedule { - margin: 10px 0 30px; + border: 1.5px solid #65abda; + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + position: relative; + text-align: left; - h5 { - font-family: font(header); - font-weight: 500; + &Day + &Day { + border-left: 1px solid #9bc6e2; } - p { - font-size: size(xl); - margin: 0; + &Header { + align-items: center; + border-bottom: 1px solid #9bc6e2; + display: flex; + justify-content: space-between; + padding: 20px 28px; + + h4 { + color: #333; + font-family: font(header); + font-size: 27px; + font-weight: 700; + margin: 5px 0 0; + } } - &Time { - margin-right: 20px !important; - font-weight: bold; - white-space: nowrap; + &Eyebrow { + color: #357fae; + font-size: 10px; + font-weight: 700; + letter-spacing: 2px; + text-transform: uppercase; + } + + &Status { + align-self: flex-end; + display: grid; + gap: 6px; + margin-bottom: 3px; + margin-left: 12px; } - &Row { + &Indicator { + align-items: center; + background: #f7f8f9; + border: 1px solid #e0e5e8; + border-radius: 3px; + color: #626d75; display: flex; - margin: 10px 0 25px; - justify-content: center; + font-size: 9px; + font-weight: 700; + gap: 6px; + letter-spacing: 0.8px; + padding: 4px 6px; + text-transform: uppercase; + white-space: nowrap; } - @include responsive(md-down) { + &Indicator[data-state="on"] { + background: #fff8df; + border-color: #e7b43b; + color: #755100; + + .scheduleStatusDot { + background: #ffd840; + border-color: #f5a623; + box-shadow: 0 0 7px rgba(255, 174, 0, 0.65); + } + .scheduleStatusValue { + color: #755100; + } + } + + &Event[data-state="on"]::after { + background: #ffd840; + border-color: #f5a623; + box-shadow: 0 0 6px rgba(255, 190, 0, 0.8), 0 0 13px rgba(255, 174, 0, 0.4); + } + + &EventStatus { + clip-path: inset(50%); + height: 1px; + width: 1px; + overflow: hidden; + position: absolute; + white-space: nowrap; + } + + &StatusDot { + background: #ccd2d6; + border: 1px solid #abb4bc; + border-radius: 50%; + height: 6px; + width: 6px; + } + + &StatusValue { + color: #727c83; + margin-left: auto; + } + + &Events { + list-style: none; + margin: 0; + padding: 28px 28px 30px 46px; + } + + &Event { + padding: 0 0 23px 16px; + position: relative; + + // Timeline wires stay static; event lamps follow the configured date and time. + &::before { + background: #65abda; + bottom: -7px; + content: ""; + left: -20px; + position: absolute; + top: 8px; + width: 1.5px; + } + &::after { + background: #e7e2d6; + border: 1.5px solid #bfb49a; + border-radius: 50%; + content: ""; + height: 12px; + left: -25px; + position: absolute; + top: 5px; + width: 12px; + } + &:last-child { + padding-bottom: 0; + &::before { + bottom: auto; + height: 20px; + } + } + + time { + color: #946000; + display: block; + font-size: 14px; + font-weight: 800; + letter-spacing: 0.3px; + line-height: 1.5; + } p { - font-size: size(lg); + color: #333; + font-size: 15px; + line-height: 1.5; + margin: 2px 0 0; + } + .scheduleNote { + color: #666; + font-size: 13px; + margin-top: 5px; + max-width: 330px; + } + } + + &Pin { + --pin-power: 0; + background: rgb( + calc(170 + 85 * var(--pin-power)), + calc(158 + 58 * var(--pin-power)), + calc(125 - 61 * var(--pin-power)) + ); + border: 1.5px solid #f5a623; + border-radius: 2px; + box-shadow: 0 0 5px rgba(255, 196, 72, var(--pin-power)), + 0 0 14px rgba(255, 174, 0, calc(var(--pin-power) * 0.5)); + transition: background-color 150ms ease, box-shadow 150ms ease; + height: 14px; + position: absolute; + width: 14px; + z-index: 1; + &--topLeft { + left: -7px; + top: -7px; + } + &--topRight { + right: -7px; + top: -7px; + } + &--bottomLeft { + left: -7px; + bottom: -7px; + } + &--bottomRight { + right: -7px; + bottom: -7px; + } + } + + @media (prefers-reduced-motion: reduce) { + &Pin { + transition: none; + } + } + + &Footer { + margin-top: 30px; + } + + @media (max-width: 600px) { + grid-template-columns: 1fr; + &Day + &Day { + border-left: 0; + border-top: 1.5px solid #65abda; + } + &Header { + padding: 20px 22px; + } + &Events { + padding: 24px 22px 28px 40px; + } + &Header h4 { + font-size: 24px; } - &Time { - width: 70px; + &Event p { + font-size: 14px; } } } diff --git a/hackathon_site/hackathon_site/jinja2.py b/hackathon_site/hackathon_site/jinja2.py index b9aad9f..c12ed7f 100644 --- a/hackathon_site/hackathon_site/jinja2.py +++ b/hackathon_site/hackathon_site/jinja2.py @@ -37,6 +37,7 @@ def environment(**options): "registration_open_date": settings.REGISTRATION_OPEN_DATE, "registration_close_date": settings.REGISTRATION_CLOSE_DATE, "event_start_date": settings.EVENT_START_DATE, + "event_time_zone": settings.TIME_ZONE, "event_end_date": settings.EVENT_END_DATE, "waitlisted_acceptance_start_time": settings.WAITLISTED_ACCEPTANCE_START_TIME, "final_review_response_date": settings.FINAL_REVIEW_RESPONSE_DATE, diff --git a/hackathon_site/tests/js/schedule-live.test.cjs b/hackathon_site/tests/js/schedule-live.test.cjs new file mode 100644 index 0000000..3537656 --- /dev/null +++ b/hackathon_site/tests/js/schedule-live.test.cjs @@ -0,0 +1,87 @@ +const assert = require("node:assert/strict"); +const { test } = require("node:test"); +const fs = require("node:fs"); +const path = require("node:path"); +const vm = require("node:vm"); +const context = vm.createContext({ + document: { readyState: "loading", addEventListener() {} }, +}); +vm.runInContext( + fs.readFileSync(path.join(__dirname, "../../event/static/event/js/schedule-live.js"), "utf8"), + context +); +const zone = "America/Toronto"; + +test("second day follows the configured date across month/year and leap-day boundaries", () => { + assert.equal(context.scheduleDateAtOffset("2026-02-14", 0), "2026-02-14"); + assert.equal(context.scheduleDateAtOffset("2026-02-14", 1), "2026-02-15"); + assert.equal(context.scheduleDateAtOffset("2026-12-31", 1), "2027-01-01"); + assert.equal(context.scheduleDateAtOffset("2028-02-28", 1), "2028-02-29"); +}); + +test("LIVE dates follow Toronto midnight, not UTC or the visitor timezone", () => { + assert.equal(context.scheduleClock(new Date("2026-02-15T04:59:59Z"), zone).date, "2026-02-14"); + const midnight = context.scheduleClock(new Date("2026-02-15T05:00:00Z"), zone); + assert.equal(midnight.date, "2026-02-15"); + assert.equal(midnight.time, "00:00"); +}); + +test("event LEDs accumulate across the weekend and turn off after Sunday", () => { + const reached = (clock, date, time) => context.scheduleEventReached(clock, date, time, "2026-02-15"); + assert.equal(reached({ date: "2026-02-13", time: "23:59" }, "2026-02-14", "08:30"), false); + assert.equal(reached({ date: "2026-02-14", time: "08:29" }, "2026-02-14", "08:30"), false); + assert.equal(reached({ date: "2026-02-14", time: "08:30" }, "2026-02-14", "08:30"), true); + assert.equal(reached({ date: "2026-02-15", time: "00:00" }, "2026-02-14", "20:00"), true); + assert.equal(reached({ date: "2026-02-14", time: "23:59" }, "2026-02-15", "07:00"), false); +}); + +test("Toronto time and calendar-day offsets survive daylight-saving transitions", () => { + assert.equal(context.scheduleDateAtOffset("2026-03-07", 1), "2026-03-08"); + assert.equal(context.scheduleClock(new Date("2026-03-08T11:00:00Z"), zone).time, "07:00"); + assert.equal(context.scheduleDateAtOffset("2026-10-31", 1), "2026-11-01"); + assert.equal(context.scheduleClock(new Date("2026-11-01T12:00:00Z"), zone).time, "07:00"); +}); + +test("refresh updates LIVE badges and event LEDs together without touching outer pins", () => { + let now = "2026-02-14T13:30:00Z"; + let refresh; + const makeDay = (offset, times) => { + const indicator = { dataset: {} }, status = {}; + const events = times.map(time => ({ dataset: {}, status: {}, querySelector(selector) { + return selector === "time" ? { getAttribute: () => time } : this.status; + } })); + return { dataset: { dayOffset: offset }, indicator, status, events, + querySelector: selector => selector === ".scheduleIndicator" ? indicator : status, + querySelectorAll: () => events }; + }; + const days = [makeDay("0", ["08:30", "20:00"]), makeDay("1", ["07:00"])]; + const schedule = { dataset: { startDate: "2026-02-14", timeZone: zone }, querySelectorAll: () => days }; + const browser = vm.createContext({ + Date: class extends Date { constructor(...args) { super(...(args.length ? args : [now])); } }, + document: { readyState: "complete", querySelector: () => schedule, addEventListener() {} }, + window: { setInterval: callback => { refresh = callback; }, addEventListener() {} }, + }); + vm.runInContext(fs.readFileSync(path.join(__dirname, "../../event/static/event/js/schedule-live.js"), "utf8"), browser); + assert.equal(days[0].indicator.dataset.state, "on"); + assert.equal(days[1].status.textContent, "Off"); + assert.equal(days[0].events[0].dataset.state, "on"); + assert.equal(days[0].events[1].dataset.state, "off"); + now = "2026-02-15T04:59:59Z"; + refresh(); + assert(days[0].events.every(event => event.dataset.state === "on")); + now = "2026-02-15T05:00:00Z"; + refresh(); + assert(days[0].events.every(event => event.dataset.state === "on")); + assert.equal(days[0].events[0].status.textContent, "Scheduled time reached"); + assert.equal(days[1].events[0].dataset.state, "off"); + now = "2026-02-15T12:00:00Z"; + refresh(); + assert.equal(days[0].status.textContent, "Off"); + assert.equal(days[1].status.textContent, "On"); + assert.equal(days[1].events[0].dataset.state, "on"); + assert(days[0].events.every(event => event.dataset.state === "on")); + now = "2026-02-16T05:00:00Z"; + refresh(); + assert(days.every(day => day.status.textContent === "Off")); + assert(days.every(day => day.events.every(event => event.dataset.state === "off"))); +});