Skip to content

Commit

Permalink
for 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
d3netxer committed Nov 2, 2022
1 parent d4ec646 commit 5e7741e
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,35 +165,48 @@ <h3><a href="{{site.baseurl}}/{{post.permalink}}">{{ post.title }}</a></h3>
console.log('response is ok');
events = json;
console.log('print events');
console.log(events);
console.log(events.length);
//initialize();

events.sort(function(a,b){
const filter = events.filter(checkDates);

function checkDates(a) {
return new Date(a.date).getTime() > 0;
}

console.log('print filter');
console.log(filter);

filter.sort(function(a,b){

if(isNaN(new Date(a.date).getTime())) {
return 1-isNaN(new Date(b.date).getTime());
} else {
return (new Date(b.date).getTime()) - (new Date(a.date).getTime());
}
// Turn your strings into dates, and then subtract them
// to get a value that is either negative, positive, or zero.
return new Date(b.date) - new Date(a.date);

});

document.querySelector('#event_counter').textContent = events.length;


for (i = 0; i < 3; i++) {

console.log(events[i]);
console.log(filter[i]);

var t = document.querySelector('#mytemplate');


t.content.querySelector('#title').textContent = events[i].event_name;
t.content.querySelector('#date').textContent = events[i].date;
t.content.querySelector('#title').textContent = filter[i].event_name;
t.content.querySelector('#date').textContent = filter[i].date;

// add to document DOM
var clone = document.importNode(t.content, true); // where true means deep copy
document.querySelector('#insert3events').appendChild(clone);

}


});
} else {
console.log('Network request for products.json failed with response ' + response.status + ': ' + response.statusText);
Expand Down

0 comments on commit 5e7741e

Please sign in to comment.