Populating metadata
This commit is contained in:
27
history.js
27
history.js
@@ -11,18 +11,38 @@ function formatDate(ms) {
|
||||
}
|
||||
}
|
||||
|
||||
function formatMeta(entry) {
|
||||
const key = entry && entry.key ? entry.key : "n/a";
|
||||
const bpm = entry && entry.bpm ? entry.bpm : "n/a";
|
||||
const tags = entry && Array.isArray(entry.tags) && entry.tags.length ? entry.tags.join(", ") : "n/a";
|
||||
return `Key: ${key} | BPM: ${bpm} | Tags: ${tags}`;
|
||||
}
|
||||
|
||||
function buildItem(entry) {
|
||||
const li = document.createElement("li");
|
||||
li.className = "history-item";
|
||||
|
||||
if (entry.coverImageUrl) {
|
||||
const cover = document.createElement("img");
|
||||
cover.className = "history-cover-image";
|
||||
cover.src = entry.coverImageUrl;
|
||||
cover.alt = "Cover art";
|
||||
cover.loading = "lazy";
|
||||
li.appendChild(cover);
|
||||
}
|
||||
|
||||
const url = document.createElement("p");
|
||||
url.className = "history-url";
|
||||
url.textContent = entry.fullUrl || entry.url || "";
|
||||
url.textContent = entry.fileName || entry.sampleId || "(unknown filename)";
|
||||
|
||||
const meta = document.createElement("p");
|
||||
meta.className = "history-meta";
|
||||
const mode = entry.fullUrl ? "full candidate" : "preview fallback";
|
||||
meta.textContent = `Captured: ${formatDate(entry.capturedAt)} | Mode: ${mode} | Source: ${entry.source || "unknown"}`;
|
||||
const mode = entry.mode === "full" || entry.fullUrl ? "full candidate" : "preview fallback";
|
||||
meta.textContent = `Captured: ${formatDate(entry.capturedAt)} | Mode: ${mode} | Source: ${entry.source || "unknown"} | ID: ${entry.sampleId || "n/a"}`;
|
||||
|
||||
const details = document.createElement("p");
|
||||
details.className = "history-meta";
|
||||
details.textContent = formatMeta(entry);
|
||||
|
||||
const download = document.createElement("button");
|
||||
download.type = "button";
|
||||
@@ -41,6 +61,7 @@ function buildItem(entry) {
|
||||
|
||||
li.appendChild(url);
|
||||
li.appendChild(meta);
|
||||
li.appendChild(details);
|
||||
li.appendChild(download);
|
||||
return li;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user