PageSourceSearch

https://www.safeopedia.com/wp-content/themes/starter-theme/dist/js/topics-homepage.js?ver=1

js safeopedia.com collected 2026-10-02 10:17:00 UTC 3,670 bytes, 146 lines download raw bytes

1(function ($) {
2	$('#pills-tab').find('a[data-toggle="pill"]').on('shown.bs.tab', function (e) {
3		topicArticlesLoaded();
4	});
5
6	setTimeout(function () {
7		topicArticlesLoaded();
8	}, 100);
9
10	$('.manual-more').hide();
11
12	$('#taglist').change(function () {
13		var tag = $(this).find(":selected").val(),
14			containerName = $(this).find(":selected").data('container');
15
16		changeTopic(tag, containerName);
17	});
18
19	$('#topics-list').find('a.article-tag-link').click(function (e) {
20		e.preventDefault();
21
22		var containerName = $(this).data('container'),
23			tag = $(this).data('tag');
24
25		$('#taglist').val(tag);
26
27		changeTopic(tag, containerName);
28
29		return false;
30	});
31
32	function changeTopic(tag, containerName) {
33		var divContainer = $('#pills-topics'); // set it on the div because it will always be on the page
34		var ajaxurl = divContainer.data('ajaxurl'); // Get the ajaxurl from the div's data attribute
35
36		$('#article-topics-wrapper').find('.topic-articles').addClass('d-none');
37		var $container = $('#article-topics-wrapper').find('div[data-container="' + containerName + '"]');
38		$container.removeClass('d-none');
39
40		// if ($container.data('loaded') === false) {
41		// 	// Load the articles
42		// 	$.ajax({
43		// 		url: ajaxurl,
44		// 		type: 'post',
45		// 		data: {
46		// 			action: 'load_more_tag_topics',
47		// 			tagId: tag,
48		// 			p: 1
49		// 		}
50		// 	})
51		// 		.done(function (r) {
52		// 			$container.find('.row').html(r);
53		// 			$container.data('loaded', "true");
54		// 			topicArticlesLoaded();
55		// 		});
56		// }
57
58		scrollToElement('article-topics-wrapper');
59    }
60
61	$('#article-topics-wrapper').on('click', '.action-moretagarticles', function (e) {
62		var $btn = $(this);
63
64		$btn.attr('disabled', true).html('Loading more articles...');
65
66		var tag = $btn.data('tag'),
67			nextPage = $btn.data('nextpage');
68
69		// Update data-nextpage value
70		var newNextPage = nextPage + 1;
71		$btn.data('nextpage', newNextPage);
72
73		var $container = $btn.closest('.row');
74		var ajaxurl = $btn.data('ajaxurl'); // Get the ajaxurl from the button's data attribute
75
76		$.ajax({
77			url: ajaxurl,
78			type: 'post',
79			data: {
80				action: 'load_more_tag_topics',
81				tagId: tag,
82				p: newNextPage
83			}
84		})
85			.done(function (r) {
86				$container.append(r);
87				topicArticlesLoaded();
88
89			})
90			.always(function (r) {
91				$btn.closest('div').remove();
92				$btn.remove();
93			});
94	});
95
96	$('#latest-articles-wrapper').on('click', '.action-loadmorelatest', function (e) {
97		var $btn = $(this);
98		$btn.attr('disabled', true).html('Loading more articles...');
99		var ajaxurl = $btn.data('ajaxurl'); // Get the ajaxurl from the button's data attribute
100
101		var nextPage = $btn.data('nextpage');
102
103		var $moreLatestContainer = $('#latest-articles-container');
104
105		$.ajax({
106			url: ajaxurl,
107			type: 'post',
108			data: {
109				action: 'load_more_latest_articles',
110				p: nextPage
111			}
112		})
113			.done(function (r) {
114				$moreLatestContainer.append(r);
115
116				// Update the nextPage value
117				nextPage = parseInt(nextPage) + 1;
118				$btn.data('nextpage', nextPage);
119
120			})
121			.always(function (r) {
122				$btn.closest('div').remove();
123				$btn.remove();
124			});
125
126
127	});
128
129	$('.topic-articles').on('show').trigger('loadTopicArticles');
130
131	var topicArticlesLoaded = function () {
132		if ($('.topic-articles:visible').length) {
133			$('.topic-articles').find('.card-top').sameHeight();
134			$('.topic-articles').find('.card').sameHeight();
135        }
136		
137		$('#sub-featured-wrapper').find('.card:visible').sameHeight();
138
139		if ($('#trending-articles-wrapper:visible').length) {
140			$('#trending-articles-wrapper').find('.card-top').sameHeight();
141			$('#trending-articles-wrapper').find('.card').sameHeight();
142        }
143		
144	};
145
146})(jQuery);

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.