From nobody Tue May 03 18:53:05 2022 X-Original-To: dev-commits-doc-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 482241ABFD34 for ; Tue, 3 May 2022 18:53:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Kt8H61Xmcz3pkm; Tue, 3 May 2022 18:53:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651603986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xX9nZMjKT57YxDraWKIzfAhXY6ZtgI98vzOHV1mIGC8=; b=pQcGXpJlFp1cEeYl2EMz6HISYmysSMkCB/87xBFN/TEvmqehvBv+4K0Fq36iipdKbrdUel +1QcraXHi1k34VuvfBdLnuNc0PA8iH10OidymQ1Dov1yi4qMQEcTOxqkPX4YWZ882PUehX eaSLZuOM2F3NazOA8Cgb5daojFdCtbzTlLGiKm9iI5wPilLn71b2399FJHzfAn2jr5iptV wSqOIkzt07cD9P4fLyE8FUimaUHK6fK2IiMJPJtzghzsWADfzRk4j9h7IBVAwCL/U6HPci ghQdxSs3HYIQd0GskoXKjIh0xQU84Eqq0Pro5QXt4BsUfJT60TFEwNPrAvXGYw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 14E3A23D23; Tue, 3 May 2022 18:53:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 243Ir5Bw070732; Tue, 3 May 2022 18:53:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 243Ir5gw070731; Tue, 3 May 2022 18:53:05 GMT (envelope-from git) Date: Tue, 3 May 2022 18:53:05 GMT Message-Id: <202205031853.243Ir5gw070731@gitrepo.freebsd.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org From: Sergio Carlavilla Delgado Subject: git: 4612e81a77 - main - Fix undefined reference in search function and other JS improvements List-Id: Commit messages for all branches of the doc repository List-Archive: https://lists.freebsd.org/archives/dev-commits-doc-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-doc-all@freebsd.org X-BeenThere: dev-commits-doc-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: carlavilla X-Git-Repository: doc X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4612e81a776915245ac78ee7808f57f4f13332c2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651603986; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xX9nZMjKT57YxDraWKIzfAhXY6ZtgI98vzOHV1mIGC8=; b=ADUi2m5UvYpaxf0v68ilPj/HBHKbQMxIkaFXDzivQPHP+//o9yOUYDZEyX2whte8+rgMtk OSOYWgxO+oh0+uqARKda2isjrJoo0IpHII0fBP2KUt2ZKwH1Ol+kvbaYwN8uJVH/MKpy04 H4LPsWyqVkycm/XMbZCRtnDbiT6dTmw5Mh9rYLfwNYoUmCyezd6NqNzDn+FUvLWnvaxvgR 7hencjxwu7t8JECzJU3UMgS2hFn8lJ28gI2x9Rh9Ry0KMVSkgWT07Oy8v2p9UravIri5Jk /IIOAu21enPdrJ/qoR57Wg70pX/YK3wecupM3fen1uMAREq0ufnwQDiBCtxJvQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651603986; a=rsa-sha256; cv=none; b=ky3MadZRav47OC2AyUE4oa1mo73RiAd+QPUjkrz2cy/SMATONHsWPrgIsjsp8cag42/e7E 3WZIfaXoqY9YdxUON5/WBoCxuaZH844mJAa8VdElk993b96B14fL1kpxgy9xG9sVee4G8U t3u/wz0ujeRDrrS45q1FLoDbBOaQV1tOef5+uV8QfNr0ndyKCbFrWhYrwAKs9lLPRI1XIz Hhn44Y+1ktOEfYzU6IAi/FyODBeQ6OWgbxkOoX+2RX7YgDQvjNfKv6PS3rbx9+6Nfflzpa FccXlNIPmnvouTDkJy9El18VOk3Zci9F+HFf21V47STlAQHVVG7twi6/IvyJzg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by carlavilla: URL: https://cgit.FreeBSD.org/doc/commit/?id=4612e81a776915245ac78ee7808f57f4f13332c2 commit 4612e81a776915245ac78ee7808f57f4f13332c2 Author: Sergio Carlavilla Delgado AuthorDate: 2022-05-03 18:52:03 +0000 Commit: Sergio Carlavilla Delgado CommitDate: 2022-05-03 18:52:03 +0000 Fix undefined reference in search function and other JS improvements --- .../themes/beastie/assets/js/copy-clipboard.js | 29 +++++++++--------- documentation/themes/beastie/assets/js/search.js | 5 +++- .../themes/beastie/assets/js/theme-chooser.js | 34 +++++++++++----------- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/documentation/themes/beastie/assets/js/copy-clipboard.js b/documentation/themes/beastie/assets/js/copy-clipboard.js index 4b11058422..126f2bf8b1 100644 --- a/documentation/themes/beastie/assets/js/copy-clipboard.js +++ b/documentation/themes/beastie/assets/js/copy-clipboard.js @@ -27,7 +27,9 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -(function () { +;(function () { + 'use strict' + document.querySelectorAll(".rouge, .highlight").forEach(function(codeItem) { var sourceCode = codeItem.textContent; @@ -51,16 +53,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. button.addEventListener('click', copyToClipboard.bind(button, sourceCode)); }); -})(); -function copyToClipboard(text, item) { - const tooltip = item.target.nextElementSibling; - window.navigator.clipboard.writeText(text).then(function() { - if (tooltip) { - tooltip.classList.add("show-tooltip"); - setTimeout(function(){ - tooltip.classList.remove("show-tooltip"); - }, 1200); - } - }); -} + function copyToClipboard(text, item) { + const tooltip = item.target.nextElementSibling; + window.navigator.clipboard.writeText(text).then(function() { + if (tooltip) { + tooltip.classList.add("show-tooltip"); + setTimeout(function(){ + tooltip.classList.remove("show-tooltip"); + }, 1200); + } + }); + } + +})(); diff --git a/documentation/themes/beastie/assets/js/search.js b/documentation/themes/beastie/assets/js/search.js index cab7098d09..0cf9a29bb2 100644 --- a/documentation/themes/beastie/assets/js/search.js +++ b/documentation/themes/beastie/assets/js/search.js @@ -32,7 +32,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. var searchBookInput = document.querySelector("#search-book"); var menuContents = document.querySelector("#MenuContents"); - searchBookInput.addEventListener('keyup', search); + + if (searchBookInput) { + searchBookInput.addEventListener('keyup', search); + } function search() { var menuElements = menuContents.children[0]; diff --git a/documentation/themes/beastie/assets/js/theme-chooser.js b/documentation/themes/beastie/assets/js/theme-chooser.js index 9a48432dc5..cc52d7084b 100644 --- a/documentation/themes/beastie/assets/js/theme-chooser.js +++ b/documentation/themes/beastie/assets/js/theme-chooser.js @@ -27,7 +27,9 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -(function () { +;(function () { + 'use strict' + var theme = localStorage.getItem('theme'); var themeChooser = document.querySelector('#theme-chooser'); var themeContainer = document.querySelector('.theme-container'); @@ -43,23 +45,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. setTheme('theme-light'); themeChooser.value = 'theme-light'; } -})(); -var themeChooser = document.querySelector('#theme-chooser'); + themeChooser.addEventListener('change', function() { + var theme = this.value; -themeChooser.addEventListener('change', function() { - var theme = this.value; + if (theme === "theme-dark") { + setTheme('theme-dark'); + } else if (theme === "theme-high-contrast") { + setTheme('theme-high-contrast'); + } else { + setTheme('theme-light'); + } + }); - if (theme === "theme-dark") { - setTheme('theme-dark'); - } else if (theme === "theme-high-contrast") { - setTheme('theme-high-contrast'); - } else { - setTheme('theme-light'); + function setTheme(themeName) { + localStorage.setItem('theme', themeName); + document.documentElement.className = themeName; } -}); - -function setTheme(themeName) { - localStorage.setItem('theme', themeName); - document.documentElement.className = themeName; -} +})();