Skip to content

Commit

Permalink
feat(index.html): query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuwn committed Jun 12, 2024
1 parent cc8ba21 commit 5d70b86
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,39 @@ <h2>Username</h2>
<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 = `![${inputValue}](${image.src})\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 = [
Expand Down

0 comments on commit 5d70b86

Please sign in to comment.