PageSourceSearch

https://www.wellbeingintlstudiesrepository.org/assets/scripts/xmlCarousel.js

js wellbeingintlstudiesrepository.org collected 2026-10-02 03:51:04 UTC 2,044 bytes, 59 lines download raw bytes

1// process mrss file and return HTML for carousel
2function process_mrss(xml) {
3    var html = '';
4    var $items = $(xml).find('item');
5    $items.each(function() {
6      var $item = $(this);
7      var title = $item.find('title').first().text();
8      var description_node = $item.find('description').text();
9      var description = succint($(description_node).text().trim(), 240);
10      var link = $item.find('link').text();
11      var media_content = $item.find('media\\:content, content').attr('url');
12
13      // write items to carousel HTML
14      html += '<article>';
15      html += '<div class="text-content">';
16      html += '<h2>' + title + '</h2>';
17      html += '<p class="carousel-text">' + description + '</p>';
18      html += '<a href="' + link + '" target="_blank" class="button-link read-more">View More</a>';
19      html += '</div>';
20      html += '<div class="image-content">';
21      html += '<a href="' + link + '" target="_blank" class="image-link">';
22      html += '<img src="' + media_content + '" alt="' + title + '">';
23      html += '</a>';
24      html += '</div>';
25      html += '</article>';
26    });
27    return html;
28}
29
30// shorten text to 'limit' chars, stripping special chars off the end and adding ellipsis '...'
31function succint(text, limit) {
32	if (text.length > limit) {
33  	return $.trim(text).substring(0, limit).split(' ').slice(0, -1).join(' ').replace(/[!-\/:-@\[-`{-~]$/, '') + '...';
34  } else {
35    return $.trim(text);
36  }
37}
38
39// after page loads, ajax for MRSS/XML feed
40$(document).ready(function() {
41  // only run if there is a carousel on the page
42if ($carousel != undefined && $carousel.length > 0) {
43    // ajax to get MRSS/XML feed
44    $.ajax({
45      type: 'GET',
46      dataType: 'xml',
47      url: crossdomain_rss_url(mrss_url),
48      success: function(xml) {
49        var carousel_html = process_mrss(xml);
50        $carousel.html(carousel_html);
51        $carousel.slippry(slippry_options);
52      },
53      error: function(xhr, status, text) {
54        console.log(status + ': ' + text);
55      }
56    });
57	}
58});
59

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.