function updateCalendar() {
  if (selectBeruf.options[selectBeruf.selectedIndex].value != 0 && selectKlasse.options[selectKlasse.selectedIndex].value != 0) {
    saveLastSetting();
    // Childs löschen
    clearCalendar();
    fetch('http://sandbox.gibm.ch/tafel.php?klasse_id=' + selectKlasse.options[selectKlasse.selectedIndex].value + '&woche=' + selectedYearWeek[1] + '-' + selectedYearWeek[0])
      .then((response) => {
        return response.json();
      })
      .then((data) => {
        if (data == false) {
          calendarInfo.innerText = 'Keine Daten vorhanden';
          return;
        }

        data.forEach((element, index) => {
          let div = document.createElement('div');
          let from = element.tafel_von;
          let to = element.tafel_bis;
          div.innerHTML = from.slice(0, -3) + '-' + to.slice(0, -3) + '<br>' + element.tafel_longfach + '<br>' + element.tafel_lehrer + '<br>' + element.tafel_raum;

          div.classList.add('bg-primary', 'appointment-prop', 'event', 'text-white');

          // If screen < 768px remove margin on top of appointment 
          if (window.innerWidth >= 768) {
            div.classList.add('position-absolute');
            let fromMin = toMinutes(from);
            let toMin = toMinutes(to);
            div.style.top = (fromMin - calendarStart) / 5 * intervalHeight + 'px';
            div.style.height = (toMin - fromMin) / 5 * intervalHeight + 'px';
          } else {
            // Add margin on bottom of appointment
            div.classList.add('mb-1');
          }
          document.getElementById('weekday-' + (element.tafel_wochentag - (element.tafel_wochentag == 0 ? (-6) : 1))).appendChild(div);
        });
      })
      .catch(function (error) {
        alert('API reagiert nicht, versuchen Sie es bitte erneut.')
        console.error('Fetch error (Tafel): ' + error);
      });
  }
}
/**
 * Fetching the data for the calendar and fill in the appointments
 */
Fetching the data for the calendar and fill in the appointments
Fetching the data for the calendar and fill in the appointments
function updateCalendar() {
  if (selectBeruf.options[selectBeruf.selectedIndex].value != 0 && selectKlasse.options[selectKlasse.selectedIndex].value != 0) {
    saveLastSetting();
    clearCalendar();
    fetch('http://sandbox.gibm.ch/tafel.php?klasse_id=' + selectKlasse.options[selectKlasse.selectedIndex].value + '&woche=' + selectedYearWeek[1] + '-' + selectedYearWeek[0])
      .then((response) => {
        return response.json();
      })
      .then((data) => {
        if (data == false) {
          calendarInfo.innerText = 'Keine Daten vorhanden';
          return;
        }
        data.forEach((element, index) => {
          let div = document.createElement('div');
          let from = element.tafel_von;
          let to = element.tafel_bis;
          div.innerHTML = from.slice(0, -3) + '-' + to.slice(0, -3) + '<br>' + element.tafel_longfach + '<br>' + element.tafel_lehrer + '<br>' + element.tafel_raum;
          div.classList.add('bg-primary', 'appointment-prop', 'event', 'text-white');
          if (window.innerWidth >= 768) {
            div.classList.add('position-absolute');
            let fromMin = toMinutes(from);
            let toMin = toMinutes(to);
            div.style.top = (fromMin - calendarStart) / 5 * intervalHeight + 'px';
            div.style.height = (toMin - fromMin) / 5 * intervalHeight + 'px';
          } else {
            div.classList.add('mb-1');
          }
          document.getElementById('weekday-' + (element.tafel_wochentag - (element.tafel_wochentag == 0 ? (-6) : 1))).appendChild(div);
        });
      })
      .catch(function (error) {
        alert('API reagiert nicht, versuchen Sie es bitte erneut.')
        console.error('Fetch error (Tafel): ' + error);
      });
  }
}
function updateCalendar ( ) { if ( selectBeruf . options [ selectBeruf . selectedIndex ] . value != 0 && selectKlasse . options [ selectKlasse . selectedIndex ] . value != 0 ) { saveLastSetting ( ) ; clearCalendar ( ) ; fetch ( 'http://sandbox.gibm.ch/tafel.php?klasse_id=' + selectKlasse . options [ selectKlasse . selectedIndex ] . value + '&woche=' + selectedYearWeek [ 1 ] + '-' + selectedYearWeek [ 0 ] ) . then ( ( response ) => { return response . json ( ) ; } ) . then ( ( data ) => { if ( data == false ) { calendarInfo . innerText = 'Keine Daten vorhanden' ; return ; } data . forEach ( ( element , index ) => { let div = document . createElement ( 'div' ) ; let from = element . tafel_von ; let to = element . tafel_bis ; div . innerHTML = from . slice ( 0 , - 3 ) + '-' + to . slice ( 0 , - 3 ) + '<br>' + element . tafel_longfach + '<br>' + element . tafel_lehrer + '<br>' + element . tafel_raum ; div . classList . add ( 'bg-primary' , 'appointment-prop' , 'event' , 'text-white' ) ; if ( window . innerWidth >= 768 ) { div . classList . add ( 'position-absolute' ) ; let fromMin = toMinutes ( from ) ; let toMin = toMinutes ( to ) ; div . style . top = ( fromMin - calendarStart ) / 5 * intervalHeight + 'px' ; div . style . height = ( toMin - fromMin ) / 5 * intervalHeight + 'px' ; } else { div . classList . add ( 'mb-1' ) ; } document . getElementById ( 'weekday-' + ( element . tafel_wochentag - ( element . tafel_wochentag == 0 ? ( - 6 ) : 1 ) ) ) . appendChild ( div ) ; } ) ; } ) . catch ( function ( error ) { alert ( 'API reagiert nicht, versuchen Sie es bitte erneut.' ) console . error ( 'Fetch error (Tafel): ' + error ) ; } ) ; } }
Fetching the data for the calendar and fill in the appointments
Fetching the data for the calendar and fill in the appointments
// Childs löschen
 // If screen < 768px remove margin on top of appointment 
 // Add margin on bottom of appointment
