(function () {
var grid = document.getElementById("jobs-grid");
var status = document.getElementById("jobs-status");
var fallback = document.getElementById("jobs-fallback");
var updated = document.getElementById("jobs-updated");
if (!grid) return;
function safeText(value) { return String(value || ""); }
function detail(label, value) {
if (!value) return "";
return '' + label + '' + safeText(value) + '';
}
function card(job, index) {
var article = document.createElement("article");
article.className = "job-card reveal visible";
article.style.setProperty("--card-delay", (index * 70) + "ms");
var top = document.createElement("div");
top.className = "job-card-top";
var number = document.createElement("span");
number.className = "job-number";
number.textContent = String(index + 1).padStart(2, "0");
var badge = document.createElement("span");
badge.className = "job-badge";
badge.textContent = "Now hiring";
top.append(number, badge);
var title = document.createElement("h3");
title.textContent = safeText(job.title);
var meta = document.createElement("div");
meta.className = "job-meta";
[
["Location", job.location || "See Indeed"],
["Compensation", job.pay || "See Indeed"],
["Employment", job.employment || "See Indeed"],
["Schedule", job.schedule || "See Indeed"]
].forEach(function (item) { var field = document.createElement("span"); field.innerHTML = '' + item[0] + ''; field.append(document.createTextNode(item[1])); meta.append(field); });
var description = document.createElement("p");
description.textContent = safeText(job.description || "Review the full position details, qualifications, and application instructions on Indeed.");
var link = document.createElement("a");
link.href = job.url || "https://www.indeed.com/cmp/Task-Force-Protection/jobs";
link.target = "_blank";
link.rel = "noopener";
link.innerHTML = 'View position ↗';
article.append(top, title, meta, description, link);
return article;
}
var verifiedJobs = [
{
title: "Armed Security Officer (Overnight)",
location: "Wilmington, NC 28403",
pay: "$18 an hour",
employment: "Full-time",
schedule: "Overnight · 8-hour shift",
description: "Provide a professional security presence during overnight operations. Review the complete responsibilities, qualifications, and application instructions on Indeed.",
url: "https://www.indeed.com/cmp/Task-Force-Protection/jobs"
},
{
title: "Unarmed Security Officer",
location: "Wilmington, NC",
pay: "$16 an hour",
employment: "Full-time or part-time",
schedule: "24–40 hours · Multiple shifts",
description: "Join our security team in Wilmington with full-time or part-time scheduling. Review the complete responsibilities, qualifications, and application instructions on Indeed.",
url: "https://www.indeed.com/cmp/Task-Force-Protection/jobs"
}
];
status.hidden = true;
verifiedJobs.forEach(function (job, index) { grid.appendChild(card(job, index)); });
updated.textContent = "Current openings verified on Indeed. Confirm availability and apply on Indeed.";
var controller = new AbortController();
var timeout = setTimeout(function () { controller.abort(); }, 10000);
fetch("/api/jobs", { headers: { accept: "application/json" }, signal: controller.signal })
.then(function (response) { if (!response.ok) throw new Error("Unavailable"); return response.json(); })
.then(function (data) {
clearTimeout(timeout);
status.hidden = true;
if (!data.jobs || !data.jobs.length) return;
grid.replaceChildren();
data.jobs.forEach(function (job, index) { grid.appendChild(card(job, index)); });
if (data.updatedAt) {
var date = new Date(data.updatedAt);
updated.textContent = (data.fallback ? "Listings last verified " : (data.stale ? "Last confirmed " : "Openings synced ")) + date.toLocaleString([], { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" }) + ". Confirm availability and apply on Indeed.";
}
})
.catch(function () { clearTimeout(timeout); status.hidden = true; });
})();