PageSourceSearch

https://juliadiff.org/ChainRulesCore.jl/stable/assets/warner.js

js juliadiff.org collected 2026-09-25 13:58:36 UTC 4,635 bytes, 124 lines download raw bytes

1function maybeAddWarning() {
2  // DOCUMENTER_NEWEST is defined in versions.js, DOCUMENTER_CURRENT_VERSION and DOCUMENTER_STABLE
3  // in siteinfo.js. DOCUMENTER_IS_DEV_VERSION is optional and defined in siteinfo.js.
4  // If the required variables are undefined something went horribly wrong, so we abort.
5  if (
6    window.DOCUMENTER_NEWEST === undefined ||
7    window.DOCUMENTER_CURRENT_VERSION === undefined ||
8    window.DOCUMENTER_STABLE === undefined
9  ) {
10    return;
11  }
12
13  // Current version is not a version number, so we can't tell if it's the newest version. Abort.
14  if (!/v(\d+\.)*\d+/.test(window.DOCUMENTER_CURRENT_VERSION)) {
15    return;
16  }
17
18  // Current version is newest version, so no need to add a warning.
19  if (window.DOCUMENTER_NEWEST === window.DOCUMENTER_CURRENT_VERSION) {
20    return;
21  }
22
23  // Add a noindex meta tag (unless one exists) so that search engines don't index this version of the docs.
24  if (document.body.querySelector('meta[name="robots"]') === null) {
25    const meta = document.createElement("meta");
26    meta.name = "robots";
27    meta.content = "noindex";
28
29    document.getElementsByTagName("head")[0].appendChild(meta);
30  }
31
32  const div = document.createElement("div");
33  // Base class is added by default
34  div.classList.add("warning-overlay-base");
35  const closer = document.createElement("button");
36  closer.classList.add("outdated-warning-closer", "delete");
37  closer.addEventListener("click", function () {
38    document.body.removeChild(div);
39  });
40  var target_href =
41    window.documenterBaseURL + "/../" + window.DOCUMENTER_STABLE;
42
43  // try to stay on the same page when linking to the stable version
44  // get the current page path relative to the version root
45  var current_page = window.location.pathname;
46
47  // resolve the documenterBaseURL to an absolute path
48  // documenterBaseURL is a relative path (usually "."), so we need to resolve it
49  var base_url_absolute = new URL(documenterBaseURL, window.location.href)
50    .pathname;
51  if (!base_url_absolute.endsWith("/")) {
52    base_url_absolute = base_url_absolute + "/";
53  }
54
55  // extract the page path after the version directory
56  // e.g., if we're on /stable/man/guide.html, we want "man/guide.html"
57  var page_path = "";
58  if (current_page.startsWith(base_url_absolute)) {
59    page_path = current_page.substring(base_url_absolute.length);
60  }
61
62  // construct the target URL with the same page path
63  var target_url = target_href;
64  if (page_path && page_path !== "" && page_path !== "index.html") {
65    // ensure target_href ends with a slash before appending page path
66    if (!target_url.endsWith("/")) {
67      target_url = target_url + "/";
68    }
69    target_url = target_url + page_path;
70  }
71
72  // preserve the anchor (hash) from the current page
73  var current_hash = window.location.hash;
74
75  // Determine if this is a development version or an older release
76  let warningMessage = "";
77  if (window.DOCUMENTER_IS_DEV_VERSION === true) {
78    div.classList.add("dev-warning-overlay");
79    warningMessage =
80      "This documentation is for the <strong>development version</strong> and may contain unstable or unreleased features.<br>";
81  } else {
82    div.classList.add("outdated-warning-overlay");
83    warningMessage =
84      "This documentation is for an <strong>older version</strong> that may be missing recent changes.<br>";
85  }
86
87  // Create the link element with same-page navigation
88  const link = document.createElement("a");
89  link.href = target_url + current_hash;
90  link.textContent =
91    "Click here to go to the documentation for the latest stable release.";
92
93  // If we're trying to stay on the same page, verify it exists first
94  if (page_path && page_path !== "" && page_path !== "index.html") {
95    link.addEventListener("click", function (e) {
96      e.preventDefault();
97      // check if the target page exists, fallback to homepage if it doesn't
98      fetch(target_url, { method: "HEAD" })
99        .then(function (response) {
100          if (response.ok) {
101            window.location.href = target_url + current_hash;
102          } else {
103            // page doesn't exist in the target version, go to homepage
104            window.location.href = target_href;
105          }
106        })
107        .catch(function (error) {
108          // network error or other failure - use homepage
109          window.location.href = target_href;
110        });
111    });
112  }
113
114  div.innerHTML = warningMessage;
115  div.appendChild(link);
116  div.appendChild(closer);
117  document.body.appendChild(div);
118}
119
120if (document.readyState === "loading") {
121  document.addEventListener("DOMContentLoaded", maybeAddWarning);
122} else {
123  maybeAddWarning();
124}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.