Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 53 additions & 78 deletions hackathon_site/event/jinja2/event/landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,88 +206,62 @@ <h3 class="center" id="countdownTitle"></h3>
</div>
</div>

<div class="container colorScroll" data-background-color="#035E8A">
<div class="section scrollspy" id="schedule">
<div class="row schedule">
<div class="m12 center">
<h3 class="center">Schedule (2026)</h3>
</div>
<div class="col s12 m6 l6">
<h4 class="white-text" style="text-align:center; flex-grow:1;">
Saturday
</h4>

<div class="scheduleRow">
<p class="scheduleTime">8:30AM</p>
<p>Participant Registration</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">10AM</p>
<p>Hacking Begins!</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">10AM</p>
<p>Hardware Component Distribution</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">12PM</p>
<p>Lunch</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">6PM</p>
<p>3D printing submissions close</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">6PM</p>
<p>Dinner</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">8PM</p>
<p>Hardware room closes for Saturday (Orders after 8 PM can be picked up 7 AM on Sunday)</p>
</div>
</div>

<div class="col s12 m6 l6">
<h4 class="white-text" style="text-align:center; flex-grow:1;">
Sunday
</h4>
<div class="scheduleRow">
<p class="scheduleTime">7AM</p>
<p>Hardware room opens for Sunday</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">8AM</p>
<p>Breakfast</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">9AM</p>
<p>Hardware room closes for Sunday</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">10AM</p>
<p>Hacking Ends!</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">11AM</p>
<p>Lunch</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">12PM</p>
<p>Judging Begins</p>
</div>
<div class="scheduleRow">
<p class="scheduleTime">3PM</p>
<p>Closing Ceremony</p>
</div>
</div>


<section class="scheduleSection colorScroll" data-background-color="#FFFFFF" aria-labelledby="schedule-title">
<div class="container section scrollspy" id="schedule">
<h3 id="schedule-title" class="center">Schedule ({{ event_start_date.year }})</h3>
<div class="schedule" data-start-date="{{ event_start_date|strftime('%Y-%m-%d') }}" data-time-zone="{{ event_time_zone }}">
{% for corner in ['topLeft', 'topRight', 'bottomLeft', 'bottomRight'] %}
<span class="schedulePin schedulePin--{{ corner }}" aria-hidden="true"></span>
{% 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 %}
<section class="scheduleDay" data-day-offset="{{ loop.index0 }}" aria-labelledby="schedule-day-{{ number }}">
<header class="scheduleHeader">
<div>
<p class="scheduleEyebrow">{{ short_day }} · Day {{ number }}</p>
<h4 id="schedule-day-{{ number }}">{{ day }}</h4>
</div>
<div class="scheduleStatus" aria-label="Day status">
<span class="scheduleIndicator" data-state="off"><span class="scheduleStatusDot" aria-hidden="true"></span>Live <span class="scheduleStatusValue">Off</span></span>
</div>
</header>
<ol class="scheduleEvents">
{% for time, display_time, title, note in events %}
<li class="scheduleEvent" data-state="off">
<time datetime="{{ time }}">{{ display_time }}</time>
<p>{{ title }}</p>
<span class="scheduleEventStatus">Upcoming</span>
{% if note %}<p class="scheduleNote">{{ note }}</p>{% endif %}
</li>
{% endfor %}
</ol>
</section>
{% endfor %}
</div>
<div class="m12 center">
<div class="center scheduleFooter">
<a href="https://docs.google.com/document/d/1Ui_ymFZ0fvkTWReaLKW9xdoBdV8rvJ56uL9ls9XOkmk/edit?usp=sharing" class="btn-large waves-effect waves-light colorBtn" rel="noopener" target="_blank">Full schedule</a>
</div>
</div>
</div>
</section>
<br /><br /><br />

<div class="container colorScroll" data-background-color="#003650">
Expand Down Expand Up @@ -494,6 +468,7 @@ <h3 class="row center">Contact Us</h3>
<script src="{{ static('event/js/sponsors-data.js') }}"></script>
<script src="{{ static('event/js/sponsors-component.js') }}"></script>
<script src="{{ static('event/js/landing.js') }}"></script>
<script src="{{ static('event/js/schedule-live.js') }}"></script>

<!-- Select2 JS for the MLH interest form -->
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
Expand Down
35 changes: 35 additions & 0 deletions hackathon_site/event/static/event/js/landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
84 changes: 84 additions & 0 deletions hackathon_site/event/static/event/js/schedule-live.js
Original file line number Diff line number Diff line change
@@ -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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noticed that when testing with an event that already ended with today's date (i.e. the hour passed but not the date) that day 2 is still shown as live. can you change this to also check the time rather than just the date?

image

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();
}
Loading
Loading