1document.addEventListener('DOMContentLoaded', function () { 2 const searchForms = document.querySelectorAll('.search-form'); 3 4 const pathname = window.location.pathname.split('/')[1]; 5 if (pathname.length === 2) { 6 document.querySelector('.logoLink').href = `/${pathname}/`; 7 document.querySelector('.footLogo').href = `/${pathname}/`; 8 } 9 10 // Iterate over each form and attach the submit event listener 11 searchForms.forEach((form) => { 12 form.addEventListener('submit', (event) => { 13 event.preventDefault(); // Prevent the default form s 14 // ubmission behavior 15 16 // Find the input within the current form 17 const input = form.querySelector('input[type="text"]'); 18 if (!input) { 19 console.error('Search input field not found within the form.'); 20 return; 21 } 22 23 // Retrieve and trim the input value 24 const query = input.value.trim(); 25 26 // Check if the input is not empty 27 if (query) { 28 // Encode the query to make it URL-safe 29 const encodedQuery = encodeURIComponent(query); 30 31 // if the first location.href.pathname has two digits, for example /en/ then add it to search url 32 if (pathname.length === 2) { 33 window.location.href = `/${pathname}/search/?q=${encodedQuery}`; 34 return; 35 } 36 37 // Redirect the user to the search results page with the query parameter 38 window.location.href = `/search/?q=${encodedQuery}`; 39 } else { 40 // Optionally, you can handle empty queries here 41 alert('Por favor, introduce un término de búsqueda válido.'); 42 } 43 }); 44 }); 45 46 // Optional: Handle cases where forms might not have been found 47 if (searchForms.length === 0) { 48 console.warn('No search forms found with the class "search-form".'); 49 } 50}); 51 52var linkParams = ''; 53var width = window.innerWidth || document.documentElement.clientWidth; 54var isMobile = false; 55var isTablet = false; 56var isPc = false; 57 58if (width < 768) { 59 isMobile = true; 60} else if (width >= 768 && width < 1201) { 61 isTablet = true; 62} else { 63 isPc = true; 64} 65 66function smoothScroll(event, targetId) { 67 event.preventDefault(); 68 const targetElement = document.getElementById(targetId); 69 if (targetElement) { 70 var offsetPosition = 0; 71 if (isPc) { 72 offsetPosition = targetElement.offsetTop; 73 } else { 74 offsetPosition = targetElement.offsetTop - 50; 75 } 76 window.scrollTo({ 77 top: offsetPosition, 78 behavior: 'smooth', 79 }); 80 } 81} 82 83document.addEventListener('scroll', function () { 84 var links = document.querySelectorAll('.contentsLink'); 85 var scrollPos = window.scrollY; 86 87 links.forEach((link) => { 88 var targetId = link.getAttribute('href').substring(1); 89 var targetSection = document.getElementById(targetId); 90 91 if (targetSection) { 92 if ( 93 targetSection.offsetTop <= scrollPos && 94 targetSection.offsetTop + targetSection.offsetHeight > scrollPos 95 ) { 96 links.forEach((l) => l.parentElement.classList.remove('active')); 97 98 link.parentElement.classList.add('active'); 99 } 100 } 101 }); 102 103 if (links[0] && window.scrollY <= links[0].offsetTop) { 104 links.forEach((link) => link.parentElement.classList.remove('active')); 105 } 106}); 107 108var body = document.getElementsByTagName('body')[0]; 109var menuWrap = document.getElementsByClassName('menuWrap')[0]; 110var menuMask = document.getElementsByClassName('menuMask')[0]; 111function showSearch() { 112 menuWrap.style.top = '0px'; 113 menuMask.style.display = 'block'; 114 body.style.overflow = 'hidden'; 115} 116function closeSearch() { 117 menuWrap.style.top = '-100%'; 118 menuMask.style.display = 'none'; 119 body.style.overflow = 'scroll'; 120} 121 122function getQueryValue(name) { 123 const queryStr = window.location.search.substring(1); 124 125 const vars = queryStr.split('&'); 126 for (let i = 0; i < vars.length; i++) { 127 let pair = vars[i].split('='); 128 if (pair[0] == name) { 129 return decodeURIComponent(pair[1]); 130 } 131 } 132 133 return null; 134} 135var urlSearchText = getQueryValue('q') || ''; 136if (urlSearchText) { 137 var searchInput = document.getElementById('searchInput'); 138 searchInput.value = urlSearchText; 139} 140 141function jumpSearch(searchNode) { 142 var seaTextIndex = document.querySelector(searchNode); 143 var searchText = seaTextIndex.value; 144 if (searchText !== '') { 145 if ('') { 146 window.location.href = '/search' + '?q=' + searchText + '&'; 147 } else { 148 window.location.href = '/search' + '?q=' + searchText; 149 } 150 } else { 151 console.log('Please enter the content of your searchï¼'); 152 } 153} 154 155function enterSearch(searchNode) { 156 var e = window.event; 157 if (e.keyCode == 13) { 158 jumpSearch(searchNode); 159 } 160} 161const tabButtons = document.querySelectorAll('.tabButton'); 162const tabContents = document.querySelectorAll('.tabContent'); 163const tabContentPc = document.querySelectorAll('.tabContentPc'); 164 165tabButtons.forEach((button) => { 166 button.addEventListener('click', function () { 167 tabButtons.forEach((btn) => btn.classList.remove('active')); 168
169 tabContents.forEach((content) => content.classList.remove('active')); 170 171 this.classList.add('active'); 172 173 const tabId = this.getAttribute('data-tab'); 174 const activeTab = document.getElementById(tabId); 175 activeTab.classList.add('active'); 176 177 if (isMobile) { 178 tabContentPc.forEach((item, index) => { 179 item.style.display = 'none'; 180 }); 181 } 182 }); 183}); 184const newArticlesPc = document.querySelectorAll('.newArticlesPc'); 185 186function ajax(options) { 187 var xhr = null; 188 var params = formsParams(options.data); 189 190 if (window.XMLHttpRequest) { 191 xhr = new XMLHttpRequest(); 192 } else { 193 xhr = new ActiveXObject('Microsoft.XMLHTTP'); 194 } 195 196 if (options.type == 'GET') { 197 xhr.open(options.type, options.url + '?' + params, options.async); 198 xhr.send(null); 199 if (xhr.status === 200) { 200 options.success(xhr.responseText); 201 } 202 } else if (options.type == 'POST') { 203 xhr.open(options.type, options.url, options.async); 204 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8'); 205 xhr.send(params); 206 xhr.onreadystatechange = function () { 207 if (xhr.readyState == 4 && xhr.status == 200) { 208 options.success(xhr.responseText); 209 } 210 }; 211 } 212} 213 214function formsParams(data) { 215 var arr = []; 216 for (var prop in data) { 217 arr.push(prop + '=' + data[prop]); 218 } 219 return arr.join('&'); 220} 221 222function lazyImg() { 223 const images = document.querySelectorAll('.lazyImg'); 224 const observer = new IntersectionObserver((entries = []) => { 225 entries.forEach((item) => { 226 if (item.isIntersecting) { 227 const img = item.target; 228 img.setAttribute('src', img.getAttribute('data-src')); 229 observer.unobserve(img); 230 } 231 }); 232 }); 233 234 images.forEach((image) => { 235 observer.observe(image); 236 }); 237} 238lazyImg(); 239 240function marquee(swiperUl, swiperItem, rightBtn, leftBtn, swiperDateList) { 241 var moveLength = 500; 242 243 var moveTotal = 0; 244 var swiperBox = document.getElementsByClassName(swiperUl)[0]; 245 246 var swiperBoxWidth = swiperBox.offsetWidth; 247 var swiperList = 0; 248 var list = swiperDateList; 249 var listLength = list.length; 250 for (let index = 0; index < listLength; index++) { 251 var item = document.getElementsByClassName(swiperItem)[index]; 252 var itemWidth = item.offsetWidth; 253 swiperList += itemWidth; 254 } 255 256 var boxWidth = swiperList - swiperBoxWidth; 257 var rightBtn = document.getElementById(rightBtn); 258 var leftBtn = document.getElementById(leftBtn); 259 260 if (swiperDateList == null || swiperBoxWidth >= swiperList) { 261 rightBtn.style.display = 'none'; 262 } else 263 rightBtn.addEventListener('click', function () { 264 if (boxWidth > moveLength) { 265 boxWidth -= moveLength; 266 moveTotal += moveLength; 267 swiperBox.setAttribute('style', '-webkit-transform: translateX(-' + moveTotal + 'px);'); 268 leftBtn.style.display = 'flex'; 269 } else if (boxWidth <= moveLength) { 270 moveTotal += boxWidth; 271 boxWidth = 0; 272 swiperBox.setAttribute('style', '-webkit-transform: translateX(-' + moveTotal + 'px);'); 273 rightBtn.style.display = 'none'; 274 leftBtn.style.display = 'flex'; 275 } 276 }); 277 278 leftBtn.addEventListener('click', function () { 279 if (moveLength < moveTotal) { 280 boxWidth += moveLength; 281 moveTotal -= moveLength; 282 swiperBox.setAttribute('style', '-webkit-transform: translateX(-' + moveTotal + 'px);'); 283 rightBtn.style.display = 'flex'; 284 } else if (moveLength >= moveTotal) { 285 boxWidth += moveTotal; 286 moveTotal = 0; 287 swiperBox.setAttribute('style', '-webkit-transform: translateX(-' + moveTotal + 'px);'); 288 rightBtn.style.display = 'flex'; 289 leftBtn.style.display = 'none'; 290 } 291 }); 292} 293 294var dentalsOptionsDom = document.querySelector('.dentalsOptions'); 295 296function optionDentals() { 297 dentalsOptionsDom.style.display = 'block'; 298} 299 300function hideDentals() { 301 dentalsOptionsDom.style.display = 'none'; 302} 303 304document.addEventListener('DOMContentLoaded', function () { 305 var linkElements = document.querySelectorAll('a'); 306 307 linkElements.forEach(function (linkElement) { 308 var originalHref = linkElement.getAttribute('href'); 309 310 if (originalHref && (originalHref.startsWith('/') || originalHref.startsWith('https://'))) { 311 if (typeof linkParams !== 'undefined' && linkParams) { 312 if (originalHref.includes('?')) { 313 linkElement.setAttribute('href', originalHref + '&' + linkParams); 314 } else { 315 linkElement.setAttribute('href', originalHref + '?' + linkParams); 316 } 317 } 318 } 319 }); 320});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.