diff options
| author | Bobby <[email protected]> | 2025-12-17 17:39:48 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-17 17:39:48 +0530 |
| commit | 392d61eb154bb284768a20815b2d58d9d9734182 (patch) | |
| tree | b8dd310fc48866eb1b2f32096688246ffccb2d68 | |
| parent | 1ca97f8cc71b9a3099f205e4f1ceb6ae664fc36e (diff) | |
| download | cgitconf-392d61eb154bb284768a20815b2d58d9d9734182.tar.xz cgitconf-392d61eb154bb284768a20815b2d58d9d9734182.zip | |
| -rw-r--r-- | head-include.html | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/head-include.html b/head-include.html index 17e06b5..8e05195 100644 --- a/head-include.html +++ b/head-include.html @@ -64,11 +64,14 @@ * The hex dump is moved into a <details> block below the image. */ function enhanceBlobPreview() { - const content = document.querySelector("div.content"); const binBlob = document.querySelector("table.bin-blob"); - const plainLink = document.querySelector('a[href*="/plain/"]'); + if (!binBlob) return; - if (!content || !binBlob || !plainLink) return; + const plainLink = document.querySelector('a[href*="/plain/"]'); + if (!plainLink) { + binBlob.style.display = "table"; + return; + } const url = plainLink.getAttribute("href"); const ext = getFileExtension(url); @@ -78,20 +81,23 @@ return; } + const content = document.querySelector("div.content"); + if (!content) { + binBlob.style.display = "table"; + return; + } + const img = new Image(); img.src = url; img.alt = "Rendered image"; img.onload = () => { - // Image preview const preview = document.createElement("div"); preview.className = "cgit-image-preview"; preview.appendChild(img); - // Insert preview before hex dump content.insertBefore(preview, binBlob); - // Wrap hex dump in <details> const details = document.createElement("details"); details.className = "cgit-hexdump"; |
