No Events -> Hide event section. Added Autolinker.js

This commit is contained in:
m11 2021-02-01 23:30:45 +01:00
parent 5b763171d1
commit 8a1594b805
4 changed files with 63 additions and 24 deletions

View File

@ -4,11 +4,11 @@ layout: default
<div class="container"> <div class="container">
<h1>Termine</h1> <h1>Termine</h1>
<hr />
<h3>Coronabedingt sind die Clubräume derzeit geschlossen. Alle Termine finden virtuell statt.</h3> <h3>Coronabedingt sind die Clubräume derzeit geschlossen. Alle Termine finden virtuell statt.</h3>
<hr />
<h2>Events</h2> <h2 id="hevents">Events</h2>
<div id="calendar"> <div id="calendar">
Loading Events, please stand by … Loading Events, please stand by …
@ -38,5 +38,7 @@ layout: default
</div> </div>
<script src="js/ical.min.js"></script> <script src="js/ical.min.js"></script>
<script src="js/Autolinker.min.js"></script>
<script src="js/calv2.js"></script> <script src="js/calv2.js"></script>

25
js/Autolinker.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
js/Autolinker.min.js.map Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,26 @@
var autolinker = new Autolinker( {
urls : {
schemeMatches : true,
wwwMatches : true,
tldMatches : true
},
email : true,
phone : true,
mention : false,
hashtag : false,
stripPrefix : true,
stripTrailingSlash : true,
newWindow : true,
truncate : {
length : 0,
location : 'end'
},
className : ''
} );
var eventList = [] var eventList = []
var recurringEventList = [] var recurringEventList = []
var cancelledEvents = {} var cancelledEvents = {}
@ -44,7 +67,6 @@ Event.prototype.toHTML = function () {
var div_description = document.createElement('div') var div_description = document.createElement('div')
div_description.setAttribute('class', 'cal_descriptionbox') div_description.setAttribute('class', 'cal_descriptionbox')
//div_description.appendChild(span_summary)
var span_description = document.createElement('div') var span_description = document.createElement('div')
span_description.setAttribute('class', 'cal_description') span_description.setAttribute('class', 'cal_description')
@ -52,7 +74,7 @@ Event.prototype.toHTML = function () {
if (this.description !== null) { if (this.description !== null) {
var span_description = document.createElement('span') var span_description = document.createElement('span')
span_description.setAttribute('class', 'cal_description') span_description.setAttribute('class', 'cal_description')
span_description.appendChild(document.createTextNode(this.description)) span_description.innerHTML = autolinker.link( this.description )
} }
div_description.appendChild(span_description) div_description.appendChild(span_description)
@ -134,34 +156,18 @@ Event.prototype.toHTML = function () {
div_cal.appendChild(div_description) div_cal.appendChild(div_description)
if (this.description !== null) { if (this.description !== null) {
var parts = this.description.split(/\r\n|\r|\n/)
parts.map(function (i) {
var span_description = document.createElement('span') var span_description = document.createElement('span')
span_description.setAttribute('class', 'cal_description') span_description.setAttribute('class', 'cal_description')
words = i.split(' ') span_description.innerHTML = autolinker.link( this.description )
words.forEach(function(word) {
if (word.match(/(ht|f)tps?\:\/\//i)) {
var a = document.createElement('a')
a.setAttribute('href', word)
a.appendChild(document.createTextNode(word))
span_description.appendChild(a)
} else {
span_description.appendChild(document.createTextNode(word))
}
span_description.appendChild(document.createTextNode(' '))
})
div_description.appendChild(span_description) div_description.appendChild(span_description)
})
} }
// if (this.event.component.getFirstPropertyValue("status") == "CANCELLED") { // if (this.event.component.getFirstPropertyValue("status") == "CANCELLED") {
// div_cal.style.textDecoration = 'line-through' // div_cal.style.textDecoration = 'line-through'
// } // }
} }
return div_cal return div_cal
@ -181,7 +187,6 @@ function parseIcalData(data) {
events.map(function (e) { events.map(function (e) {
var event = new ICAL.Event(e) var event = new ICAL.Event(e)
if (event.component.getFirstPropertyValue("status") == "CANCELLED") { if (event.component.getFirstPropertyValue("status") == "CANCELLED") {
// console.log(event)
if (!(cancelledEvents[event.uid] instanceof Array)) { if (!(cancelledEvents[event.uid] instanceof Array)) {
cancelledEvents[event.uid] = [] cancelledEvents[event.uid] = []
} }
@ -224,6 +229,7 @@ function orderEvents() {
function writeEvents() { function writeEvents() {
var cal = document.getElementById('calendar') var cal = document.getElementById('calendar')
cal.textContent = '' cal.textContent = ''
// TODO: Wenn EventList leer, dann Event-Abschnitt ausblenden // TODO: Wenn EventList leer, dann Event-Abschnitt ausblenden
@ -231,8 +237,12 @@ function writeEvents() {
eventList.map(function (e) { eventList.map(function (e) {
cal.appendChild(e.toHTML()) cal.appendChild(e.toHTML())
}) })
} else { } else {
cal.textContent = 'No events found.'
cal.style.display = "none";
var hevents = document.getElementById('hevents')
hevents.style.display = "none";
} }
var calRecur = document.getElementById('calendar-recurring') var calRecur = document.getElementById('calendar-recurring')
@ -245,6 +255,7 @@ function writeEvents() {
} else { } else {
calRecur.textContent = 'No events found.' calRecur.textContent = 'No events found.'
} }
} }
function xhrRequest(url, callback, fail) { function xhrRequest(url, callback, fail) {