event.item['author-avatar'],
event.item['author-name'],
event.item.desc,
- formatEventLocationText(event.item.location)
+ htmlToText(event.item.location)
));
break;
case "agendaDay":
event.item['author-avatar'],
event.item['author-name'],
event.item.desc,
- formatEventLocationText(event.item.location)
+ htmlToText(event.item.location)
));
break;
case "listMonth":
// Get only template data if there exists location data
if (event.item.location) {
- var eventLocationText = formatEventLocationText(event.item.location);
+ var eventLocationText = htmlToText(event.item.location);
// Get the the html template for formatting the location
var eventLocationTemplate = eventHoverLocationTemplate();
// Format the event location data according to the the event location
return formatted;
}
-
-// Format event location in pure text
-function formatEventLocationText(location) {
- // Friendica can store the event location as text or as html
- // We need to check if the location is html. In this case we need
- // to transform it into clean text
- if (location.startsWith("<div")) {
- var locationHtml = $.parseHTML( location );
- var eventLocationText = locationHtml[0]['innerText'];
- } else {
- var eventLocationText = location.replace("<br>", " ");
- };
-
- return eventLocationText;
-}
\ No newline at end of file
$(elm).animate(colWhite, 1000).animate(colShiny).animate(colWhite, 600);
});
}
+
+// format a html string to pure text
+function htmlToText(htmlString) {
+ // Replace line breaks with spaces
+ var text = htmlString.replace(/<br>/g, ' ');
+ // Strip the text out of the html string
+ text = text.replace(/<[^>]*>/g, '');
+
+ return text;
+}