From bc3257b0bd4bcd82fe0df82051ad49440b03c7d4 Mon Sep 17 00:00:00 2001 From: Jerry Date: Tue, 16 May 2023 10:32:39 +0200 Subject: [PATCH] scripts fix --- .../themes/lawcarta/assets/js/ui.js | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/htdocs/wp-content/themes/lawcarta/assets/js/ui.js b/htdocs/wp-content/themes/lawcarta/assets/js/ui.js index eb672dd..4dacce5 100644 --- a/htdocs/wp-content/themes/lawcarta/assets/js/ui.js +++ b/htdocs/wp-content/themes/lawcarta/assets/js/ui.js @@ -53,25 +53,27 @@ window.addEventListener('DOMContentLoaded', function(){ // catalog - const catalogSearchBtn = document.getElementById('catalogSearchBtn'); - const catalogSearchInput = document.getElementById('catalogSearchInput'); - const catalogSearchClear = document.getElementById('catalogSearchClear'); + if (document.getElementById('catalogSearchBtn')) { + const catalogSearchBtn = document.getElementById('catalogSearchBtn'); + const catalogSearchInput = document.getElementById('catalogSearchInput'); + const catalogSearchClear = document.getElementById('catalogSearchClear'); - catalogSearchBtn.addEventListener('click', function(){ - let searchText = catalogSearchInput.value; - top.location = 'https://app.livecarta.com/catalog?tab=books-tab&search=' + searchText; - }) - - catalogSearchClear.addEventListener('click', function(){ - catalogSearchInput.value = ''; - }) - - catalogSearchInput.addEventListener('keyup', function(e){ - if (e.keyCode === 13) { + catalogSearchBtn.addEventListener('click', function(){ let searchText = catalogSearchInput.value; top.location = 'https://app.livecarta.com/catalog?tab=books-tab&search=' + searchText; - } - }) + }) + + catalogSearchClear.addEventListener('click', function(){ + catalogSearchInput.value = ''; + }) + + catalogSearchInput.addEventListener('keyup', function(e){ + if (e.keyCode === 13) { + let searchText = catalogSearchInput.value; + top.location = 'https://app.livecarta.com/catalog?tab=books-tab&search=' + searchText; + } + }) + } // sliders