From 8e33fb7ce6d78e51ddd5f7fd5f855e310e061ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20C=C3=A9sar?= Date: Sat, 7 Oct 2023 22:43:13 +0100 Subject: [PATCH] Hide ended contests --- docs/index.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index 69ecdd0..720e3ac 100644 --- a/docs/index.html +++ b/docs/index.html @@ -124,7 +124,7 @@

Concursos Literários em Português ✒

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; @@ -148,15 +148,30 @@

Concursos Literários em Português ✒

) 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;