PageSourceSearch

https://tapahtumateollisuus.fi/content/plugins/artcloud-blocks//sr…/load-more-ajax-call.js?ver=1.0

js tapahtumateollisuus.fi collected 2026-10-02 09:56:33 UTC 3,674 bytes, 116 lines download raw bytes

1jQuery(document).ready(function ($) {
2	const initialNumberOfItems = 3; // Change this to 6 for rendering 6 posts initially
3	$("#load_more_rss_style1").on("click", function (e) {
4		e.preventDefault();
5		const $this = $(this);
6		const offset = $this.data("offset");
7		const attributes = rssFeedAttr;
8
9		$.ajax({
10			url: artcloudAjax.ajaxurl,
11			type: "POST",
12			data: {
13				action: "artcloud_load_more_rss",
14				offset: offset,
15				attributes: attributes, // Send the entire attributes array
16				numberOfItems: initialNumberOfItems, // Send initial item count for server-side logic
17			},
18			beforeSend: function () {
19				$this.text("Ladataan...");
20			},
21			success: function (response) {
22				const items = response;
23				const $container = $(".container "); // Define $container here
24				const $newItemsRow = $("#artcloud-rss-feed");
25
26				items.forEach((item) => {
27					const itemDate = new Date(item.pubDate);
28					const options = {
29						timeZone: "Europe/Helsinki",
30						year: "numeric",
31						month: "2-digit",
32						day: "2-digit",
33						hour: "2-digit",
34						minute: "2-digit",
35						second: "2-digit",
36						hour12: false,
37					};
38					const formatter = new Intl.DateTimeFormat("en-US", options);
39					const eetDateTime = formatter.format(itemDate);
40
41					const $artcloudItem = $(
42						'<div class="artcloud-item col-4" style="background-color:' +
43							attributes.backgroundColor +
44							'"></div>',
45					);
46
47					if (attributes.displayFeaturedImage) {
48						const $artcloudPostImg = $('<div class="artcloud-rssImg"></div>');
49						const $img = $(
50							`<img src="${item.enclosure.link}" alt="rss-feed-image" width="300" />`,
51						);
52						$artcloudPostImg.append($img);
53						$artcloudItem.append($artcloudPostImg);
54					}
55
56					// Content container
57					const $artcloudContent = $('<div class="artcloud-content"></div>');
58
59					// Conditional date rendering
60					if (attributes.displayDateTime) {
61						$artcloudContent.append(
62							`<span style="color:${attributes.textColor}">${eetDateTime}</span>`,
63						);
64					}
65
66					// Title and link
67					$artcloudContent.append(
68						`<a href="${item.link}">
69							<h3 style="color:${attributes.textColor}">${item.title.slice(0, 80)}</h3>
70						</a>`,
71					);
72
73					// Conditional description rendering
74					if (attributes.displayDescription) {
75						$artcloudContent.append(
76							`<p style="color:${attributes.textColor}">${
77								item.description.slice(0, 170) + "..."
78							}</p>`,
79						);
80					}
81
82					$artcloudItem.append($artcloudContent);
83					$newItemsRow.append($artcloudItem);
84				});
85
86				function formatDateTime(dateTimeString) {
87					// Split date and time parts
88					const [datePart, timePart] = dateTimeString.split(", ");
89					// Reformat date to dd.mm.yyyy
90					const [month, day, year] = datePart.split("/");
91					const formattedDate = `${day.padStart(2, "0")}.${month.padStart(
92						2,
93						"0",
94					)}.${year}`;
95					// Reformat time to hh:mm:ss
96					const [hour, minute, second] = timePart.split(":");
97					const formattedTime = `${hour.padStart(2, "0")}:${minute}:${second}`;
98					// Combine formatted date, time, and time zone abbreviation
99					return `${formattedDate} ${formattedTime} EET`;
100				}
101
102				// Check if new items are already appended
103				$container.append($newItemsRow);
104				if (items.length < initialNumberOfItems) {
105					$this.hide(); // Hide the "Load More" button if no more items
106				}
107				$this.data("offset", offset + initialNumberOfItems);
108				$this.text("Näytä lisää");
109			},
110			error: function (jqXHR, textStatus, errorThrown) {
111				console.error("AJAX error:", textStatus, errorThrown);
112				// alert('Failed to load more items.');
113			},
114		});
115	});
116});

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.