Great things are coming soon
Stay tuned
Powered by
GoDaddy
document.addEventListener('DOMContentLoaded', function () {
const main = document.querySelector('.fcmo-jobs-main');
if (!main) return;
const listing = main.querySelector('.jobs-listing-wrapper');
if (!listing || listing.dataset.fcmoReady) return;
listing.dataset.fcmoReady = '1';
/* Create split layout */
const split = document.createElement('div');
split.className = 'fcmo-split-jobs';
const left = document.createElement('div');
left.className = 'fcmo-jobs-left';
const preview = document.createElement('div');
preview.className = 'fcmo-job-preview';
preview.innerHTML = 'Loading job…
';
listing.parentNode.insertBefore(split, listing);
left.appendChild(listing);
split.appendChild(left);
split.appendChild(preview);
/* Load job into right-side preview */
async function loadJob(url, article) {
if (!url) return;
preview.innerHTML =
'Loading job…
';
main.querySelectorAll('.jobs-wrapper article')
.forEach(el => el.classList.remove('fcmo-active-job'));
if (article) article.classList.add('fcmo-active-job');
try {
const response = await fetch(url);
const html = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const header = doc.querySelector('.job-detail-header');
const description = doc.querySelector('.job-detail-description');
const details = doc.querySelector('.job-detail-detail');
if (!header && !description) {
window.location.href = url;
return;
}
preview.innerHTML = '';
if (header)
preview.appendChild(header.cloneNode(true));
if (description)
preview.appendChild(description.cloneNode(true));
if (details)
preview.appendChild(details.cloneNode(true));
} catch (e) {
window.location.href = url;
}
}
/* Job clicks */
main.addEventListener('click', function (e) {
const link = e.target.closest('.job-title a');
if (!link) return;
/* On tablet/mobile use normal page */
if (window.innerWidth <= 1000) return;
e.preventDefault();
const article = link.closest('article');
loadJob(link.href, article);
});
/* Load first job automatically */
const firstLink = main.querySelector('.job-title a');
if (firstLink && window.innerWidth > 1000) {
loadJob(firstLink.href, firstLink.closest('article'));
}
});