Refactor A Summer's End hero header events

This commit is contained in:
Helen Chong 2024-04-29 11:39:05 +08:00
parent 6c4d658f76
commit db7dc4cd23
6 changed files with 101 additions and 196 deletions

View File

@ -4,7 +4,7 @@
<subtitle>Leilukin&#39;s personal website.</subtitle> <subtitle>Leilukin&#39;s personal website.</subtitle>
<link href="https://leilukin.neocities.org/feed.xml" rel="self"/> <link href="https://leilukin.neocities.org/feed.xml" rel="self"/>
<link href="https://leilukin.neocities.org"/> <link href="https://leilukin.neocities.org"/>
<updated>2024-04-29T03:36:24Z</updated> <updated>2024-04-29T03:38:43Z</updated>
<id>https://leilukin.neocities.org</id> <id>https://leilukin.neocities.org</id>
<author> <author>
<name>Leilukin</name> <name>Leilukin</name>

View File

@ -103,9 +103,9 @@
const todayEvent = getTodayEvent(); const todayEvent = getTodayEvent();
if (todayEvent != "No event") { if (todayEvent) {
heroTopBarEl.classList.remove('hidden'); heroTopBarEl.classList.remove('hidden');
heroTopBarEl.innerHTML = getBlurbHtml(todayEvent); heroTopBarEl.innerHTML = todayEvent;
} }
function getTodayEvent() { function getTodayEvent() {
@ -113,47 +113,28 @@
const month = date.getMonth() + 1; const month = date.getMonth() + 1;
const day = date.getDate(); const day = date.getDate();
if (month == 2 && day == 16)
return "Michelle's Birthday";
else if (month == 4 && day == 23)
return "ASE Anniversary";
else if (month == 8 && day == 9)
return "Cecelia's Birthday";
else if (month == 12 && day == 28)
return "Sam's Birthday";
else
return "No event";
}
function getBlurbHtml(day) {
const releaseDate = new Date("2020-04-23").getFullYear(); const releaseDate = new Date("2020-04-23").getFullYear();
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
const anniversary = currentYear - releaseDate; const anniversary = currentYear - releaseDate;
switch (day) { if (month == 2 && day == 16)
case "Michelle's Birthday": return `
return ` Today is Michelle Cheung's birthday. Happy Birthday Michelle!
Today is Michelle Cheung's birthday. Happy Birthday Michelle! `;
`; else if (month == 4 && day == 23)
break; return `
case "ASE Anniversary": Today is the ${anniversary}-year anniversary of the release of <cite>A Summers End — Hong Kong 1986</cite>!
return ` `;
Today is the ${anniversary}-year anniversary of the release of <cite>A Summers End — Hong Kong 1986</cite>! else if (month == 8 && day == 9)
`; return `
break; Today is Cecelia Cortes' birthday. Happy Birthday Cecelia!
case "Cecelia's Birthday": `;
return ` else if (month == 12 && day == 28)
Today is Cecelia Cortes' birthday. Happy Birthday Cecelia! return `
`; Today is Sam Wong's birthday. Happy Birthday Sam!
break; `;
case "Sam's Birthday": else
return ` return null;
Today is Sam Wong's birthday. Happy Birthday Sam!
`;
break;
default:
return ``;
}
} }
</script> </script>

View File

@ -103,9 +103,9 @@
const todayEvent = getTodayEvent(); const todayEvent = getTodayEvent();
if (todayEvent != "No event") { if (todayEvent) {
heroTopBarEl.classList.remove('hidden'); heroTopBarEl.classList.remove('hidden');
heroTopBarEl.innerHTML = getBlurbHtml(todayEvent); heroTopBarEl.innerHTML = todayEvent;
} }
function getTodayEvent() { function getTodayEvent() {
@ -113,47 +113,28 @@
const month = date.getMonth() + 1; const month = date.getMonth() + 1;
const day = date.getDate(); const day = date.getDate();
if (month == 2 && day == 16)
return "Michelle's Birthday";
else if (month == 4 && day == 23)
return "ASE Anniversary";
else if (month == 8 && day == 9)
return "Cecelia's Birthday";
else if (month == 12 && day == 28)
return "Sam's Birthday";
else
return "No event";
}
function getBlurbHtml(day) {
const releaseDate = new Date("2020-04-23").getFullYear(); const releaseDate = new Date("2020-04-23").getFullYear();
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
const anniversary = currentYear - releaseDate; const anniversary = currentYear - releaseDate;
switch (day) { if (month == 2 && day == 16)
case "Michelle's Birthday": return `
return ` Today is Michelle Cheung's birthday. Happy Birthday Michelle!
Today is Michelle Cheung's birthday. Happy Birthday Michelle! `;
`; else if (month == 4 && day == 23)
break; return `
case "ASE Anniversary": Today is the ${anniversary}-year anniversary of the release of <cite>A Summers End — Hong Kong 1986</cite>!
return ` `;
Today is the ${anniversary}-year anniversary of the release of <cite>A Summers End — Hong Kong 1986</cite>! else if (month == 8 && day == 9)
`; return `
break; Today is Cecelia Cortes' birthday. Happy Birthday Cecelia!
case "Cecelia's Birthday": `;
return ` else if (month == 12 && day == 28)
Today is Cecelia Cortes' birthday. Happy Birthday Cecelia! return `
`; Today is Sam Wong's birthday. Happy Birthday Sam!
break; `;
case "Sam's Birthday": else
return ` return null;
Today is Sam Wong's birthday. Happy Birthday Sam!
`;
break;
default:
return ``;
}
} }
</script> </script>

View File

@ -103,9 +103,9 @@
const todayEvent = getTodayEvent(); const todayEvent = getTodayEvent();
if (todayEvent != "No event") { if (todayEvent) {
heroTopBarEl.classList.remove('hidden'); heroTopBarEl.classList.remove('hidden');
heroTopBarEl.innerHTML = getBlurbHtml(todayEvent); heroTopBarEl.innerHTML = todayEvent;
} }
function getTodayEvent() { function getTodayEvent() {
@ -113,47 +113,28 @@
const month = date.getMonth() + 1; const month = date.getMonth() + 1;
const day = date.getDate(); const day = date.getDate();
if (month == 2 && day == 16)
return "Michelle's Birthday";
else if (month == 4 && day == 23)
return "ASE Anniversary";
else if (month == 8 && day == 9)
return "Cecelia's Birthday";
else if (month == 12 && day == 28)
return "Sam's Birthday";
else
return "No event";
}
function getBlurbHtml(day) {
const releaseDate = new Date("2020-04-23").getFullYear(); const releaseDate = new Date("2020-04-23").getFullYear();
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
const anniversary = currentYear - releaseDate; const anniversary = currentYear - releaseDate;
switch (day) { if (month == 2 && day == 16)
case "Michelle's Birthday": return `
return ` Today is Michelle Cheung's birthday. Happy Birthday Michelle!
Today is Michelle Cheung's birthday. Happy Birthday Michelle! `;
`; else if (month == 4 && day == 23)
break; return `
case "ASE Anniversary": Today is the ${anniversary}-year anniversary of the release of <cite>A Summers End — Hong Kong 1986</cite>!
return ` `;
Today is the ${anniversary}-year anniversary of the release of <cite>A Summers End — Hong Kong 1986</cite>! else if (month == 8 && day == 9)
`; return `
break; Today is Cecelia Cortes' birthday. Happy Birthday Cecelia!
case "Cecelia's Birthday": `;
return ` else if (month == 12 && day == 28)
Today is Cecelia Cortes' birthday. Happy Birthday Cecelia! return `
`; Today is Sam Wong's birthday. Happy Birthday Sam!
break; `;
case "Sam's Birthday": else
return ` return null;
Today is Sam Wong's birthday. Happy Birthday Sam!
`;
break;
default:
return ``;
}
} }
</script> </script>

View File

@ -103,9 +103,9 @@
const todayEvent = getTodayEvent(); const todayEvent = getTodayEvent();
if (todayEvent != "No event") { if (todayEvent) {
heroTopBarEl.classList.remove('hidden'); heroTopBarEl.classList.remove('hidden');
heroTopBarEl.innerHTML = getBlurbHtml(todayEvent); heroTopBarEl.innerHTML = todayEvent;
} }
function getTodayEvent() { function getTodayEvent() {
@ -113,47 +113,28 @@
const month = date.getMonth() + 1; const month = date.getMonth() + 1;
const day = date.getDate(); const day = date.getDate();
if (month == 2 && day == 16)
return "Michelle's Birthday";
else if (month == 4 && day == 23)
return "ASE Anniversary";
else if (month == 8 && day == 9)
return "Cecelia's Birthday";
else if (month == 12 && day == 28)
return "Sam's Birthday";
else
return "No event";
}
function getBlurbHtml(day) {
const releaseDate = new Date("2020-04-23").getFullYear(); const releaseDate = new Date("2020-04-23").getFullYear();
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
const anniversary = currentYear - releaseDate; const anniversary = currentYear - releaseDate;
switch (day) { if (month == 2 && day == 16)
case "Michelle's Birthday": return `
return ` Today is Michelle Cheung's birthday. Happy Birthday Michelle!
Today is Michelle Cheung's birthday. Happy Birthday Michelle! `;
`; else if (month == 4 && day == 23)
break; return `
case "ASE Anniversary": Today is the ${anniversary}-year anniversary of the release of <cite>A Summers End — Hong Kong 1986</cite>!
return ` `;
Today is the ${anniversary}-year anniversary of the release of <cite>A Summers End — Hong Kong 1986</cite>! else if (month == 8 && day == 9)
`; return `
break; Today is Cecelia Cortes' birthday. Happy Birthday Cecelia!
case "Cecelia's Birthday": `;
return ` else if (month == 12 && day == 28)
Today is Cecelia Cortes' birthday. Happy Birthday Cecelia! return `
`; Today is Sam Wong's birthday. Happy Birthday Sam!
break; `;
case "Sam's Birthday": else
return ` return null;
Today is Sam Wong's birthday. Happy Birthday Sam!
`;
break;
default:
return ``;
}
} }
</script> </script>

View File

@ -10,9 +10,9 @@
{% block eventScript %} {% block eventScript %}
const todayEvent = getTodayEvent(); const todayEvent = getTodayEvent();
if (todayEvent != "No event") { if (todayEvent) {
heroTopBarEl.classList.remove('hidden'); heroTopBarEl.classList.remove('hidden');
heroTopBarEl.innerHTML = getBlurbHtml(todayEvent); heroTopBarEl.innerHTML = todayEvent;
} }
function getTodayEvent() { function getTodayEvent() {
@ -20,46 +20,27 @@
const month = date.getMonth() + 1; const month = date.getMonth() + 1;
const day = date.getDate(); const day = date.getDate();
if (month == 2 && day == 16)
return "Michelle's Birthday";
else if (month == 4 && day == 23)
return "ASE Anniversary";
else if (month == 8 && day == 9)
return "Cecelia's Birthday";
else if (month == 12 && day == 28)
return "Sam's Birthday";
else
return "No event";
}
function getBlurbHtml(day) {
const releaseDate = new Date("2020-04-23").getFullYear(); const releaseDate = new Date("2020-04-23").getFullYear();
const currentYear = new Date().getFullYear(); const currentYear = new Date().getFullYear();
const anniversary = currentYear - releaseDate; const anniversary = currentYear - releaseDate;
switch (day) { if (month == 2 && day == 16)
case "Michelle's Birthday": return `
return ` Today is Michelle Cheung's birthday. Happy Birthday Michelle!
Today is Michelle Cheung's birthday. Happy Birthday Michelle! `;
`; else if (month == 4 && day == 23)
break; return `
case "ASE Anniversary": Today is the ${anniversary}-year anniversary of the release of <cite>A Summers End — Hong Kong 1986</cite>!
return ` `;
Today is the ${anniversary}-year anniversary of the release of <cite>A Summers End — Hong Kong 1986</cite>! else if (month == 8 && day == 9)
`; return `
break; Today is Cecelia Cortes' birthday. Happy Birthday Cecelia!
case "Cecelia's Birthday": `;
return ` else if (month == 12 && day == 28)
Today is Cecelia Cortes' birthday. Happy Birthday Cecelia! return `
`; Today is Sam Wong's birthday. Happy Birthday Sam!
break; `;
case "Sam's Birthday": else
return ` return null;
Today is Sam Wong's birthday. Happy Birthday Sam!
`;
break;
default:
return ``;
}
} }
{% endblock %} {% endblock %}