forked from mne-tools/mne-python
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
async function getRelease() { | ||
result = await fetch("https://api.github.com/repos/mne-tools/mne-installers/releases/latest"); | ||
data = await result.json(); | ||
return data; | ||
} | ||
async function warnVersion() { | ||
let outer = document.createElement("div"); | ||
let title = document.createElement("p"); | ||
let inner = document.createElement("p"); | ||
outer.setAttribute("class", "admonition warning"); | ||
title.setAttribute("class", "admonition-title"); | ||
title.innerText = "Warning"; | ||
data = await getRelease(); | ||
// Take v1.5.1 for example and change to 1.5 | ||
ids = ["linux-installers", "macos-intel-installers", "macos-apple-installers", "windows-installers"]; | ||
warn = false; | ||
ids.forEach((id) => { | ||
console.log(id) | ||
label_id = document.getElementById(id); | ||
// tab is immediately after label | ||
children = [].slice.call(label_id.parentNode.children); | ||
div = children[children.indexOf(label_id) + 1]; | ||
a = div.children[0].children[0]; // div->p->a | ||
ending = a.href.split("-").slice(-1)[0]; // macOS_Intel.pkg, macOS_M1.pkg, Linux.sh, Windows.exe | ||
data["assets"].forEach((asset) => { | ||
if (asset["browser_download_url"].endsWith(ending)) { | ||
old_stem = a.href.split("/").slice(-1)[0]; | ||
new_stem = asset["browser_download_url"].split("/").slice(-1)[0]; | ||
a.href = asset["browser_download_url"]; | ||
// also replace the command on Linux | ||
if (ending === "Linux.sh") { | ||
code = document.getElementById("codecell0"); | ||
console.log(code.innerText.replace(old_stem, new_stem)); | ||
} | ||
// MNE-Python-1.5.1_0-Linux.sh to 1.5 for example | ||
if (!warn) { | ||
old_ver = old_stem.split("-").slice(2)[0].split("_")[0].split(".").slice(0, 2).join("."); | ||
new_ver = new_stem.split("-").slice(2)[0].split("_")[0].split(".").slice(0, 2).join("."); | ||
if (old_ver !== new_ver) { | ||
warn = `The installers below are for version ${new_ver} as ${old_ver} is no longer supported`; | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
if (warn) { | ||
inner.innerText = warn; | ||
outer.append(title, inner); | ||
document.querySelectorAll('.platform-selector-tabset')[0].before(outer); | ||
} | ||
} | ||
warnVersion(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters