aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergio Carlavilla Delgado <carlavilla@FreeBSD.org>2022-05-03 18:52:03 +0000
committerSergio Carlavilla Delgado <carlavilla@FreeBSD.org>2022-05-03 18:52:03 +0000
commit4612e81a776915245ac78ee7808f57f4f13332c2 (patch)
tree359f675cf5a6aa2d05268c0f9d14e53c3c887b1e
parent4ff24d6d1ee129936e908da45c7bbe7631999906 (diff)
downloaddoc-4612e81a776915245ac78ee7808f57f4f13332c2.tar.gz
doc-4612e81a776915245ac78ee7808f57f4f13332c2.zip
Fix undefined reference in search function and other JS improvements
-rw-r--r--documentation/themes/beastie/assets/js/copy-clipboard.js29
-rw-r--r--documentation/themes/beastie/assets/js/search.js5
-rw-r--r--documentation/themes/beastie/assets/js/theme-chooser.js34
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;
-}
+})();