PageSourceSearch

https://custardprint.co.uk/static/script/modules-v3/blog-articles.js?v=2023-04-17-1544

js custardprint.co.uk collected 2026-10-04 12:21:12 UTC 3,864 bytes, 126 lines download raw bytes

1var publicKey = document.currentScript.getAttribute('data-publicKey');
2
3$( document ).ready(function() {
4
5	populateBlogArticles();
6
7})
8
9function populateBlogArticles() {
10
11	var data = {}
12	data.url = $('section.dev .site-url').text() || location.hostname;
13	data.publicKey = publicKey;
14
15	var blogCategory = $('h1.blog-category-h1').attr('data-category-folder');
16	if (blogCategory) data.category = blogCategory;
17
18	$.getJSON('https://api.vb.media/v1/public/get-blog-articles/', data, function(blogData) {
19
20		// console.log('blogData: ' + JSON.stringify(blogData, null, '\t'));
21
22		if (blogData.data) {
23			var maxArticles = blogData.data.length
24			
25			$('.blog-group').each(function() {
26				
27				var id = $(this).closest('section').attr('id');
28				
29				var offset = parseInt($(this).attr('data-offset')) || 0;
30				var qtyRequested = $(this).attr('data-qty') == 'all' ? maxArticles - offset : parseInt($(this).attr('data-qty'));
31				var qtyToShow = qtyRequested > maxArticles ? maxArticles - offset : qtyRequested;
32				var sectionColumns = parseInt($(this).attr('data-columns'));
33				var sectionStyle = $(this).attr('data-style');
34				var blogHTMLClone = $(this).clone();
35				
36				var blogArticlesHTML = '';
37				
38				// console.log('sectionStyle:' + sectionStyle);
39				// console.log('sectionColumns:' + sectionColumns);
40
41				for (var i = offset ; i < (offset + qtyToShow) ; i++) {
42				
43					var count = i - offset;
44
45					var blogHTML = blogHTMLClone.clone();
46					var blog = blogData.data[i];
47
48					if (blog) {
49
50						var blogDate = blog.date ? formatTimestamp(blog.date, 'long') : null;
51						var imageSizeToUse = 'medium';
52						var maxWidth = 600
53						
54						
55						$('.item', blogHTML).attr('id', `${id}-${i}`);
56						$('a', blogHTML).attr('href', `/blog/${blog.folder}`);
57						$('h5', blogHTML).html(blog.title || '&nbsp;');
58						$('.date', blogHTML).html(blogDate || '&nbsp;');
59						$('.blurb', blogHTML).html(blog.description || '&nbsp;');
60					
61						if (blog.image?.handle === undefined) {
62
63							$('.image-wrap', blogHTML).remove();
64
65						} else {
66
67							var imageHeight = $('img', blogHTML).attr('data-height');
68							var sizingData = {
69								baseSize: 'm',
70								maxHeight: imageHeight,
71							};
72							
73							if (sectionStyle === 'grid') {
74
75								if (sectionColumns > 1) sizingData.layoutType = 'grid';
76
77								switch (parseInt(sectionColumns)) {
78									case 2:
79										if (i == 0) sizingData.startWidth = 1000;
80										else sizingData.startHeight = 400;
81										break;
82									case 3:
83									case 4:
84										if (i == 0) sizingData.startHeight = 650;
85										else if (count == 1) sizingData.startHeight = 450;
86										else sizingData.startHeight = 200;
87										break;
88									case 5:
89										if (i < 2) sizingData.startHeight = 450;
90										else if (i > 1 && i < 4) sizingData.startHeight = 350;
91										else sizingData.startHeight = 200;
92										break;
93									case 6:
94										if (i == 0 || i == 3) sizingData.startWidth = 450;
95										else if (i == 1 || i == 2) sizingData.startWidth = 350;
96										else sizingData.startHeight = 200;
97										break;
98								}
99
100							} else {
101								sizingData.setHeight = imageHeight;
102							}
103
104							var imageHTML = image(blog.image, sizingData);
105							
106							$('.image-wrap', blogHTML).html(imageHTML);
107						}
108						
109						blogArticlesHTML += blogHTML.html();
110					}
111				}
112				
113				$(this).html(blogArticlesHTML).closest('section').removeClass('loading').delay(300).queue(function() {
114					checkAnimations();
115					$(this).dequeue();
116					unbindRebind();
117				});;
118			})
119
120		} else {
121
122			$('section[data-type="blog-articles"]').html('<div data-text-align="center">Sorry, no articles available.</div>').attr('data-padding','20');
123
124		}
125	})
126}

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.