possibly fixed ajax fetch
This commit is contained in:
@@ -78,6 +78,7 @@ class Partnerexpo_Core_Public {
|
||||
'title' => $post->post_title,
|
||||
'image' => get_the_post_thumbnail_url($post->ID),
|
||||
'excerpt' => $post->post_excerpt,
|
||||
'modif' => $post->post_modified,
|
||||
'url' => get_permalink($post),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -31,25 +31,25 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
let activeSortKey = "relevance";
|
||||
let results = []; // Fills via Ajax
|
||||
|
||||
// ---------- Sort Definitions ----------
|
||||
const SORTS = {
|
||||
relevance: {
|
||||
label: "Relevance",
|
||||
compare: (a, b) => (b.relevance - a.relevance) || (b.score - a.score)
|
||||
},
|
||||
score_desc: {
|
||||
label: "Score (high → low)",
|
||||
compare: (a, b) => (b.score - a.score)
|
||||
},
|
||||
date_desc: {
|
||||
label: "Date (new → old)",
|
||||
compare: (a, b) => new Date(b.updated) - new Date(a.updated)
|
||||
},
|
||||
title_asc: {
|
||||
label: "Title (A → Z)",
|
||||
compare: (a, b) => (a.title || "").localeCompare(b.title || "")
|
||||
}
|
||||
};
|
||||
// // ---------- Sort Definitions ----------
|
||||
// const SORTS = {
|
||||
// relevance: {
|
||||
// label: "Relevance",
|
||||
// compare: (a, b) => (b.relevance - a.relevance) || (b.score - a.score)
|
||||
// },
|
||||
// score_desc: {
|
||||
// label: "Score (high → low)",
|
||||
// compare: (a, b) => (b.score - a.score)
|
||||
// },
|
||||
// date_desc: {
|
||||
// label: "Date (new → old)",
|
||||
// compare: (a, b) => new Date(b.updated) - new Date(a.updated)
|
||||
// },
|
||||
// title_asc: {
|
||||
// label: "Title (A → Z)",
|
||||
// compare: (a, b) => (a.title || "").localeCompare(b.title || "")
|
||||
// }
|
||||
// };
|
||||
|
||||
// ---------- Helpers ----------
|
||||
function escapeHtml(str) {
|
||||
@@ -58,26 +58,24 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}[s]));
|
||||
}
|
||||
|
||||
// Generates HTML with the correct 'pexpo-core-' classes
|
||||
function cardEl(r) {
|
||||
const div = document.createElement("div");
|
||||
div.className = "pexpo-core-card";
|
||||
div.innerHTML = `
|
||||
<div class="pexpo-core-imageWrap">
|
||||
<img src="${escapeHtml(r.image_url || 'https://placehold.co/600x400')}"
|
||||
<img src="${escapeHtml(r.image || 'https://placehold.co/600x400')}"
|
||||
alt="${escapeHtml(r.title)}"
|
||||
style="width:100%; border-radius:10px; object-fit:cover;" />
|
||||
</div>
|
||||
<div class="pexpo-core-cardTop">
|
||||
<div class="pexpo-core-title">${escapeHtml(r.title)}</div>
|
||||
</div>
|
||||
<div class="pexpo-core-desc">${escapeHtml(r.desc)}</div>
|
||||
<div class="pexpo-core-desc">${escapeHtml(r.excerpt)}</div>
|
||||
<div class="pexpo-core-foot">
|
||||
<div class="pexpo-core-status">
|
||||
<span class="pexpo-core-dot"></span>
|
||||
score: <b style="margin-left:6px;color:rgba(16,24,40,.86)">${r.score}</b>
|
||||
</div>
|
||||
<div>${escapeHtml(r.updated)}</div>
|
||||
<div>${escapeHtml(r.modif)}</div>
|
||||
</div>
|
||||
`;
|
||||
return div;
|
||||
|
||||
Reference in New Issue
Block a user