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>
<link href="https://leilukin.neocities.org/feed.xml" rel="self"/>
<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>
<author>
<name>Leilukin</name>

View File

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

View File

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

View File

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

View File

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

View File

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