Small JS rewrite
Slightly rewrote the JavaScript on the main page.
I didn't like how it looked before. Then again, I don't think I'm happy with having to rely on JavaScript at all right now.
Slightly rewrote the JavaScript on the main page.
I didn't like how it looked before. Then again, I don't think I'm happy with having to rely on JavaScript at all right now.
by steve0greatness, Monday, 8 July 2024, 13:11:00 (1720444260), pushed by steve0greatness, Tuesday, 28 January 2025, 07:34:16 (1738049656)
Author identity: Steve0Greatness <steve0greatnessiscool@gmail.com>
7cbedf8c5263ccffb0ab1e2e0c146c3afb1af904
</li>
</template>
<script>
(async function() {
<script type="text/javascript">
const ThemeListElementTemplate = document.querySelector("#ThemeListElement");
const HTMLThemeList = document.querySelector("#ThemeList");
const ThemeList = await fetch("themes.xml")
.then(res => res.text())
.then(txt => {
const parser = new DOMParser();
const doc = parser.parseFromString(txt, "text/xml");
return doc;
});
const ThemeListElementTemplate = document.querySelector("#ThemeListElement");
const HTMLThemeList = document.querySelector("#ThemeList");
ListThemes();
async function ListThemes() {
const ThemeList = await GetXMLDoc("themes.xml");
const themes = ThemeList.querySelectorAll("theme");
for (let index = 0; index < themes.length; index++) {
const theme = themes[index];
const ThemeIndex = CreateThemeListElement(
title = theme.querySelector("title").textContent,
authorname = theme.querySelector("author").textContent,
authorlink = theme.querySelector("author").getAttribute("uri"),
path = theme.querySelector("uri").textContent
);
HTMLThemeList.appendChild(ThemeIndex);
}
}
const title = theme.querySelector("title").textContent;
const author = theme.querySelector("author");
const path = theme.querySelector("uri").textContent;
function CreateThemeListElement(title, authorname, authorlink, path) {
const ListEl = ThemeListElementTemplate.content.cloneNode(true);
ListEl.querySelector(".theme-name").textContent = title;
ListEl.querySelector(".download").href = "themes/" + path;
const ListEl = ThemeListElementTemplate.content.cloneNode(true);
ListEl.querySelector(".theme-name").textContent = title;
ListEl.querySelector(".download").href = "themes/" + path;
const Author = ListEl.querySelector(".author-url");
Author.textContent = authorname;
Author.href = authorlink;
const Author = ListEl.querySelector(".author-url");
Author.href = author.getAttribute("uri");
Author.textContent = author.textContent;
HTMLThemeList.appendChild(ListEl);
}
return ListEl;
}
})();
function GetXMLDoc(path) {
return new Promise(async (resolve, reject) => {
const PlaintextXML = await fetch(path).then(response => response.text());
const XML_DOM = new DOMParser().parseFromString(PlaintextXML, "text/xml");
resolve(XML_DOM);
});
}
</script>
</body>