Make linter happy
This commit is contained in:
parent
cd5aef5c23
commit
7d58465d73
1 changed files with 38 additions and 37 deletions
|
@ -33,44 +33,45 @@ function getEvents(number, callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
fetch('https://launchlibrary.net/1.3/launch/next/1')
|
fetch('https://launchlibrary.net/1.3/launch/next/1')
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const launches = res.launches.map((launch) => {
|
const launches = res.launches.map((launch) => {
|
||||||
return {
|
const start = new Date(launch.windowstart);
|
||||||
allDay: false,
|
const end = new Date(launch.windowend);
|
||||||
start: new Date(launch.windowstart).toISOString(),
|
return {
|
||||||
end: new Date(launch.windowend).toISOString(),
|
allDay: false,
|
||||||
title: launch.name,
|
start: start.toISOString(),
|
||||||
id: launch.lsp.abbrev,
|
end: end.toISOString(),
|
||||||
type: 'launch',
|
title: launch.name,
|
||||||
};
|
id: launch.lsp.abbrev,
|
||||||
|
type: 'launch',
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const events = current.concat(upcoming, launches);
|
||||||
|
events.sort((a, b) => {
|
||||||
|
if (a.start < b.start) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (a.start > b.start) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
return callback(events.slice(0, number));
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
const events = current.concat(upcoming);
|
||||||
|
events.sort((a, b) => {
|
||||||
|
if (a.start < b.start) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (a.start > b.start) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
return callback(events.slice(0, number));
|
||||||
});
|
});
|
||||||
const events = current.concat(upcoming, launches);
|
|
||||||
events.sort((a, b) => {
|
|
||||||
if (a.start < b.start) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (a.start > b.start) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
console.log(events.slice(0, number));
|
|
||||||
return callback(events.slice(0, number));
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
const events = current.concat(upcoming);
|
|
||||||
events.sort((a, b) => {
|
|
||||||
if (a.start < b.start) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (a.start > b.start) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
return callback(events.slice(0, number));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let prevDate = new Date();
|
let prevDate = new Date();
|
||||||
|
|
Loading…
Reference in a new issue