This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch preview/calendar
in repository https://gitbox.apache.org/repos/asf/comdev-events-site.git


The following commit(s) were added to refs/heads/preview/calendar by this push:
     new 95955de  Reduce the number of changes from main
95955de is described below

commit 95955def28ec2f295bb6662682954e870c062f6f
Author: Sebb <s...@apache.org>
AuthorDate: Fri Apr 19 15:24:38 2024 +0100

    Reduce the number of changes from main
---
 static/js/events-calendar.js | 104 +++++++++++++++++++++----------------------
 1 file changed, 50 insertions(+), 54 deletions(-)

diff --git a/static/js/events-calendar.js b/static/js/events-calendar.js
index abd33ed..f5e2543 100644
--- a/static/js/events-calendar.js
+++ b/static/js/events-calendar.js
@@ -6,66 +6,62 @@ if (!events) {
   events = $('body').append("<ul id='events'/>");
 }
 
-function apply(response) {
-   events.empty();
-
-   var el = response['items'];
-   let reg = /T.*$/;
-   let official = /(ApacheCon|Roadshow|Community (O|o)ver Code)/;
-   if (el.length > 0) {
-      for (i = 0; i < el.length; i++) {
-         var ev = el[i];
-         var when = ev.start.dateTime;
-         if (!when) {
-            when = ev.start.date;
-         }
-         when = when.replace(reg,"");
-         if (ev.end) {
-           var end = ev.end.dateTime;
-           if (!end) {
-              end = ev.end.date;
-           }
-           end = end.replace(reg,"");
-           if (end != when) {
-              when = when + " to " + end;
-           }
-         }
-         var link = null;
-         if (ev.description) {
-            var line1 = ev.description.split("\n")[0];
-            if (line1.slice(0,7) === "http://"; ||
-                line1.slice(0,8) === "https://";
-            ) {
-               link = line1.trim();
-            }
-         }
-
-         var html = "<li>";
-         if (link) { html += "<a href='" + link + "'>"; }
-         if (ev.summary.match(official)) {
-             html += "<b>" + ev.summary + "</b>";
-         } else {
-             html += ev.summary;
-         }
-         if (link) { html += "</a>"; }
-         html += " - <i>" + when + "</i>";
-         if (ev.location) {
-            html += "<br/>"+ev.location;
-         }
-         events.append(html);
-      }
-   } else {
-      events.append("<li><i>No events found, sorry</i></li>");
-   }
-}
-
 // Fetch
 $.ajax({
     type: 'GET',
     url: encodeURI('/js/calendar.json'),
     dataType: 'json',
     success: function (response) {
-      apply(response);
+       events.empty();
+
+       var el = response['items'];
+       let reg = /T.*$/;
+       let official = /(ApacheCon|Roadshow|Community (O|o)ver Code)/;
+       if (el.length > 0) {
+          for (i = 0; i < el.length; i++) {
+             var ev = el[i];
+             var when = ev.start.dateTime;
+             if (!when) {
+                when = ev.start.date;
+             }
+             when = when.replace(reg,"");
+             if (ev.end) {
+               var end = ev.end.dateTime;
+               if (!end) {
+                  end = ev.end.date;
+               }
+               end = end.replace(reg,"");
+               if (end != when) {
+                  when = when + " to " + end;
+               }
+             }
+             var link = null;
+             if (ev.description) {
+                var line1 = ev.description.split("\n")[0];
+                if (line1.slice(0,7) === "http://"; ||
+                    line1.slice(0,8) === "https://";
+                ) {
+                   link = line1.trim();
+                }
+             }
+
+             var html = "<li>";
+             if (link) { html += "<a href='" + link + "'>"; }
+             if (ev.summary.match(official)) {
+                 html += "<b>" + ev.summary + "</b>";
+             } else {
+                 html += ev.summary;
+             }
+             if (link) { html += "</a>"; }
+             html += " - <i>" + when + "</i>";
+             if (ev.location) {
+                html += "<br/>"+ev.location;
+             }
+             events.append(html);
+          }
+       } else {
+          events.append("<li><i>No events found, sorry</i></li>");
+       }
     },
     error: function (response) {
        events.empty();

Reply via email to