From e6f767d81545f4d4705bc8bd415f4b104e11edba Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Thu, 2 May 2024 18:00:10 +0800 Subject: [PATCH] =?UTF-8?q?Add=20link=20to=20image=20title=20/=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=B6=85=E9=93=BE=E6=8E=A5=E5=88=B0=E9=95=9C=E5=83=8F?= =?UTF-8?q?=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/mod/allow-modify-image/mod.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/mod/allow-modify-image/mod.js b/app/mod/allow-modify-image/mod.js index cfbe269..464afe8 100644 --- a/app/mod/allow-modify-image/mod.js +++ b/app/mod/allow-modify-image/mod.js @@ -5,8 +5,23 @@ (function () { const observedAnchor = '.tab-content'; async function moduleFunction() { - const tabContents = document.querySelectorAll(observedAnchor) + const tabContents = document.querySelectorAll(observedAnchor); tabContents.forEach(tabContent => { + + // 增加超链接 + const tabPanels = tabContent.querySelectorAll(':scope > div'); + tabPanels.forEach(tabPanel => { + const imageLabel = tabPanel.querySelector('span > div:nth-child(1) > div > div > span.is-flex-grow-1 > div > label'); + const imageInput = tabPanel.querySelector('span > div:nth-child(1) > div > div > span.is-flex-grow-1 > div > div > input'); + linkToImage(); + imageInput.addEventListener('input', () => { linkToImage(); }); + function linkToImage() { + const imageURL = imageInput.value.includes('.') ? `https://${imageInput.value}` : `https://hub.docker.com/r/${imageInput.value}`; + imageLabel.innerHTML = `Docker 镜像 *`; + } + }); + + // 镜像可编辑 const inputElements = tabContent.querySelectorAll('input[readonly="readonly"]'); inputElements.forEach(inputElement => { inputElement.removeAttribute('readonly'); @@ -35,5 +50,5 @@ timeout = setTimeout(() => func.apply(this, args), wait); }; } - const debounced = debounce(moduleFunction, 1000); + const debounced = debounce(moduleFunction, 500); })(); \ No newline at end of file