]> git.mxchange.org Git - friendica.git/commitdiff
frio: better handling of event location in event hover cards
authorrabuzarus <>
Mon, 17 Oct 2016 20:58:30 +0000 (22:58 +0200)
committerrabuzarus <>
Mon, 17 Oct 2016 20:58:30 +0000 (22:58 +0200)
view/theme/frio/js/mod_events.js
view/theme/frio/js/theme.js

index 4e900d06ca0e85dbb4b67746602af099329b279a..5bd7c944986b3fe8db4481b91775ee4416a81ecd 100644 (file)
@@ -56,7 +56,7 @@ $(document).ready(function() {
                                                        event.item['author-avatar'],
                                                        event.item['author-name'],
                                                        event.item.desc,
-                                                       formatEventLocationText(event.item.location)
+                                                       htmlToText(event.item.location)
                                        ));
                                break;
                                case "agendaDay":
@@ -66,7 +66,7 @@ $(document).ready(function() {
                                                        event.item['author-avatar'],
                                                        event.item['author-name'],
                                                        event.item.desc,
-                                                       formatEventLocationText(event.item.location)
+                                                       htmlToText(event.item.location)
                                        ));
                                        break;
                                case "listMonth":
@@ -203,7 +203,7 @@ function eventHoverHtmlContent(event) {
 
        // 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
@@ -252,18 +252,3 @@ function formatListViewEvent(event) {
 
        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
index ffe82c24a502a9327385377a8ec227deef113d93..8fbee06e51721c2ae7b78bf590fcbf6c5fb76108 100644 (file)
@@ -570,3 +570,13 @@ function scrollToItem(itemID) {
                $(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;
+}