const cacheBuster = Math.floor(new Date().getTime() / (1000 * 60 * 5)); fetch("./data.json?cacheBuster=" + cacheBuster) .then((response) => response.json()) .then((data) => { const osList = ["linux", "darwin", "windows", "docker"]; const releases = data.releases; const osData = osList.map((os) => { const data = releases.map((release) => { const binaries = release.binaries.filter((binary) => { return binary.os === os; }); return { version: release.version, os: os, binaries, }; }); if (os === "darwin") { os = "macOS"; } return { os: os, stable: data.filter((release) => !release.version.includes("rc")), rc: data.filter((release) => release.version.includes("rc")), }; }); const stableTabContainer = document.getElementById("tab-container"); const rcTabContainer = document.getElementById("rc-tab-container"); const stableContainer = document.getElementById("stable-data"); const stableNoData = document.getElementById("stable-no-data"); const rcContainer = document.getElementById("rc-data"); const rcNoData = document.getElementById("rc-no-data"); if (osData) { let stableLength = 0; let rcLength = 0; osData.map((os) => { stableLength += os.stable.length; rcLength += os.rc.length; }); if (stableLength === 0) { stableContainer.style.display = "none"; stableNoData.style.display = "block"; } if (rcLength === 0) { rcContainer.style.display = "none"; rcNoData.style.display = "block"; } } osData.map((os, idx) => { const tabContent = document.createElement("div"); tabContent.setAttribute("id", os.os); tabContent.classList.add("tabcontent"); tabContent.setAttribute("data-type", "stable"); if (idx === 0) { tabContent.classList.add("active"); } let eventIdsToAdd = []; const html = os.stable.map((release, index) => { eventIdsToAdd.push(`${release.version}-${os.os}`); let cls = "panel"; if (index === 0) { cls += " panel-active"; } let als = "accordion"; if (index === 0) { als += " accordion-active"; } return `
${ release.binaries.length === 0 ? ` ` : "" } ${release.binaries .map((binary) => { // create horizontal html table in the return return ` `; }) .join("")}
Binary Arch File Checksum Tag
No binaries available
${binary.name} ${binary.arch} ${binary.file_name} ${binary.checksum} ${binary.tag}
`; }); tabContent.innerHTML = html.join(""); stableTabContainer.appendChild(tabContent); eventIdsToAdd.forEach((id) => { const element = document.getElementById(`${id}`); if (element) { element.addEventListener("click", () => { openAccordion(id); }); } }); eventIdsToAdd = []; }); function openAccordion(accordionId) { const panel = document.getElementById(accordionId + "-panel"); const accordion = document.getElementById(accordionId); if (accordion.classList.contains("accordion-active")) { accordion.classList.remove("accordion-active"); } else { accordion.classList.add("accordion-active"); } if (panel.classList.contains("panel-active")) { panel.classList.remove("panel-active"); } else { panel.classList.add("panel-active"); } } }); function openTab(evt, tabId, dataType) { // Declare all variables let i, tabcontent, tablinks; // Get all elements with dataType attribute and hide them tabcontent = document.querySelectorAll(`[data-type=${dataType}]`); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } // Get all elements with class="tablinks" and remove the class "active" tablinks = document.getElementsByClassName(`tablinks-${dataType}`); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace("active", ""); } // Show the current tab, and add an "active" class to the button that opened the tab document.getElementById(tabId).style.display = "block"; evt.currentTarget.className += " active"; }