diff --git a/d2cli/static/favicon-err.ico b/d2cli/static/favicon-err.ico new file mode 100644 index 000000000..5619a4ebd Binary files /dev/null and b/d2cli/static/favicon-err.ico differ diff --git a/d2cli/static/favicon.ico b/d2cli/static/favicon.ico new file mode 100644 index 000000000..452e6dcf6 Binary files /dev/null and b/d2cli/static/favicon.ico differ diff --git a/d2cli/static/watch.js b/d2cli/static/watch.js index 71fa9436f..3cb3a75e1 100644 --- a/d2cli/static/watch.js +++ b/d2cli/static/watch.js @@ -28,7 +28,7 @@ function init(reconnectDelay) { // we can't just set `d2SVG.innerHTML = msg.svg` need to parse this as xml not html const parsedXML = new DOMParser().parseFromString(msg.svg, "text/xml"); d2SVG.replaceChildren(parsedXML.documentElement); - + changeFavicon("./static/favicon.ico"); const svgEl = d2SVG.querySelector("#d2-svg"); // just use inner SVG in watch mode svgEl.parentElement.replaceWith(svgEl); @@ -56,6 +56,7 @@ function init(reconnectDelay) { if (msg.err) { d2ErrDiv.innerText = msg.err; d2ErrDiv.style.display = "block"; + changeFavicon("./static/favicon-err.ico"); d2ErrDiv.scrollIntoView(); } }; @@ -73,3 +74,8 @@ function init(reconnectDelay) { }, reconnectDelay); }; } + +const changeFavicon = function (iconURL) { + const faviconLink = document.getElementById("favicon"); + faviconLink.href = iconURL; +}; diff --git a/d2cli/watch.go b/d2cli/watch.go index d1a2c64f0..6b1c5412c 100644 --- a/d2cli/watch.go +++ b/d2cli/watch.go @@ -429,6 +429,7 @@ func (w *watcher) handleRoot(hw http.ResponseWriter, r *http.Request) { %s +