| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
(function () { |
| 11 |
"use strict"; |
| 12 |
|
| 13 |
var segments = window.location.pathname.split("/").filter(Boolean); |
| 14 |
var first = segments[0]; |
| 15 |
|
| 16 |
var channel; |
| 17 |
if (first === "master") { |
| 18 |
channel = { kind: "nightly" }; |
| 19 |
} else if (/^\d+\.\d+/.test(first || "")) { |
| 20 |
channel = { kind: "version", version: first }; |
| 21 |
} else { |
| 22 |
channel = { kind: "stable" }; |
| 23 |
} |
| 24 |
|
| 25 |
if (channel.kind === "nightly" || channel.kind === "version") { |
| 26 |
var releasePath = "/" + segments.slice(1).join("/"); |
| 27 |
|
| 28 |
var banner = document.createElement("div"); |
| 29 |
banner.id = "helix-version-banner"; |
| 30 |
banner.setAttribute("role", "status"); |
| 31 |
|
| 32 |
var link = |
| 33 |
'<a href="' + releasePath + '">View this page in the latest release →</a>'; |
| 34 |
if (channel.kind === "nightly") { |
| 35 |
banner.className = "nightly"; |
| 36 |
banner.innerHTML = |
| 37 |
"You're reading the <strong>development (master)</strong> docs — " + |
| 38 |
"they describe unreleased changes. " + link; |
| 39 |
} else { |
| 40 |
banner.className = "archived"; |
| 41 |
banner.innerHTML = |
| 42 |
"You're reading the docs for <strong>" + channel.version + |
| 43 |
"</strong>, which may be outdated. " + link; |
| 44 |
} |
| 45 |
|
| 46 |
var main = document.querySelector("#mdbook-content main") || document.body; |
| 47 |
main.insertBefore(banner, main.firstChild); |
| 48 |
} |
| 49 |
|
| 50 |
|
| 51 |
var currentHref = channel.kind === "nightly" ? "/master/" : "/"; |
| 52 |
var tiles = document.querySelectorAll(".version-tiles .version-tile"); |
| 53 |
for (var i = 0; i < tiles.length; i++) { |
| 54 |
if (tiles[i].getAttribute("href") === currentHref) { |
| 55 |
tiles[i].classList.add("current"); |
| 56 |
} |
| 57 |
} |
| 58 |
})(); |