- Replaced all remaining 'Civicomfy' references with 'HuggingFace' - Updated JavaScript extension name and button text - Fixed all UI component references - Updated console logs and error messages - Changed extension registration name - Updated CSS and image paths This should fix the missing button issue in ComfyUI
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
// File: web/js/utils/dom.js
|
|
|
|
/**
|
|
* Dynamically adds a CSS link to the document's head.
|
|
* It resolves the path relative to this script's location using import.meta.url,
|
|
* making it robust against case-sensitivity issues and different install paths.
|
|
* @param {string} relativeHref - Relative path to the CSS file (e.g., '../huggingfaceDownloader.css').
|
|
* @param {string} [id="huggingface-downloader-styles"] - The ID for the link element.
|
|
*/
|
|
export function addCssLink(relativeHref, id = "huggingface-downloader-styles") {
|
|
if (document.getElementById(id)) return; // Prevent duplicates
|
|
|
|
try {
|
|
const absoluteUrl = new URL(relativeHref, import.meta.url);
|
|
|
|
const link = document.createElement("link");
|
|
link.id = id;
|
|
link.rel = "stylesheet";
|
|
link.href = absoluteUrl.href;
|
|
|
|
link.onload = () => {
|
|
console.log("[HuggingFace] CSS loaded successfully:", link.href);
|
|
};
|
|
link.onerror = () => {
|
|
console.error("[HuggingFace] Critical error: Failed to load CSS from:", link.href);
|
|
};
|
|
|
|
document.head.appendChild(link);
|
|
} catch (e) {
|
|
console.error("[HuggingFace] Error creating CSS link. import.meta.url may be unsupported in this context.", e);
|
|
}
|
|
}
|