Loading...
 
Skip to main content

History: MenuPageBanner

Source of version: 10 (current)

Copy to clipboard
            {rss url="https://tiki.org/tiki-calendars_rss.php" max="1" date="1" desc="1" author="1" showtitle="1" ticker="1" sortBy="publication_date" sortOrder="ASC" tplWiki="rss_gabarit" refresh="360" }
{JQ()}
var $scope = $('.upcoming-event-banner');

  /**
   * Extracts the calendar item ID (calitemId) from a URL string
   * Handles both encoded and non-encoded URLs
   */
  function extractCalItemId(rawUrl) {
    if (!rawUrl) return null;
    var decoded = rawUrl;
    try { decoded = decodeURIComponent(rawUrl); } catch (e) {}
    var m = decoded.match(/(?:^|[?&])calitemId=([^&#]+)/i);
    return m ? m[1] : null;
  }

  /**
   * Builds the final iCal export URL from the extracted calitemId
   */
  function buildIcalUrl(id) {
    return 'https://tiki.org/tiki-calendar_export_ical.php?export=y&calendarItem=' + encodeURIComponent(id);
  }

  // 1) Convert <a> WITHOUT target="_blank" → iCal export link
  $scope.find('a:not([target="_blank"])').each(function () {
    var $a = $(this);
    var href = $a.attr('href');
    if (!href) return;

    // Skip if it's already an iCal export link
    if (/tiki-calendar_export_ical\.php/i.test(href)) return;

    // Try to extract calitemId from href or data-href
    var id = extractCalItemId(href) || (this.dataset && this.dataset.href ? extractCalItemId(this.dataset.href) : null);
    if (id) $a.attr('href', buildIcalUrl(id));
  });

  // 2) Convert <a> WITH target="_blank" → decode encoded URLs
  $scope.find('a[target="_blank"]').each(function () {
    var $a = $(this);
    var href = $a.attr('href');
    if (!href) return;

    // Only process if the URL is encoded (contains %3F, %3D, etc.)
    if (/%3F|%3D|%26|%2F/i.test(href)) {
      try {
        var decoded = decodeURIComponent(href);
        $a.attr('href', decoded);
      } catch (e) {
        // Fail silently if decoding throws an error
      }
    }
  });
{JQ}
        

History

Information Version
Wed 19 of Nov, 2025 14:00 UTC Alvin Bauma 10
Mon 18 of Aug, 2025 13:15 UTC Alvin Bauma 9
Fri 15 of Aug, 2025 15:08 UTC Alvin Bauma 8
Fri 15 of Aug, 2025 15:07 UTC Alvin Bauma 7
Wed 27 of Nov, 2024 14:33 UTC Alvin Bauma 6
Wed 27 of Nov, 2024 14:33 UTC Alvin Bauma 5
Mon 28 of Oct, 2024 11:34 UTC Gary Cunningham-Lee Changing cache time didn't make a difference so changed back to no cache. 4
Mon 28 of Oct, 2024 11:31 UTC Gary Cunningham-Lee Changed the cache time to one minute to see if it refreshes with correct information. 3
Wed 14 of Aug, 2024 10:33 UTC Alvin Bauma 2
Wed 14 of Aug, 2024 10:32 UTC Alvin Bauma 1