Skip to content

Commit

Permalink
feat(index): Past weeks have right rockets. Remove alarm clock after …
Browse files Browse the repository at this point in the history
…past due
  • Loading branch information
pham committed Oct 10, 2022
1 parent 55c70d4 commit 678c904
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
12 changes: 11 additions & 1 deletion _includes/course.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ <h3>{{ session.header }}</h3>
<div class="control">
<a class="button" href="/segment/{{ segment }}">
{{ info.title }}&nbsp;
<span class="middle-align material-symbols-outlined">rocket_launch</span>
<span data-date="{{ info.end }}"
class="middle-align material-symbols-outlined rocket">rocket_launch</span>
</a>
</div>
</li>
Expand All @@ -61,10 +62,19 @@ <h3>{{ session.header }}</h3>

<script defer>
const due = document.querySelectorAll('.due');
const rocket = document.querySelectorAll('.rocket');
due.forEach( el => {
const d = new Date(el.dataset.date.split('-')).getTime();
if (d < Date.now()) {
el.classList.add('past');
}
});
rocket.forEach( el => {
if (el.dataset.date) {
const d = new Date(el.dataset.date.split('-')).getTime();
if (d < Date.now()) {
el.innerText = 'rocket';
}
}
});
</script>
4 changes: 3 additions & 1 deletion _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<ul>
{% for item in site.acc.footer -%}
<li>
<span class="material-symbols-outlined">{{ item.icon }}</span>
{%- if item.icon -%}
<span class="material-symbols-outlined">{{ item.icon }}</span>
{%- endif -%}
<a href="{{ item.href }}">{{ item.text }}</a>
</li>
{%- endfor %}
Expand Down
12 changes: 11 additions & 1 deletion _includes/segment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

{%- if session.due -%}
<div class="header">
<span class="material-symbols-outlined">alarm_on</span>
<span data-date="{{ session.due }}" class="material-symbols-outlined alarm">alarm_on</span>
{{ session.due | date: '%b %e, %y' }}
</div>
{%- elsif session.type -%}
Expand All @@ -46,3 +46,13 @@ <h3>{{ session.title }}</h3>
</li>
{%- endfor -%}
</ul>

<script defer>
const due = document.querySelectorAll('.alarm');
due.forEach( el => {
const d = new Date(el.dataset.date.split('-')).getTime();
if (d < Date.now()) {
el.parentNode.removeChild(el);
}
});
</script>

0 comments on commit 678c904

Please sign in to comment.