Skip to content

Commit 592a558

Browse files
authored
Update certManager.js
1 parent dad1cfb commit 592a558

File tree

1 file changed

+19
-33
lines changed

1 file changed

+19
-33
lines changed

web/certManager.js

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ function parseCertTable(md) {
3737
// split by '|' and trim
3838
const parts = line.split("|").map(p => p.trim());
3939
// expected parts: ["", "Company", "Type", "Status", "Valid From", "Valid To", "Download", ""]
40-
// guard: ensure at least 7 meaningful columns
41-
const meaningful = parts.filter((p, idx) => p !== "" || (idx > 0 && idx < parts.length - 1));
42-
// We'll read by indexes, but check boundary
4340
const company = parts[1] || "";
4441
const type = parts[2] || "";
4542
const statusRaw = parts[3] || "";
@@ -93,35 +90,25 @@ function decodeSafe(u) {
9390
/* ---------- Rendering ---------- */
9491

9592
function renderRecommended(md) {
96-
// find the Recommend Certificate section
97-
// README uses:
98-
// # Recommend Certificate
99-
// **China Telecommunications Corporation V2 - ❌ Revoked**
100-
//
101-
// We'll capture the next non-empty line and strip stars.
10293
const lines = md.split("\n");
10394
let idx = lines.findIndex(l => l.trim().toLowerCase().startsWith("# recommend certificate"));
10495
let rec = "";
10596
if (idx !== -1) {
106-
// find first non-empty line after the header
10797
for (let i = idx + 1; i < lines.length; i++) {
10898
const ln = lines[i].trim();
10999
if (!ln) continue;
110-
// strip ** and md markup
111100
rec = ln.replace(/\*\*/g, "").trim();
112-
// remove surrounding markdown quote markers or other noise
113101
rec = rec.replace(/^>\s?/, "").trim();
114102
break;
115103
}
116104
}
117105

118106
const el = document.getElementById("recommended");
119107
if (!rec) {
120-
el.style.display = "none";
108+
if (el) el.style.display = "none";
121109
return;
122110
}
123-
// show plain text (no bold)
124-
el.innerHTML = `<h3>⭐ Recommended Certificate</h3><p>${escapeHtml(rec)}</p>`;
111+
if (el) el.innerHTML = `<h3>⭐ Recommended Certificate</h3><p>${escapeHtml(rec)}</p>`;
125112
}
126113

127114
function renderCertCards(certs) {
@@ -183,20 +170,11 @@ function renderUpdates(md) {
183170

184171
for (let i = 0; i < lines.length; i++) {
185172
let line = lines[i].trim();
186-
187173
if (!line) continue;
188174
if (line.startsWith("#")) break;
189-
190-
// 🚫 ignore markdown dividers like ---
191175
if (line === "---") continue;
192-
193-
// strip bold markers
194176
line = line.replace(/\*\*/g, "").trim();
195-
196-
// only keep real update lines
197-
if (line.length > 2) {
198-
updates.push(line);
199-
}
177+
if (line.length > 2) updates.push(line);
200178
}
201179

202180
if (!updates.length) {
@@ -212,27 +190,35 @@ function renderUpdates(md) {
212190
/* ---------- Modal ---------- */
213191
function openModal(c) {
214192
const modal = document.getElementById("certModal");
193+
if (!modal) return;
194+
215195
document.getElementById("modalName").textContent = c.company;
216196
document.getElementById("modalMeta").textContent = `${c.type} • Status: ${c.status || (c.status === "" ? "Unknown" : c.status)}`;
217197
document.getElementById("modalDates").textContent = `Valid: ${c.validFrom}${c.validTo}`;
218198

199+
// Hide/remove the modal-note if present (removes the Disclaimer)
200+
const noteEl = document.getElementById("modalNote");
201+
if (noteEl) {
202+
noteEl.innerHTML = "";
203+
noteEl.style.display = "none";
204+
}
205+
219206
const dl = document.getElementById("modalDownload");
220207
dl.innerHTML = "";
221208
if (c.download) {
209+
// Create a single anchor that shows the (decoded) URL as the button/text.
222210
const a = document.createElement("a");
223211
a.href = c.download;
224212
a.target = "_blank";
225213
a.rel = "noopener noreferrer";
226-
a.textContent = "Download";
214+
// Show a decoded URL for readability (falls back to original if decode fails)
215+
a.textContent = decodeSafe(c.download);
216+
a.className = "download-link";
217+
// Make it look/behave like a button if you want CSS for .download-link
218+
a.setAttribute("role", "button");
227219
dl.appendChild(a);
228220

229-
// also show raw url (small)
230-
const small = document.createElement("div");
231-
small.style.marginTop = "8px";
232-
small.style.fontSize = "12px";
233-
small.style.color = "var(--muted)";
234-
small.textContent = c.download;
235-
dl.appendChild(small);
221+
// NOTE: we intentionally do NOT add a small raw URL under the button — per request.
236222
} else {
237223
dl.innerHTML = `<div style="color:var(--muted);">No download link found.</div>`;
238224
}

0 commit comments

Comments
 (0)