Browse Source

fix dates if no date is found

master
Thomas Rupprecht 2 years ago
parent
commit
c63516d962
  1. 2
      background/index.js
  2. 14
      popup/index.js

2
background/index.js

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

14
popup/index.js

@ -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…
Cancel
Save