diff options
| author | Fuwn <[email protected]> | 2024-06-12 08:38:42 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-12 08:38:42 -0700 |
| commit | 5d70b86bb06095fd890aac0746dff3a41dc421bf (patch) | |
| tree | de0583a66e28e50d478942f5e9547b2e5ceacd9e | |
| parent | cc8ba2138c8a471426359a6a87273dcc8a6d7333 (diff) | |
| download | mayu-0.1.7.tar.xz mayu-0.1.7.zip | |
feat(index.html): query parametersv0.1.7
| -rw-r--r-- | index.html | 27 |
1 files changed, 23 insertions, 4 deletions
@@ -253,20 +253,39 @@ <img src="" alt="Mascot" class="mascot" title="Mascot" /> <script> + const themeQueryParameter = new URLSearchParams( + window.location.search + ).get("theme"); + const defaultConfiguration = { + id: new URLSearchParams(window.location.search).get("id") || "demo", + theme: themeQueryParameter || "asoul", + }; let inputTimeout; const idInput = document.getElementById("idInput"); const themeSelect = document.getElementById("themeSelect"); const image = document.getElementById("example"); const copyCodesInput = document.getElementById("copy-codes"); - let inputValue = "demo"; - let themeValue = "asoul"; + let inputValue = defaultConfiguration.id; + let themeValue = defaultConfiguration.theme; const setCopyCodes = () => { copyCodesInput.innerText = `\n\n<img src="${image.src}" alt="${inputValue}" />`; }; const set = () => { - inputValue = idInput.value || "demo"; - themeValue = themeSelect.value || "asoul"; + if (idInput.value === "" || idInput.value === null) { + idInput.value = defaultConfiguration.id; + } else { + inputValue = idInput.value; + } + + if (themeQueryParameter) { + themeValue = themeQueryParameter; + themeSelect.value = themeValue; + } else { + themeValue = themeSelect.value; + } + image.src = `https://counter.due.moe/get/@${inputValue}?theme=${themeValue}`; + setCopyCodes(); }; const mascots = [ |