issue_comments: 1484274796
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | issue | performed_via_github_app |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/simonw/datasette/issues/1608#issuecomment-1484274796 | https://api.github.com/repos/simonw/datasette/issues/1608 | 1484274796 | IC_kwDOBm6k_c5YeDxs | 9599 | 2023-03-26T23:38:18Z | 2023-03-26T23:38:18Z | OWNER | ChatGPT prompt: > ``` > jQuery(function ($) { > // Show banner linking to /stable/ if this is a /latest/ page > if (!/\/latest\//.test(location.pathname)) { > return; > } > var stableUrl = location.pathname.replace("/latest/", "/stable/"); > // Check it's not a 404 > fetch(stableUrl, { method: "HEAD" }).then((response) => { > if (response.status == 200) { > var warning = $( > `<div class="admonition warning"> > <p class="first admonition-title">Note</p> > <p class="last"> > This documentation covers the <strong>development version</strong> of Datasette.</p> > <p>See <a href="${stableUrl}">this page</a> for the current stable release. > </p> > </div>` > ); > warning.find("a").attr("href", stableUrl); > $("article[role=main]").prepend(warning); > } > }); > }); > > Rewrite this to use vanilla JavaScript, no jQuery > ``` Got back: ```javascript document.addEventListener("DOMContentLoaded", function() { // Show banner linking to /stable/ if this is a /latest/ page if (!/\/latest\//.test(location.pathname)) { return; } var stableUrl = location.pathname.replace("/latest/", "/stable/"); // Check it's not a 404 fetch(stableUrl, { method: "HEAD" }).then((response) => { if (response.status === 200) { var warning = document.createElement("div"); warning.className = "admonition warning"; warning.innerHTML = ` <p class="first admonition-title">Note</p> <p class="last"> This documentation covers the <strong>development version</strong> of Datasette. </p> <p> See <a href="${stableUrl}">this page</a> for the current stable release. </p> `; var mainArticle = document.querySelector("article[role=main]"); mainArticle.insertBefore(warning, mainArticle.firstChild); } }); }); ``` | {"total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0} | 1109808154 |