forked from XimeX/usrspace-browser-addon
fix dates if no date is found
This commit is contained in:
parent
31e4a3375a
commit
c63516d962
|
@ -2,7 +2,7 @@ const fetchJson = (url) => {
|
|||
return fetch(url).then((response) => (response.json()));
|
||||
};
|
||||
|
||||
const fetchCalendar = (days = null) => {
|
||||
const fetchCalendar = (days = 28) => {
|
||||
let url = Config.calenderUrl + '?o=json';
|
||||
if (days) {
|
||||
url += '&r=' + days;
|
||||
|
|
|
@ -20,12 +20,20 @@ browser.runtime.getBackgroundPage().then((page) => {
|
|||
});
|
||||
|
||||
const updateNextEvent = (nextEvents) => {
|
||||
const nextEventDate = nextEvents[0].begin.substr(0, 10);
|
||||
const nextEventDateEvents = nextEvents.filter((nextEvent) => (nextEvent.begin.startsWith(nextEventDate)));
|
||||
|
||||
const calendarElement = document.getElementById('calendar');
|
||||
calendarElement.innerText = '';
|
||||
|
||||
if (nextEvents.length === 0) {
|
||||
const hintNode = document.createTextNode('Keine Termine in den nächsten 4 Wochen!');
|
||||
const strongElement = document.createElement('strong');
|
||||
strongElement.append(hintNode);
|
||||
calendarElement.append(strongElement);
|
||||
return;
|
||||
}
|
||||
|
||||
const nextEventDate = nextEvents[0].begin.substr(0, 10);
|
||||
const nextEventDateEvents = nextEvents.filter((nextEvent) => (nextEvent.begin.startsWith(nextEventDate)));
|
||||
|
||||
nextEventDateEvents.forEach((nextEventDateEvent) => {
|
||||
const divElement = document.createElement('div');
|
||||
divElement.innerHTML = '<img src="../icons/font-awesome/clock-regular.svg" width="19" height="19" alt="Clock" />';
|
||||
|
|
Loading…
Reference in a new issue