]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frio/js/mod_events.js
Merge pull request #3488 from annando/ptobr-no-cache
[friendica.git] / view / theme / frio / js / mod_events.js
index 7b06990fad05959480c2820e5b8560b668246a42..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":
@@ -131,16 +131,14 @@ function eventHoverBodyTemplate() {
                                <div class="hover-card-header left-align">\
                                        <div class="event-hover-left-date left-align">\
                                                <span class="event-date-wrapper medium">\
-                                                       <span class="event-hover-short-month">{6}</span>\
-                                                       <span class="event-hover-short-date">{7}</span>\
+                                                       <span class="event-hover-short-month">{5}</span>\
+                                                       <span class="event-hover-short-date">{6}</span>\
                                                </span>\
                                        </div>\
                                        <div class="event-card-content media-body">\
-                                               <div class="event-hover-title">{3}</div>\
-                                               <div class="event-property"><span class="event-hover-date">{5}</span>{4}\
-                                               <div class="event-hover-profile-name profile-entry-name">\
-                                                       <span class="left-align1"><a href="{1}" class="userinfo">{2}</a></span>\
-                                               </div>\
+                                               <div class="event-hover-title">{2}</div>\
+                                               <div class="event-property"><span class="event-hover-date">{4}</span>{3}\
+                                               {1}\
                                        </div>\
                                </div>\
                                <div class="clearfix"></div>\
@@ -156,9 +154,17 @@ function eventHoverLocationTemplate() {
        return template;
 }
 
+function eventHoverProfileNameTemplate() {
+       var template = '\
+                       <div class="event-hover-profile-name profile-entry-name">\
+                               <span class="left-align1"><a href="{0}" class="userinfo">{1}</a></span>\
+                       </div>';
+       return template;
+}
 // transform the event data to html so we can use it in the event hover-card 
 function eventHoverHtmlContent(event) {
        var eventLocation = '';
+       var eventProfileName = '';
        // Get the Browser language
        var locale = window.navigator.userLanguage || window.navigator.language;
        var data = '';
@@ -176,7 +182,7 @@ function eventHoverHtmlContent(event) {
        var endTime = moment(event.item.finish).format('HH:mm');
        var monthNumber;
 
-       var formattedDate = startDate
+       var formattedDate = startDate;
 
        // We only need the to format the end date if the event does have
        // a finish date. 
@@ -195,9 +201,9 @@ function eventHoverHtmlContent(event) {
        // Get the html template
        data = eventHoverBodyTemplate();
 
-       // Get only template data if there exist location data
-       if (event.item.location != '') {
-               var eventLocationText = formatEventLocationText(event.item.location);
+       // Get only template data if there exists location data
+       if (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
@@ -207,11 +213,21 @@ function eventHoverHtmlContent(event) {
                );
        }
 
+       // Get only template data if there exists a profile name
+       if (event.item['author-name']) {
+               // Get the template
+               var eventProfileNameTemplate = eventHoverProfileNameTemplate();
+               // Insert the data into the template
+               eventProfileName = eventProfileNameTemplate.format(
+                                       event.item['author-link'],
+                                       event.item['author-name']
+               );
+       }
+
        // Format the event data according to the event hover template
        var formatted = data.format(
                                event.item['author-avatar'], // this isn't used at the present time
-                               event.item['author-link'],
-                               event.item['author-name'],
+                               eventProfileName,
                                event.title,
                                eventLocation,
                                formattedDate,
@@ -236,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