1// Mark current language radio as checked - Defined globally 2window.setCurrentLanguageRadio = function() { 3 var currentLang = document.documentElement.lang || ''; 4 if (currentLang) { 5 currentLang = currentLang.toLowerCase(); 6 // Buscar todos los radios de idioma en la página 7 $('.language-radio').each(function() { 8 var radioLang = $(this).attr('data-lang'); 9 if (radioLang && (radioLang.toLowerCase() === currentLang || (currentLang == "nl" && radioLang.toLowerCase() == "be"))) { 10 $(this).prop('checked', true); 11 } else { 12 $(this).prop('checked', false); 13 } 14 }); 15 } 16} 17 18$(document).ready(function () { 19 // Mark current language radio as checked on page load (desktop) 20 window.setCurrentLanguageRadio(); 21 22 // Navigate to language URL when clicking the radio button 23 $(document).on('change', '.language-radio', function () { 24 var href = $(this).closest('.language-item').find('a.item').attr('href'); 25 if (href) { 26 window.location.href = href; 27 } 28 }); 29 30 // Check the radio when clicking the language link 31 $(document).on('click', '.language-item a.item', function (e) { 32 e.preventDefault(); 33 var radio = $(this).closest('.language-item').find('.language-radio'); 34 radio.prop('checked', true).trigger('change'); 35 }); 36 37 // Wait half a second and remove noSee class from #blockNotification 38 setTimeout(function () { 39 $('#blockNotification').removeClass('noSee'); 40 41 42 // Analytics for Black Banner links in CC65 (.text-covid) 43 $('.text-covid span a').click(function(e){ 44 var linkHref = $(this).attr('href'); 45 var ogTitle = $('meta[property="og:title"]').attr('content') || document.title; 46 var urlModulDis = window.location.href; 47 dataLayer.push({ 48 'event': 'eventga', 49 'category': 'Interaccion', 50 'action': 'Click Black Banner link', 51 'slidername': ogTitle, 52 'label': linkHref, 53 'urlmodule': urlModulDis 54 }); 55 }); 56 57 // Analytics for Coloured Banner links in CC65 (.blocknotification-description) 58 $('.block-notification-description a').click(function(e){ 59 var linkHref = $(this).attr('href'); 60 var ogTitle = $('meta[property="og:title"]').attr('content') || document.title; 61 var urlModulDis = window.location.href; 62 dataLayer.push({ 63 'event': 'eventga', 64 'category': 'Interaccion', 65 'action': 'Click Coloured Banner link', 66 'slidername': ogTitle, 67 'label': linkHref, 68 'urlmodule': urlModulDis 69 }); 70 }); 71 }, 500); 72 73 // localStorage handling for notifications with expiration 74 function handleNotifications() { 75 // Helper function to check if localStorage item is expired 76 function isExpired(key) { 77 var item = localStorage.getItem(key + '_timestamp'); 78 if (!item) return true; 79 var timestamp = parseInt(item); 80 var now = new Date().getTime(); 81 var oneDay = 24 * 60 * 60 * 1000; // 1 day in milliseconds 82 return (now - timestamp) > oneDay; 83 } 84 85 // Helper function to set localStorage with timestamp 86 function setWithExpiration(key, value) { 87 localStorage.setItem(key, value); 88 localStorage.setItem(key + '_timestamp', new Date().getTime().toString()); 89 } 90 91 // Check localStorage for regular notification 92 if (localStorage.getItem('policyBar') != "active" || isExpired('policyBar')) { 93 $('#cookieBar').show(); 94 } else { 95 $('#cookieBar').hide(); 96 } 97 98 // Assign localStorage on click for regular notification 99 $('#cookieBar .icon-close').on('click', function () { 100 setWithExpiration('policyBar', 'active'); 101 $('#cookieBar').fadeOut(); 102 $('.cc62_navigation_menu').removeClass('topCovid'); 103 104 let urlModulCovid = window.location.href; 105 dataLayer.push({ 106 'category': 'Interaccion', 107 'action': 'top-header', 108 'label': 'Cerrar Alerta', 109 'event': 'eventga', 110 'urlmodule': urlModulCovid, 111 'slidername': 'Alerta Covid', 112 'Gate': namePark, 113 }); 114 115 if($(window).width() <= 1024) { 116 $('.cc62_navigation_menu').css('top', '0'); 117 } 118 }); 119 120 // Check localStorage for block notification 121 if (localStorage.getItem('blockNotificationBar') != "active" || isExpired('blockNotificationBar')) { 122 $('#blockNotification').show(); 123 } else { 124 $('#blockNotification').hide(); 125 } 126 127 // Assign localStorage on click for block notification 128 $('#blockNotification .icon-close').on('click', function () { 129 setWithExpiration('blockNotificationBar', 'active'); 130 $('#blockNotification').fadeOut(); 131 }); 132 } 133 134 handleNotifications(); 135 136 $(".group-idiomas .block1").bind('click', function () { 137 $(this).parents(".listado-menu").find(".menu-idiomas").toggle(); 138 }); 139 var languageItem = $('.listado-men-new .menu-idiomas').length; 140 if (languageItem >= 1) { 141 $('.group-idiomas-new').show(); 142 }else { 143 //$('.group-idiomas-new').hide(); 144 } 145 var currentLang = $("meta[property='og:locale']").attr("content"); 146 var currentLangFull = $("meta[property='og:locale:alternate']").attr("content"); 147 let mnemonic = $("#parkmnemonic").val(); 148 if (currentLang != "undefined") { 149 if(mnemonic === "BJL" && currentLang === "nl") { 150 currentLang = "be"; 151 } 152 $("<span class='text'>" + currentLang + "</span>").appendTo(".group-idiomas-new .btn-idiomas"); 153 if (currentLangFull != null) { 154 $('.cc65_navigation_menu_top .section-contact .group-idiomas-new .menu-idiomas').prepend(`<li><a class="item" href="#" data-lang="${currentLangFull}" title="${currentLangFull}">${currentLangFull}</a></li>`); 155 } 156 } else { 157 $(".group-idiomas-new").css("visibility", "hidden"); 158 } 159 $menu = $('.group-idiomas-new').find('ul').find('li'); 160 $menu.hover(function () { 161 //console.log("hov"); 162 $(this).children('ul').stop(); 163 $(this).find(".btn-idiomas").addClass("active"); 164 $(this).children('ul').show(); 165 }, function () { 166 $(this).children('ul').stop(); 167 $(this).find(".btn-idiomas").removeClass("active"); 168 $(this).children('ul').hide(); 169 }); 170 171 var typeBack = $('#typeBack').val(); 172 if(typeBack == 'solid') { 173 $('.cc65_navigation_menu_top').addClass('solid'); 174 }else { 175 $('.cc65_navigation_menu_top').addClass('transparent'); 176 } 177 if($(".menu-idiomas li").length <= 1){ 178 $(".listado-men-new").hide(); 179 } 180}); 181 182//PRECICT SEARCH 183//Open Modal 184$('.cc65_navigation_menu_top .section-contact .iconos-enlaces .icon-search').click(function (e) { 185 e.preventDefault(); 186 $('.cc65_navigation_menu_top .modal_search').show(); 187});
188//Close Modal 189$('.cc65_navigation_menu_top .modal_search .icon-close').click(function () { 190 $('.modal_search').hide(); 191}); 192//Submit 193$('#form-modal-search').submit(function (e) { 194 e.preventDefault(); 195 var word = $(".input-searchModal").val(); 196 var searchUrl = $("#searchURlink").attr("href"); 197 var host = $(location).attr('hostname'); 198 window.location.href = searchUrl + "?word=" + word; 199}); 200//Writing 201$(".modal_search-block input").keyup(function () { 202 var word = $(this).val(); 203 var wordLength = word.length; 204 if (wordLength > 2) { 205 suggestSearchModal(word); 206 $('.modal_search .shortcut').css('display', 'none'); 207 $('.modal_search .predict').css('display', 'block'); 208 $('.modal_search .icon-search').css('display', 'none'); 209 $('.modal_search .predict-result .results').remove(); 210 } else { 211 $('.modal_search .shortcut').css('display', 'block'); 212 $('.modal_search .predict').css('display', 'none'); 213 $('.modal_search .predict-result .results').remove(); 214 $('.modal_search .icon-search').css('display', 'block'); 215 } 216}); 217$(".modal_search-block input").on('paste', function () { 218 var element = this; 219 setTimeout(function () { 220 var word = $(element).val(); 221 var wordLength = word.length; 222 if (wordLength > 2) { 223 suggestSearchModal(word); 224 $('.modal_search .shortcut').css('display', 'none'); 225 $('.modal_search .predict').css('display', 'block'); 226 $('.modal_search .icon-search').css('display', 'none'); 227 $('.modal_search .predict-result .results').remove(); 228 } else { 229 $('.modal_search .shortcut').css('display', 'block'); 230 $('.modal_search .predict').css('display', 'none'); 231 $('.modal_search .predict-result .results').remove(); 232 $('.modal_search .icon-search').css('display', 'block'); 233 } 234 }, 100); 235}); 236 237function suggestSearchModal(word) { 238 var url = $('input.current-page-generic-search').attr('data-page-path'); 239 var lg = document.documentElement.lang.toLowerCase(); 240 var data = { "term": word, "lang": lg }; 241 jQuery.ajax({ 242 url: url + ".suggestservlet.json", 243 type: 'GET', 244 dataType: "json", 245 data: data, 246 success: function (data) { 247 248 var assarray = []; 249 var arrayofElement = []; 250 var assarray = $.map(data, function (value, index) { 251 return [value]; 252 }); 253 var arrayLength = assarray[0].length; 254 if (arrayLength == 0) { 255 $('.modal_search .predict').css('display', 'none'); 256 $('.modal_search .shortcut').css('display', 'block'); 257 } else { 258 $('.modal_search .shortcut').css('display', 'none'); 259 $('.modal_search .predict').css('display', 'block'); 260 } 261 $.each(assarray[0], function (indexInArray, valueOfElement) { 262 arrayofElement.push(valueOfElement); 263 arrayofElementLength = indexInArray; 264 }); 265 266 printPressModal(arrayofElement, word); 267 arrayofElement = []; 268 }, 269 error: function (XMLHttpRequest, textStatus, errorThrown) { 270 console.log("Error: {}", errorThrown); 271 272 }, 273 statusCode: function (status) { 274 alert("page: " + status); 275 } 276 }); 277 278} 279 280function printPressModal(data, word) { 281 // $.each(data, function (indexArray, valueArray) { 282 // var searchUrl = $('#searchURL').val(); 283 // var removeHtml = valueArray.replace(/<\/?b>/g, ''); 284 // var linkHeader = searchUrl+'?word='+removeHtml; 285 // $('.predict-result').append('<a href="'+linkHeader+'" class="results"><span class="text">'+valueArray+'</span><span class="icon-Right"></span></a href="#">'); 286 // }); 287 // arrayofElement = []; 288 $.each(data, function (indexArray, valueArray) { 289 var comienzo = '----------------------' 290 var palabraBuscada = word; 291 var resultadoCompleto = valueArray; 292 var searchUrl = $("#searchURlink").attr("href"); 293 var removeHtml = valueArray.replace(/<\/?b>/g, '').replace(/\n/ig, ''); 294 295 var textPos = valueArray.indexOf('<b>'); 296 297 //let newTextPre = valueArray.replace(/(<([^>]+)>)/ig,"").replace(/<\/?b>/g, '').replace('.','').replace(',','').replace('!','').replace('¡','').replace('-','').replace(':',''); 298 let newTextPre = valueArray.toLowerCase().replace(/(<([^>]+)>)/ig, "").replace(/<\/?b>/g, ''); 299 //var newTextPre = newTextPre.split('.')[0]; 300 var wordSearch = word.toLowerCase(); 301 var textPosB = newTextPre.indexOf(wordSearch); 302 var introText = newTextPre.substr(textPosB, 50); 303 var introTextB = introText.split('âµ')[0]; 304 //var introTextB = introText.split(/[^a-zA-Z0-9_ ]/g)[0];
305 var introTextB = introText.split(/[^A-Za-zÃÃÃÃÃáéÃóúñÃ0-9_ ]/g)[0]; 306 var textShort = introTextB.split(/\s+/, 4); 307 var textCut = introTextB.split(' '); 308 var textCutOne = textCut[0]; 309 var textCutTwo = textCut[1]; 310 var textCutThree = textCut[2]; 311 var textCutFour = textCut[3]; 312 var limiteText = textShort.join(" "); 313 var hasPoint = limiteText.indexOf('.'); 314 315 316 if (textCutTwo != null) { 317 var textCutTwoLength = textCutTwo.length; 318 } else { 319 var textCutTwoLength = 1; 320 } 321 322 if (textCutThree != null) { 323 var textCutThreeLength = textCutThree.length; 324 } else { 325 var textCutThreeLength = 1; 326 } 327 328 if (textCutFour != null) { 329 var textCutFourLength = textCutFour.length; 330 } else { 331 var textCutFourLength = 1; 332 } 333 334 if (textCutTwoLength <= 3 || textCutTwo == null) { 335 var textCutTwo = ''; 336 } 337 if (textCutThreeLength <= 3 || textCutThree == null) { 338 var textCutThree = ''; 339 } 340 if (textCutFourLength <= 3 || textCutFour == null) { 341 var textCutFour = ''; 342 } 343 344 limiteTextLow = limiteText.trim().toLowerCase(); 345 var resultLimit = '<b>' + textCutOne + '</b> ' + textCutTwo + ' ' + textCutThree + ' ' + textCutFour + '...'; 346 var resultLimitLow = resultLimit.toLowerCase(); 347 var resultLimitInput = textCutOne + textCutTwo + textCutThree + textCutFour; 348 var resultLimitUrl = textCutOne + ' ' + textCutTwo + ' ' + textCutThree + ' ' + textCutFour; 349 if (textCutOne.length > 3) { 350 var linkHeader = searchUrl + '?word=' + resultLimitUrl; 351 //var limiteText = limiteText.split('.').join(" "); 352 $('.modal_search .predict-result').append('<a href="' + linkHeader + '" class="results results-predict"><span class="text">' + resultLimitLow + '</span><span class="icon-Right"></span><input type="hidden" id="predictUrl" value="' + resultLimitInput + '"><input type="hidden" id="predictUrlB" value="' + resultLimitUrl + '"></a>'); 353 354 } 355 356 357 var prueba = valueArray.split(" ").splice(textPos, 3).join(" "); 358 if (valueArray.length > 65) { 359 var index = valueArray.indexOf(' ', 15); 360 361 362 363 var textShort = valueArray.split(/\s+/, 15); 364 var limiteText = textShort.join(" "); 365 limite = valueArray.substr(textPos, 80) + "..."; 366 var removeHtml = limite.replace(/<\/?b>/g, ''); 367 //$('.predict-result').append('<a href="#" class="results"><span class="text">'+valueArray+'</span><span class="icon-Right"></span><input type="hidden" id="predictUrl" value="'+removeHtml+'"></a>'); 368 } 369 }); 370 //recorriendo resultados, eliminando repetidos y poniendolos en orden 371 var seen = {}; 372 $('.modal_search .predict-result .results-predict').each(function (index, element) { 373 var textVal = $('#predictUrl', element).val().trim(); 374 if (seen[textVal]) { 375 $(this).remove(); 376 } else { 377 seen[textVal] = true; 378 379 } 380 }); 381 $('.modal_search .predict-result .results-predict').each(function () { 382 var textValLength = $('#predictUrl', this).val().trim().length; 383 if (textValLength < 10) { 384 $(this).addClass('primero'); 385 } else if (textValLength > 10 && textValLength < 20) { 386 $(this).addClass('segundo'); 387 } else { 388 $(this).addClass('tercero'); 389 } 390 }); 391 $('.modal_search .predict-result .results-predict').each(function () { 392 if ($(this).hasClass('primero')) { 393 $(this).prependTo('.predict-result'); 394 } 395 if ($(this).hasClass('segundo')) { 396 $(this).insertAfter('primero'); 397 } 398 if ($(this).hasClass('tercero')) { 399 $(this).appendTo('.predict-result'); 400 } 401 402 403 }); 404 //Restringiendo resultados a 3 405 var resultsPredict = $('.modal_search .predict-result .results-predict').length; 406 if ($(window).width() >= 768) { 407 resultsPredict = 10; 408 } else { 409 resultsPredict = 5; 410 } 411 //var resultsPredict = (- resultsPredict) + 10; 412 const parent = document.querySelector(".modal_search .predict-result"); 413 [...parent.children].slice(resultsPredict).forEach(parent.removeChild.bind(parent)); 414 arrayofElement = []; 415 416 $('.modal_search .predict-result .results').click(function (e) { 417 //e.preventDefault(); 418 var word = $('#predictUrlB', this).val(); 419 //genericSearch(word,null,true,0,true,false,false); 420 $('.input-select .input-searchModal').val(''); 421 $(".modal_search").hide(); 422 //Analytics 423 var urlModulDis = window.location.href; 424 var maingate = $('#parkmnemonic').val(); 425 dataLayer.push({ 426 'category': 'Interaccion', 427 'action': 'CP34-Search/Modal', 428 'label': word, 429 'event': 'eventga', 430 'urlmodule': urlModulDis, 431 'Gate': namePark, 432 }); 433 }); 434 435 // Call the function on page load 436 window.setCurrentLanguageRadio(); 437}
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.