kopia lustrzana https://github.com/simonw/datasette
Drop jQuery dependency
rodzic
db8cf899e2
commit
c025b0180f
|
@ -8,7 +8,7 @@
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
<script>
|
<script>
|
||||||
jQuery(function ($) {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
// Show banner linking to /stable/ if this is a /latest/ page
|
// Show banner linking to /stable/ if this is a /latest/ page
|
||||||
if (!/\/latest\//.test(location.pathname)) {
|
if (!/\/latest\//.test(location.pathname)) {
|
||||||
return;
|
return;
|
||||||
|
@ -16,18 +16,20 @@ jQuery(function ($) {
|
||||||
var stableUrl = location.pathname.replace("/latest/", "/stable/");
|
var stableUrl = location.pathname.replace("/latest/", "/stable/");
|
||||||
// Check it's not a 404
|
// Check it's not a 404
|
||||||
fetch(stableUrl, { method: "HEAD" }).then((response) => {
|
fetch(stableUrl, { method: "HEAD" }).then((response) => {
|
||||||
if (response.status == 200) {
|
if (response.status === 200) {
|
||||||
var warning = $(
|
var warning = document.createElement("div");
|
||||||
`<div class="admonition warning">
|
warning.className = "admonition warning";
|
||||||
<p class="first admonition-title">Note</p>
|
warning.innerHTML = `
|
||||||
<p class="last">
|
<p class="first admonition-title">Note</p>
|
||||||
This documentation covers the <strong>development version</strong> of Datasette.</p>
|
<p class="last">
|
||||||
<p>See <a href="${stableUrl}">this page</a> for the current stable release.
|
This documentation covers the <strong>development version</strong> of Datasette.
|
||||||
</p>
|
</p>
|
||||||
</div>`
|
<p>
|
||||||
);
|
See <a href="${stableUrl}">this page</a> for the current stable release.
|
||||||
warning.find("a").attr("href", stableUrl);
|
</p>
|
||||||
$("article[role=main]").prepend(warning);
|
`;
|
||||||
|
var mainArticle = document.querySelector("article[role=main]");
|
||||||
|
mainArticle.insertBefore(warning, mainArticle.firstChild);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Ładowanie…
Reference in New Issue