PlaceholderAPI/docs/assets/js/latest-release.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-01-13 15:59:50 +01:00
document$.subscribe(async => {
const api_code = document.querySelectorAll('[data-md-component="api-version"]');
function loadAPIInfo(data) {
const version = data["version"];
const versionToken = "{version}";
for (const codeBlock of api_code) {
codeBlock.innerHTML = codeBlock.innerHTML.replace(new RegExp(versionToken, 'g'), version);
}
}
async function fetchAPIInfo() {
2024-09-26 01:36:07 +02:00
const release = await fetch("https://repo.extendedclip.com/api/maven/latest/version/releases/me/clip/placeholderapi").then(_ => _.json());
console.log(release)
2024-01-13 15:59:50 +01:00
const data = {
2024-09-26 01:36:07 +02:00
"version": release.version
2024-01-13 15:59:50 +01:00
}
__md_set("__api_tag", data, sessionStorage);
loadAPIInfo(data);
}
if(location.href.includes("/developers/using-placeholderapi")) {
const cachedApi = __md_get("__api_tag", sessionStorage);
if ((cachedApi != null) && (cachedApi["version"])) {
loadAPIInfo(cachedApi);
} else {
fetchAPIInfo();
}
}
})