	<script>
		let avatarSize = 240 // getting double size to account for retina screens
		let userCount = 56
		let militaryUserCount = 32
		let containerHeight = (avatarSize / 2) * 4

		// Only get enough users based on user's device (dont get 56 users on mobile if we only have the space to show 15)
		// we only get results in odd numbers
		if (window.innerWidth > 1440) {
			userCount = 84
		} else if (window.innerWidth < 430) { // mobile (iPhone 6/7)
		  userCount = 24
		  militaryUserCount = 20
	   } else if (window.innerWidth < 1025 ) {
			militaryUserCount = 28
			userCount = 36
			avatarSize = 160 // will be 80px when displayed (retina adjustment). decrease avatar size on mobile devices so that we can show more users (85px seems to fit 5 users in a row)
		}
		
// 		let 
// 		  Application = 'uk',
// 		  Sex = 'notSet',
// 		  Count = 56,
// 		  ShowMilitaryOnly = false	
			
		let BASE_URL = `https://fpp-api-production.fpp.workers.dev/most-popular?Width=${avatarSize}`
// 		let BASE_URL = `https://api-stg.forcespenpals.net/v1/snapshot/most-popular`
// 		let ENDPOINT_URL = `${BASE_URL}?Application=${Application}&Sex=${Sex}&Count=${Count}&ShowMilitaryOnly=${ShowMilitaryOnly}`
		let militaryUsersUrl, popularUsersUrl

    // Determine which site the user is on
		if (location.host === 'www.forcespenpals.co.uk' || location.href.startsWith('https://forcespenfriends.com/gb')  || location.href.startsWith('https://forcespenpals.net/gb')) {
			Application = 'uk'
			militaryUsersUrl = `${BASE_URL}&Application=${Application}&Count=${militaryUserCount}&ShowMilitaryOnly=true&Sex=m`
			popularUsersUrl = `${BASE_URL}&Application=${Application}&Count=${userCount}`
    } else if (location.host === 'www.forcespenpals.net' || location.href.startsWith('https://forcespenfriends.com/us') || location.href.startsWith('https://forcespenpals.net/us')) {
			Application = 'us'
			militaryUsersUrl = `${BASE_URL}&Application=${Application}&Count=${militaryUserCount}&Sex=m`
			popularUsersUrl = `${BASE_URL}&Application=${Application}&Count=${userCount}`
		}


		// Fetch Users
		async function fetchUsers(url) {
		  let response = await fetch(url)
		  return await response.json()
		}

		// Render a single user by extracting details from user object
		// Styles are in a separate CSS file
		function renderUser(user) {
				let { id, username, image_url } = user
				let profile_url = `https://app.forcespenpals.net/#profile/${id}`

				let userElement = `<div class="user">
									<!-- <a href="${profile_url}"> -->
										<img class="userImage" src="${image_url}" alt="${username}" />
										<div class="imageOverlay"></div>
										<div class="userName">${username}</div>
									<!-- </a> -->
								</div>`
				return userElement
		}

		// Get military users - Header block
		fetchUsers(militaryUsersUrl).then(data => {
			// console.info('popular miltary users', data)

			// Add a container and map data
			// Important: You need to assign the `militaryUsers` CSS ID to the element where you use the shortcde
			jQuery("#militaryUsers").append(`
				<div id="militaryUsersContainer">
					<div id="militaryUserGrid"></div>
					<div class="textOverlay">Proud of our armed forces? <br/><small class="subheading">Tell them personally.</small></div>
				</div>`)

			data.popular_users.map(user => jQuery("#militaryUserGrid").append(renderUser(user)))
		})

		// Populate webpage with user images - Footer block
		fetchUsers(popularUsersUrl).then(data => {
			// console.info('popular users', data);

			// Add a container and map data
			// Important: You need to assign the `popularUsers` CSS ID to the element where you use the shortcde
			jQuery("#popularUsers").append(`
				<div id="popularUsersContainer">
					<div id="userGrid"></div>
					<div class="textOverlay">...Over ${data.total_registered_users} people have already joined us...</div>
				</div>`)

			// TODO: get this number of users who have joined dynamically
			data.popular_users.map(user => jQuery("#userGrid").append(renderUser(user)))
		})

	</script>

<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//forcespenpals.net/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<url>
		<loc>https://forcespenpals.net/</loc>
		<lastmod>2024-10-30T09:21:31+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2019/06/default-news-thumbnail-1.jpg</image:loc>
		</image:image>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/plugins/fpp-country-site-selector/img/uk.png</image:loc>
		</image:image>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/plugins/fpp-country-site-selector/img/us.png</image:loc>
		</image:image>
	</url>
	<url>
		<loc>https://forcespenpals.net/contact/</loc>
		<lastmod>2020-01-23T09:38:37+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2019/06/default-news-thumbnail-1.jpg</image:loc>
		</image:image>
	</url>
	<url>
		<loc>https://forcespenpals.net/news-editorial-team/</loc>
		<lastmod>2020-03-26T05:40:42+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2019/06/default-news-thumbnail-1.jpg</image:loc>
		</image:image>
	</url>
	<url>
		<loc>https://forcespenpals.net/write-to-soldiers/</loc>
		<lastmod>2020-11-02T12:56:38+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2019/06/default-news-thumbnail-1.jpg</image:loc>
		</image:image>
	</url>
	<url>
		<loc>https://forcespenpals.net/history/</loc>
		<lastmod>2021-11-23T10:56:36+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2019/06/default-news-thumbnail-1.jpg</image:loc>
		</image:image>
	</url>
	<url>
		<loc>https://forcespenpals.net/home/</loc>
		<lastmod>2022-01-02T20:49:26+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2019/06/default-news-thumbnail-1.jpg</image:loc>
		</image:image>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2020/01/FPP_Logo_2x.png</image:loc>
		</image:image>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2020/02/DailyMail.png</image:loc>
		</image:image>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2020/02/datingadvice-e1581582966408.png</image:loc>
		</image:image>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2020/02/TheDailyTelegraph.png</image:loc>
		</image:image>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2020/11/fpp_successs_story_grid_2@0.5x-1.png</image:loc>
		</image:image>
	</url>
	<url>
		<loc>https://forcespenpals.net/support-soldiers/</loc>
		<lastmod>2022-01-25T10:37:09+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2019/06/default-news-thumbnail-1.jpg</image:loc>
		</image:image>
	</url>
	<url>
		<loc>https://forcespenpals.net/glossary/</loc>
		<lastmod>2022-01-27T08:21:39+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2019/06/default-news-thumbnail-1.jpg</image:loc>
		</image:image>
	</url>
	<url>
		<loc>https://forcespenpals.net/success-stories/</loc>
		<lastmod>2022-01-27T09:53:35+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2020/11/fpp_successs_story_grid@0.5x.png</image:loc>
		</image:image>
	</url>
	<url>
		<loc>https://forcespenpals.net/terms-and-conditions/</loc>
		<lastmod>2022-06-09T08:30:00+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2019/06/default-news-thumbnail-1.jpg</image:loc>
		</image:image>
	</url>
	<url>
		<loc>https://forcespenpals.net/privacy/</loc>
		<lastmod>2022-06-09T11:31:08+00:00</lastmod>
		<image:image>
			<image:loc>https://forcespenpals.net/wp-content/uploads/2019/06/default-news-thumbnail-1.jpg</image:loc>
		</image:image>
	</url>
</urlset>
<!-- XML Sitemap generated by Yoast SEO -->