Skip to content

Commit

Permalink
Hide ended contests
Browse files Browse the repository at this point in the history
  • Loading branch information
f3rn4nd0-c354r committed Oct 7, 2023
1 parent 19bf2e1 commit 8e33fb7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ <h1 class="page-title">Concursos Literários em Português ✒</h1>
d.setHours(0, 0, 0, 0);
let dNow = new Date();
dNow.setHours(0, 0, 0, 0);
const diffTime = Math.abs(d - dNow);
const diffTime = d - dNow;
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));

item.tempoRestante = diffDays;
Expand All @@ -148,15 +148,30 @@ <h1 class="page-title">Concursos Literários em Português ✒</h1>
)

return this.usuarios
.filter(usuario => {
// filter out contests that ended
let dToday = new Date();
dToday.setHours(0, 0, 0, 0);

if (new Date(usuario.prazo) < dToday) {
return false;
}
return true;
})

// age filter
.filter(usuario => {
if (!this.ageFilter) {
return true;
}

let minAge = parseInt(usuario.id_min) || 0;
let maxAge = parseInt(usuario.id_max) || 150;
let writerAge = parseInt(this.ageFilter);
return writerAge >= minAge && writerAge <= maxAge;
})

// genre filter
.filter(usuario => {
if (usuario.obra.trim() == "") {
return true;
Expand Down

0 comments on commit 8e33fb7

Please sign in to comment.