diff --git a/frontend/frontend.js b/frontend/frontend.js index cd30dce..a2c15f2 100644 --- a/frontend/frontend.js +++ b/frontend/frontend.js @@ -11,6 +11,11 @@ function zerocalcareDisplay() { } for (i in json_obj) { + // Do not display private events + if (typeof json_obj[i]['CLASS'] === 'string' && json_obj[i]['CLASS'] == 'PRIVATE') { + continue; + } + // Future improvements needed for a better backend output date in ISO format // Now we have to parse the string :( very very ugly var date = new Date(json_obj[i]['DATETIME']); @@ -26,23 +31,60 @@ function zerocalcareDisplay() { titleElement.classList.add('widget-title'); var dateElement = document.createElement('div'); - dateElement.appendChild(document.createTextNode('📅 ' + m.format('dddd D MMMM YYYY') )); + var dateText = document.createElement('span'); + dateText.appendChild(document.createTextNode(m.format('dddd D MMMM YYYY'))); + dateElement.appendChild(document.createTextNode('📅 ')); + dateElement.appendChild(dateText); var timeElement = document.createElement('div'); + var timeText = document.createElement('span'); var timeString = (json_obj[i]['ALLDAY'] == true) ? 'Tutto il giorno' : ('ore ' + m.format('HH:mm')); - timeElement.appendChild(document.createTextNode('⏰ ' + timeString)); + timeText.appendChild(document.createTextNode(timeString)); + timeElement.appendChild(document.createTextNode('⏰ ')); + timeElement.appendChild(timeText); + // add if location is not empty -- default location should be selected by backend var locationElement = document.createElement('div'); + var locationText = document.createElement('span'); if (typeof json_obj[i]['LOCATION'] !== 'undefined' && json_obj[i]['LOCATION'] != '') { - var locationString = json_obj[i]['LOCATION']; + locationText.appendChild(document.createTextNode(json_obj[i]['LOCATION'])); } else { - var locationString = 'Officina Informatica'; + locationText.appendChild(document.createTextNode('Officina Informatica')); } - locationElement.appendChild(document.createTextNode('📍 ' + locationString)); - + locationElement.appendChild(document.createTextNode('📍 ')); + locationElement.appendChild(locationText); + eventElement.appendChild(titleElement); + // Check if event is not confirmed + if (typeof json_obj[i]['STATUS'] === 'string') { + if (json_obj[i]['STATUS'] == 'TENTATIVE') { + // Make the text a bit lighter and italic + dateText.style.fontStyle = + timeText.style.fontStyle = + locationText.style.fontStyle = 'italic'; + dateText.style.color = + timeText.style.color = + locationText.style.color = 'gray'; + // Add note + var unconfirmedElement = document.createElement('div'); + unconfirmedElement.style.fontWeight = 'bold'; + unconfirmedElement.appendChild(document.createTextNode('⚠️ Non confermato!')); + eventElement.appendChild(unconfirmedElement); + } + else if (json_obj[i]['STATUS'] == 'CANCELLED') { + // Strike time, date and location to remark this concept + dateText.style.textDecoration = 'line-through'; + timeText.style.textDecoration = 'line-through'; + locationText.style.textDecoration = 'line-through'; + // Add note + var unconfirmedElement = document.createElement('div'); + unconfirmedElement.style.fontWeight = 'bold'; + unconfirmedElement.appendChild(document.createTextNode('⚠️ Cancellato!')); + eventElement.appendChild(unconfirmedElement); + } + } eventElement.appendChild(dateElement); eventElement.appendChild(timeElement); eventElement.appendChild(locationElement); diff --git a/getInfo.py b/getInfo.py index 8193ff6..8779d0c 100755 --- a/getInfo.py +++ b/getInfo.py @@ -124,7 +124,11 @@ def getEvents(baseDay, interval): repetition['until'] = repetition['until'].date() except: repetition['until'] = None - + elif k[0] == 'CLASS': + # Store a boolean flag. True if PRIVATE + event_dict['CLASS'] = k[1] + elif k[0] == 'STATUS': + event_dict['STATUS'] = k[1] # If single event push into list if repetition['single'] == True: events += [event_dict]