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">
<h1>Termine</h1>
<hr />
<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">
Loading Events, please stand by …
@ -38,5 +38,7 @@ layout: default
</div>
<script src="js/ical.min.js"></script>
<script src="js/Autolinker.min.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 recurringEventList = []
var cancelledEvents = {}
@ -44,7 +67,6 @@ Event.prototype.toHTML = function () {
var div_description = document.createElement('div')
div_description.setAttribute('class', 'cal_descriptionbox')
//div_description.appendChild(span_summary)
var span_description = document.createElement('div')
span_description.setAttribute('class', 'cal_description')
@ -52,7 +74,7 @@ Event.prototype.toHTML = function () {
if (this.description !== null) {
var span_description = document.createElement('span')
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)
@ -134,34 +156,18 @@ Event.prototype.toHTML = function () {
div_cal.appendChild(div_description)
if (this.description !== null) {
var parts = this.description.split(/\r\n|\r|\n/)
parts.map(function (i) {
var span_description = document.createElement('span')
span_description.setAttribute('class', 'cal_description')
words = i.split(' ')
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(' '))
})
span_description.innerHTML = autolinker.link( this.description )
div_description.appendChild(span_description)
})
}
// if (this.event.component.getFirstPropertyValue("status") == "CANCELLED") {
// div_cal.style.textDecoration = 'line-through'
// }
}
return div_cal
@ -181,7 +187,6 @@ function parseIcalData(data) {
events.map(function (e) {
var event = new ICAL.Event(e)
if (event.component.getFirstPropertyValue("status") == "CANCELLED") {
// console.log(event)
if (!(cancelledEvents[event.uid] instanceof Array)) {
cancelledEvents[event.uid] = []
}
@ -224,6 +229,7 @@ function orderEvents() {
function writeEvents() {
var cal = document.getElementById('calendar')
cal.textContent = ''
// TODO: Wenn EventList leer, dann Event-Abschnitt ausblenden
@ -231,8 +237,12 @@ function writeEvents() {
eventList.map(function (e) {
cal.appendChild(e.toHTML())
})
} 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')
@ -245,6 +255,7 @@ function writeEvents() {
} else {
calRecur.textContent = 'No events found.'
}
}
function xhrRequest(url, callback, fail) {