1function onDocumentReady(fn) { 2 if (document.readyState === 'loading') { 3 document.addEventListener('DOMContentLoaded', fn); 4 } else { 5 fn(); 6 } 7} 8function handle_WCAG_Widget_ClickEvent(event) { 9 console.log('handle_WCAG_Widget_ClickEvent(event)'); 10 event.preventDefault(); 11 const container = document.querySelector('#iap-wcag-main-component'); 12 13 if (container) { 14 console.log('handle_WCAG_Widget_ClickEvent(event) - container'); 15 if (!container.innerHTML.trim()) { 16 initMainWcagComponent(true,false,false,false); 17 } else { 18 var obj_accord = document.querySelector('#iap-wcag-options'); 19 obj_accord.removeAttribute('hidden'); 20 obj_accord.classList.add('opened'); 21 obj_accord.focus(); 22 } 23 } 24} 25 26function hideSpeechRecognitionElements() { 27 const elements = document.querySelectorAll('[data-wcag-speech-start-recognition]'); 28 elements.forEach(element => { 29 element.style.display = 'none'; 30 }); 31} 32function removeSpeechRecognitionElements() { 33 const elements = document.querySelectorAll('[data-wcag-speech-start-recognition]'); 34 elements.forEach(element => { 35 element.parentNode.removeChild(element); 36 }); 37} 38function showSpeechRecognitionElements() { 39 const elements = document.querySelectorAll('[data-wcag-speech-start-recognition]'); 40 elements.forEach(element => { 41 if (element.parentElement && element.parentElement.classList.contains('wcag-system-option-item')) { 42 element.parentElement.style.display = ''; 43 } 44 else if (element.parentElement && element.parentElement.parentElement && element.parentElement.parentElement.classList.contains('wcag-system-option-item')) { 45 element.parentElement.parentElement.style.display = ''; 46 } 47 element.style.display = ''; 48 }); 49} 50 51 var voiceReplies = true; 52 var voiceNumbers = true; 53 var voiceNumbersCookie = true; 54 var toggleSpeechRecognitionElements; 55 var isListening = false; 56 var speechRecSearchModule; 57 var speechRecInfoWrpP; 58 var speechRecSettingsWrp; 59 60 var recognition; 61 62 63 const speakInSpeechRec = (text) => { 64 if (speechSynthesis.speaking) { 65 speechSynthesis.cancel(); 66 } 67 const utterance = new SpeechSynthesisUtterance(text); 68 speechSynthesis.speak(utterance); 69 }; 70 71 const speechRecog_search = (text) => { 72 console.log("Szukam: " + text); 73 }; 74 75 const speechSynthesis = window.speechSynthesis; 76 var utterance = new SpeechSynthesisUtterance(); 77 var utteranceMinirdr; 78 var currentElementIndex = 0; 79 80 let isVoiceEnabled = false; 81 82 var iap_wcag_currentVoice_gender = 'Microsoft Adam - Polish (Poland)'; 83 var iap_wcag_value_voice_gender = 0; 84 var iap_wcag_value_voice_enabled = 0; 85 var iap_wcag_value_voice_tempo = 1; 86 var iap_wcag_value_old_voice_tempo = 1; 87 88 var articleSectionMinirdr; 89 var elementsToReadMinirdr; 90 var synthMinirdr; 91 var minirdrMainButtonWrp; 92 var isCancelled; 93 94 var currentHighlightText_color; 95 var currentHighlightSection_color; 96 97 98 var lastPosition = null; 99 var lastCheckTime = null; 100 var currentTimeout = null; 101 var progressInterval = null; 102 var activeElement = null; 103 var activeElementReadId = null; 104 105 106 107var wcsMainButton; 108var wcsWrapper; 109var wcsOptionItems; 110var wcsIconsClose; 111 112var wcsIconsWCAG; 113var wcsIconsPhone; 114var wcsIconsMail; 115 116var wcsIconsHelpCenter; 117var wcsIconsReading; 118var wcsIconsSpeaking; 119 120var wcsIconsReadingCursorClick; 121var wcsIconsReadingCursorHover; 122 123var recognition = false; 124 125var tagsHTML = null; 126document.addEventListener('DOMContentLoaded', function() { 127 128 tagsHTML = "a, h1, h2, h3, h4, h5, h6, p, span, ul, ol, li, label, legend, dd, dt, blockquote, time"; 129 130 131 const tagsToReadMinirdr = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'P', 'OL', 'UL', 'TABLE', 'FIGURE', 'blockquote', 'q', 'dt', 'dd']; 132 var currentHighlightSection_color = '#bef8d3'; 133 var currentHighlightWord_color = '#a6cbfc'; 134 var currentHighlightText_color = '#000000'; 135 136 137 var elements = document.querySelectorAll('.-js-iap-wcag-widget-btn'); 138
139 elements.forEach(function(element) { 140 console.log('rejestracja - .-js-iap-wcag-widget-btn'); 141 element.addEventListener('click', handle_WCAG_Widget_ClickEvent); 142 }); 143 144 articleSectionMinirdr = document.getElementById('iap-wcag-article-section'); 145 if (articleSectionMinirdr){ 146 elementsToReadMinirdr = Array.from(articleSectionMinirdr.querySelectorAll(tagsToReadMinirdr.join(','))); 147 148 synthMinirdr = window.speechSynthesis; 149 minirdrMainButtonWrp = document.getElementById('iap-wcag-minirdr--main-button-wrp'); 150 isCancelled = false; 151 152 153 const el_wcag_minirdr_play = document.getElementById('iap-wcag-minirdr-play'); 154 if (el_wcag_minirdr_play){ 155 document.getElementById('iap-wcag-minirdr-play').addEventListener('click', function() { 156 initMainWcagComponent(false,false,false,false); 157 setTimeout(function() { 158 if (utteranceMinirdr) { 159 cancelSpeech(); 160 isVoiceEnabled = false; 161 $('.-js-iap-wcag-option-btn-voice-enable').removeClass('iap-wcag-option-btn--active'); 162 document.body.classList.add('iap-wcag-minirdr-play-activated'); 163 iap_wcag_cookie_save('cookie-iap-wcag-voice-enabled', 0); 164 iap_wcag_value_voice_enabled = 0; 165 } 166 167 isCancelled = false; 168 minirdrMainButtonWrp.classList.add('reading-rdr-active'); 169 document.getElementById('iap-wcag-minirdr--main-button-wrp').classList.add('reading-rdr-active'); 170 speakElementMinirdr(currentElementIndex); 171 document.getElementById('iap-wcag-minirdr--controls').removeAttribute("hidden"); 172 }, 1000); 173 }); 174 } else { 175 176 } 177 } 178 179 180 181 182 183 184 185 186 wcsMainButton = document.querySelector('.wcag-system-main-button button'); 187 wcsWrapper = document.querySelector('.wcag-system-options-wrapper'); 188 wcsOptionItems = document.querySelectorAll('.wcag-system-option-item'); 189 wcsIconsClose = document.querySelector('[data-type-icon="close"]'); 190 191 wcsIconsWCAG = document.querySelector('[data-type-icon="wcag"]'); 192 wcsIconsPhone = document.querySelector('[data-type-icon="phone"]'); 193 wcsIconsMail = document.querySelector('[data-type-icon="mail"]'); 194 195 wcsIconsHelpCenter = document.querySelector('[data-type-icon="help"]'); 196 wcsIconsReading = document.querySelector('[data-type-icon="read"]'); 197 wcsIconsSpeaking = document.querySelector('[data-type-icon="speak"]'); 198 199 wcsIconsReadingCursorClick = document.querySelector('[data-type-icon="read_cursor_click"]'); 200 wcsIconsReadingCursorHover = document.querySelector('[data-type-icon="read_cursor_hover"]'); 201 202 wcsMainButton.addEventListener('click', function() { 203 wcsMainButtonAction(); 204 }); 205 206 207 208 209 210 211 212 213 214 215 216 217 toggleSpeechRecognitionElements = document.querySelectorAll('[data-wcag-speech-start-recognition]'); 218 if (toggleSpeechRecognitionElements.length > 0) { 219 toggleSpeechRecognitionElements.forEach(toggleSpeechRecognition => { 220 toggleSpeechRecognition.addEventListener('click', handle_WCAG_Speech_ClickEvent); 221 }); 222 } 223 224 225 var readingButtonsActivated = document.querySelectorAll('button[data-wcag-system-option-activated="reading"]'); 226 if (readingButtonsActivated){ 227 readingButtonsActivated.forEach(function(button) { 228 button.addEventListener('click', function(){ 229 iapWcagOptionVoiceEnable(); 230 }); 231 }); 232 } 233 var readingButtons = document.querySelectorAll('button[data-wcag-system-option="reading"]'); 234 if (readingButtons){ 235 readingButtons.forEach(function(button) { 236 237 button.addEventListener('click', handle_WCAG_Reading_ClickEvent); 238 }); 239 } 240 241 242 243 244 245 246 247 248 249 250 251 252 if (articleSectionMinirdr){ 253 const wcag_minirdr_exist = document.getElementById('iap-wcag-minirdr-next'); 254 if (wcag_minirdr_exist){ 255 document.getElementById('iap-wcag-minirdr-info').addEventListener('click', function(e) { 256 e.preventDefault(); 257 wcgOpenInfoBoxSystem(2,'medium'); 258 259 }); 260 } 261 } 262 263 264 if (!('webkitSpeechRecognition' in window)) { 265 hideSpeechRecognitionElements(); 266 267 removeSpeechRecognitionElements(); 268 } else { 269 recognition = new webkitSpeechRecognition(); 270 recognition.continuous = true; 271 recognition.interimResults = false; 272 recognition.lang = 'pl-PL'; 273 showSpeechRecognitionElements(); 274 } 275 276 277 278 279}); 280 281 282 283 284 285 286 287function wcsMainButtonAction(){ 288 if (wcsWrapper.style.display === 'none') { 289 wcsWrapper.style.display = 'block'; 290 setTimeout(function() { 291 wcsWrapper.style.opacity = '1'; 292 wcsWrapper.style.transform = 'translateY(0)'; 293 }, 10); 294
295 wcsOptionItems.forEach((item, index) => { 296 setTimeout(() => { 297 item.style.opacity = '1'; 298 item.style.transform = 'translateY(0)'; 299 }, 100 * (index + 1)); 300 }); 301 302 wcsOptionItems.forEach((item, index) => { 303 setTimeout(() => { 304 const label = item.querySelector('.wcag-system-option-item__label'); 305 label.classList.remove('hide-label'); 306 setTimeout(() => { 307 label.classList.add('hide-label'); 308 }, 2000 + 100 * index); 309 }, 100 * index); 310 }); 311 312 wcsIconsClose.classList.remove('wcw-icon-hidden'); 313 wcsIconsClose.classList.add('wcw-icon-show'); 314 315 wcsIconsWCAG.classList.remove('wcw-icon-show'); 316 wcsIconsWCAG.classList.add('wcw-icon-hidden'); 317 318 wcsIconsPhone.classList.remove('wcw-icon-show'); 319 wcsIconsPhone.classList.add('wcw-icon-hidden'); 320 321 wcsIconsMail.classList.remove('icon-show'); 322 wcsIconsMail.classList.add('wcw-icon-hidden'); 323 324 } else { 325 Array.from(wcsOptionItems).reverse().forEach((item, index) => { 326 const delay = 100 * (wcsOptionItems.length - index - 1); 327 setTimeout(() => { 328 const label = item.querySelector('.wcag-system-option-item__label'); 329 label.classList.remove('hide-label'); 330 331 item.style.opacity = '0'; 332 item.style.transform = 'translateY(20px)'; 333 334 if (index === 0) { 335 setTimeout(() => { 336 wcsWrapper.style.opacity = '0'; 337 wcsWrapper.style.transform = 'translateY(20px)'; 338 setTimeout(() => { 339 wcsWrapper.style.display = 'none'; 340 }, 500); 341 }, 500); 342 } 343 }, delay); 344 }); 345 346 wcsIconsClose.classList.remove('wcw-icon-show'); 347 wcsIconsClose.classList.add('wcw-icon-hidden'); 348 349 wcsIconsWCAG.classList.remove('wcw-icon-hidden'); 350 wcsIconsWCAG.classList.add('wcw-icon-show'); 351 352 wcsIconsPhone.classList.remove('wcw-icon-hidden'); 353 wcsIconsPhone.classList.add('wcw-icon-show'); 354 355 wcsIconsMail.classList.remove('wcw-icon-hidden'); 356 wcsIconsMail.classList.add('wcw-icon-show'); 357 358 } 359 360 361} 362 363 364function iap_wcag_cookie_save(cookie_name, cookie_value) { 365 var expires = new Date(); 366 expires.setTime(expires.getTime() + (1000 * 60 * 60 * 24 * 365)); 367 368 $.cookies.set(cookie_name, cookie_value, { 369 path: '/', 370 expiresAt: expires 371 }); 372} 373 374 375 376 377 378 379 380function initMainWcagComponent(widgetOpen=true,speechOpen=false,cursorReadingOpen=false,readingOpen=false) { 381 const container = document.querySelector('#iap-wcag-main-component'); 382 383 if (container) { 384 if (!container.innerHTML.trim()) { 385 let xhrLinks = getXHRLinks(); 386 var linkElement = document.createElement('link'); 387 linkElement.href = '/live/'+xhrLinks.folder_css+'/pub-css-proportal/css-proportal-wcag-prod.min.css'; 388 linkElement.type = 'text/css'; 389 linkElement.rel = 'stylesheet'; 390 391 document.head.appendChild(linkElement); 392 393 console.log('xhr)'); 394 const xhr = new XMLHttpRequest(); 395 xhr.open('GET', window.location.origin + xhrLinks.link_wcag_module, true); 396 xhr.onreadystatechange = function() { 397 if (xhr.readyState === 4) { 398 if (xhr.status === 200) { 399 try { 400 console.log('xhr status 200)'); 401 const response = JSON.parse(xhr.responseText); 402 if (response.status === "success" && response.html) { 403 console.log('xhr status 200 - success)'); 404 container.innerHTML = response.html; 405 406 setTimeout(function() { 407 var scriptElement = document.createElement('script'); 408 scriptElement.src = '/live/'+xhrLinks.folder_js+'/pub-js-proportal/js-proportal-wcag-prod.min.js'; 409 410 document.body.appendChild(scriptElement); 411 412 if (widgetOpen){ 413 setTimeout(function() { 414 var obj_accord = document.querySelector('#iap-wcag-options'); 415 obj_accord.removeAttribute('hidden'); 416 obj_accord.classList.add('opened'); 417 obj_accord.focus(); 418 419 }, 300); 420 }
421 if (speechOpen && ('webkitSpeechRecognition' in window)){ 422 setTimeout(function() { 423 if (!isListening) { 424 if (voiceReplies) { 425 speakInSpeechRec('Rozpoznawanie gÅosu wÅÄ czone'); 426 } else { 427 autoRespond('Rozpoznawanie gÅosu wÅÄ czone'); 428 } 429 recognition.start(); 430 toggleSpeechRecognitionElements.forEach(el => el.classList.add('js-speech-recon-started')); 431 if (speechRecSearchModule) { 432 speechRecSearchModule.style.display = 'block'; 433 document.body.classList.add('global-speech-rec'); 434 } 435 if (voiceNumbersCookie) voiceNumbers = true; 436 if (voiceNumbers){ 437 wcagSpeechNavNumbersAction('show'); 438 voiceNumbers = true; 439 } 440 } else { 441 if (voiceReplies) { 442 speakInSpeechRec('Rozpoznawanie gÅosu wyÅÄ czone'); 443 } else { 444 autoRespond('Rozpoznawanie gÅosu wyÅÄ czone'); 445 } 446 recognition.stop(); 447 toggleSpeechRecognitionElements.forEach(el => el.classList.remove('js-speech-recon-started')); 448 if (speechRecSearchModule) { 449 speechRecSearchModule.style.display = 'none'; 450 document.body.classList.remove('global-speech-rec'); 451 } 452 if (voiceNumbers){ 453 wcagSpeechNavNumbersAction('hide'); 454 voiceNumbers = false; 455 } 456 } 457 isListening = !isListening; 458 },300); 459 } 460 if (cursorReadingOpen){ 461 setTimeout(function() { 462 console.log('cursorReadingOpen - iapWcagOptionVoiceEnable() - widget init'); 463 iapWcagOptionVoiceEnable(); 464 },1000); 465 } 466 if (readingOpen){ 467 468 } 469 }, 100); 470 471 472 473 } 474 } catch (e) { 475 console.error("BÅÄ d parsowania odpowiedzi JSON", e); 476 } 477 } else { 478 console.error("BÅÄ d Å¼Ä dania AJAX", xhr.statusText); 479 } 480 } 481 }; 482 xhr.send(); 483 } 484 485 } 486} 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508function wcagSpeechNavNumbersAction(status) { 509 if (status === 'show') { 510 console.log('voice numbers tooltips - show'); 511 attachEventListeners(); 512 renderTooltips(); 513 } else if (status === 'hide') { 514 console.log('voice numbers tooltips - hide'); 515 detachEventListeners(); 516 clearTooltips(); 517 } 518} 519 520 521function handle_WCAG_Speech_ClickEvent(event) { 522 event.preventDefault(); 523 const container = document.querySelector('#iap-wcag-main-component'); 524 525 if (container) { 526 if (!container.innerHTML.trim()) { 527 initMainWcagComponent(false,true,false,false); 528 } else { 529 if (('webkitSpeechRecognition' in window)) { 530 setTimeout(function() { 531 if (!isListening) { 532 if (voiceReplies) { 533 speakInSpeechRec('Rozpoznawanie gÅosu wÅÄ czone'); 534 } else { 535 autoRespond('Rozpoznawanie gÅosu wÅÄ czone'); 536 } 537 recognition.start();
538 toggleSpeechRecognitionElements.forEach(el => el.classList.add('js-speech-recon-started')); 539 if (speechRecSearchModule) { 540 speechRecSearchModule.style.display = 'block'; 541 document.body.classList.add('global-speech-rec'); 542 } 543 if (voiceNumbersCookie) voiceNumbers = true; 544 if (voiceNumbers){ 545 wcagSpeechNavNumbersAction('show'); 546 voiceNumbers = true; 547 } 548 } else { 549 if (voiceReplies) { 550 speakInSpeechRec('Rozpoznawanie gÅosu wyÅÄ czone'); 551 } else { 552 autoRespond('Rozpoznawanie gÅosu wyÅÄ czone'); 553 } 554 recognition.stop(); 555 toggleSpeechRecognitionElements.forEach(el => el.classList.remove('js-speech-recon-started')); 556 if (speechRecSearchModule) { 557 speechRecSearchModule.style.display = 'none'; 558 document.body.classList.remove('global-speech-rec'); 559 } 560 if (voiceNumbers){ 561 wcagSpeechNavNumbersAction('hide'); 562 voiceNumbers = false; 563 } 564 } 565 isListening = !isListening; 566 },100); 567 } 568 } 569 570 } 571} 572 573function handle_WCAG_Reading_ClickEvent(event) { 574 event.preventDefault(); 575 const container = document.querySelector('#iap-wcag-main-component'); 576 577 if (container) { 578 579 if (!container.innerHTML.trim()) { 580 console.log('reading - handle_WCAG_Reading_ClickEvent - widget init'); 581 initMainWcagComponent(false,false,true,false); 582 } else { 583 setTimeout(function() { 584 console.log('cursorReadingOpen - iapWcagOptionVoiceEnable() - widget init'); 585 iapWcagOptionVoiceEnable(); 586 },100); 587 } 588 589 } 590} 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607const wcag_speech_nav_scroll_offset_threshold = 10; 608const wcag_speech_nav_selectors = [ 609 'a:not([data-wcag-speech-nav-ignore])[href]', 610 'button:not([data-wcag-speech-nav-ignore]):not([disabled]):not([hidden]):not([class^="speech-rec"]):not([class*=" speech-rec"]):not([class*="info-sw"])', 611 'details', 612 'input:not([disabled])', 613 'select:not([disabled])', 614 'textarea:not([disabled])' 615]; 616 617 618let wcag_speech_nav_eventListenersAttached = false; 619let renderTooltipsInterval = null; 620let lastScrollY = window.scrollY; 621 622function generateId() { 623 let id = 0; 624 return function() { 625 id++; 626 return id; 627 }; 628} 629 630function isVisible(element) { 631 const rect = element.getBoundingClientRect(); 632 return rect.width > 0 && rect.height > 0 && window.getComputedStyle(element).visibility !== 'hidden' && window.getComputedStyle(element).opacity !== '0'; 633} 634 635function isValidElement(element) { 636 const rect = element.getBoundingClientRect(); 637 const withinViewport = rect.top >= 0 && rect.left >= 0 && rect.bottom <= window.innerHeight && rect.right <= window.innerWidth; 638 const hasSize = rect.width > 0 && rect.height > 0; 639 const isFocusable = element.tabIndex >= 0; 640 const isVisibleElement = element.tagName === 'INPUT' ? isVisible(element) : element.offsetParent !== null; 641 return withinViewport && hasSize && isFocusable && isVisibleElement; 642} 643 644function getPosition(element) { 645 const rect = element.getBoundingClientRect(); 646 return { 647 top: rect.top + window.scrollY + rect.height + 10, 648 left: rect.left + window.scrollX + rect.width / 2 649 }; 650} 651 652function createTooltip(id, element) { 653 const tooltip = document.createElement('div'); 654 tooltip.classList.add('wcagSpeechNavTooltip'); 655 tooltip.setAttribute('data-wcag-speech-nav-tooltip-id', id); 656 tooltip.textContent = id; 657 658 if (element.tagName === 'A' && element.target === '_blank') { 659 tooltip.classList.add('newTab'); 660 } else if (element.tagName === 'BUTTON') { 661 tooltip.classList.add('isButton'); 662 } else if (element.tagName === 'INPUT') { 663 if (element.type === 'radio' || element.type === 'checkbox') { 664 tooltip.classList.add('isInputRadioCheckbox'); 665 } else { 666 tooltip.classList.add('isInput'); 667 } 668 } 669 670 return tooltip; 671} 672 673function getTooltipContainer() { 674 let container = document.getElementById('wcagSpeechNavTooltipsWrapper'); 675 if (!container) { 676 container = document.createElement('div'); 677 container.id = 'wcagSpeechNavTooltipsWrapper'; 678 document.body.appendChild(container); 679 } 680 return container; 681} 682 683function clearTooltips() { 684 const container = getTooltipContainer(); 685 container.innerHTML = ''; 686} 687 688function renderTooltip(element, id) { 689 const container = getTooltipContainer(); 690 let tooltip = container.querySelector(`.wcagSpeechNavTooltip[data-wcag-speech-nav-tooltip-id="${id}"]`); 691 if (!tooltip) { 692 tooltip = createTooltip(id, element); 693 container.appendChild(tooltip); 694 } 695 696 const position = getPosition(element); 697 tooltip.style.top = `${position.top}px`; 698 tooltip.style.left = `${position.left}px`; 699 700 const elementWithSameAttribute = document.querySelector(`[data-wcag-speech-nav-tooltip-element-id="${id}"]`,); 701 elementWithSameAttribute?.removeAttribute('data-wcag-speech-nav-tooltip-element-id'); 702 703 element.setAttribute('data-wcag-speech-nav-tooltip-element-id', String(id)); 704} 705 706function renderTooltips() { 707 clearTooltips(); 708 const elements = document.querySelectorAll(wcag_speech_nav_selectors.join(',')); 709 const nextId = generateId(); 710
711 elements.forEach(element => { 712 if (isValidElement(element)) { 713 const id = nextId(); 714 renderTooltip(element, id); 715 } 716 }); 717} 718 719function handleScroll() { 720 if (Math.abs(window.scrollY - lastScrollY) > wcag_speech_nav_scroll_offset_threshold) { 721 renderTooltips(); 722 lastScrollY = window.scrollY; 723 } 724} 725 726function attachEventListeners() { 727 if (!wcag_speech_nav_eventListenersAttached) { 728 let lastScrollY = window.scrollY; 729 730 window.addEventListener('resize', renderTooltips); 731 window.addEventListener('scroll', handleScroll); 732 renderTooltipsInterval = setInterval(renderTooltips, 2000); 733 document.addEventListener('click', (event) => { 734 if (event.target.matches('button')) { 735 clearTooltips(); 736 } 737 }); 738 739 wcag_speech_nav_eventListenersAttached = true; 740 } 741} 742 743function detachEventListeners() { 744 if (wcag_speech_nav_eventListenersAttached) { 745 wcag_speech_nav_eventListenersAttached = false; 746 window.removeEventListener('resize', renderTooltips); 747 window.removeEventListener('scroll', handleScroll); 748 clearInterval(renderTooltipsInterval); 749 document.removeEventListener('click', clearTooltips); 750 751 clearTooltips(); 752 } 753} 754 755function performAction(id) { 756 const element = document.querySelector(`[data-wcag-speech-nav-tooltip-element-id="${id}"]`); 757 if (element) { 758 if (element.tagName === 'A') { 759 window.location.href = element.getAttribute('href'); 760 } else if (['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'].includes(element.tagName)) { 761 element.focus(); 762 if (element.tagName === 'BUTTON') { 763 if (confirm('Czy wykonaÄ akcjÄ na przycisku?')) { 764 element.click(); 765 } 766 } 767 } 768 } 769} 770 771 772 773 774 775 776 777 778function wcgChangeWindowSizeAction(cardSize) { 779 const container = document.querySelector('[data-wcg-window-role="wcg-info-main-container"]'); 780 if (!container) return; 781 const currentClass = container.className; 782 783 let newClass = ''; 784 cardSize = cardSize.trim(); 785 if (cardSize === 'small') { 786 newClass = 'small-window'; 787 } else if (cardSize === 'medium') { 788 newClass = 'medium-window'; 789 } else if (cardSize === 'large') { 790 newClass = 'large-window'; 791 } 792 793 container.className = currentClass.replace(/(small-window|medium-window|large-window)/g, '').trim(); 794 if (newClass) { 795 container.classList.add(newClass); 796 } 797 798} 799 800function wcgChangeWindowSize() { 801 const container = document.querySelector('[data-wcg-window-role="wcg-info-main-container"]'); 802 if (!container) return; 803 const currentClass = container.className; 804 805 if (currentClass.includes('small-window')) { 806 container.className = currentClass.replace('small-window', 'medium-window'); 807 } else if (currentClass.includes('medium-window')) { 808 container.className = currentClass.replace('medium-window', 'large-window'); 809 } else if (currentClass.includes('large-window')) { 810 container.className = currentClass.replace('large-window', 'small-window'); 811 } else { 812 container.className = 'small-window'; 813 } 814} 815 816function wcgAddChangeSizeClickListeners() { 817 const buttons = document.querySelectorAll('[data-wcg-btn-role="change-size"]'); 818 buttons.forEach(button => { 819 button.addEventListener('click', wcgChangeWindowSize); 820 }); 821} 822 823 824function wcgRemoveChangeSizeClickListeners() { 825 const buttons = document.querySelectorAll('[data-wcg-btn-role="change-size"]'); 826 buttons.forEach(button => { 827 button.removeEventListener('click', wcgChangeWindowSize); 828 }); 829} 830 831 832 833 834function wcgChangeWindowClose(){ 835 const container = document.querySelector('[data-wcg-window-role="wcg-info-main-container"]'); 836 if (container) { 837 container.innerHTML = ''; 838 container.setAttribute('hidden', true); 839 } 840} 841function wcgAddChangeCloseClickListeners() { 842 const buttons = document.querySelectorAll('[data-wcg-btn-role="close"]'); 843 buttons.forEach(button => { 844 button.addEventListener('click', wcgChangeWindowClose); 845 }); 846} 847 848 849 850 851function wcgRemoveClickEventToTabsListeners() { 852 const buttons = document.querySelectorAll('[data-wcg-role-tab="true"]'); 853 buttons.forEach(button => { 854 button.removeEventListener('click', wcgHandleTabClick); 855 });
856} 857 858function wcgAddClickEventToTabs() { 859 const buttons = document.querySelectorAll('[data-wcg-role-tab="true"]'); 860 buttons.forEach(button => { 861 button.addEventListener('click', wcgHandleTabClick); 862 }); 863} 864 865function wcgHandleTabClick(event) { 866 const tabButton = event.target.closest('[data-wcg-role-tab="true"]'); 867 if (!tabButton) return; 868 const cardId = tabButton.getAttribute('data-wcg-destination-id'); 869 const tabId = tabButton.getAttribute('data-wcg-tab-destination-id'); 870 871 const cardSize = tabButton.getAttribute('data-wcg-window-size'); 872 const cardDestinationSize = tabButton.getAttribute('data-wcg-destination-window-size'); 873 874 if (cardDestinationSize){ 875 wcgChangeWindowSizeAction(cardDestinationSize); 876 } 877 878 if (cardId && tabId) { 879 wcgChangeCardActionFromTab(cardId, tabId); 880 } 881} 882 883 884function wcgAddClickEventToButtons() { 885 const buttons = document.querySelectorAll('[data-wcg-role-button="true"]'); 886 buttons.forEach(button => { 887 button.addEventListener('click', wcgHandleButtonClick); 888 }); 889} 890 891function wcgHandleButtonClick(event) { 892 const button = event.target.closest('[data-wcg-role-button="true"]'); 893 if (!button) return; 894 const cardId = button.getAttribute('data-wcg-destination-id'); 895 const currentCardId = button.getAttribute('data-wcg-current-id'); 896 const parentCard = button.getAttribute('data-wcg-parent'); 897 const parentCardId = button.getAttribute('data-wcg-parent-id'); 898 const tabId = button.getAttribute('data-wcg-tab-destination-id'); 899 900 const cardSize = button.getAttribute('data-wcg-window-size'); 901 const cardDestinationSize = button.getAttribute('data-wcg-destination-window-size'); 902 if (cardDestinationSize){ 903 wcgChangeWindowSizeAction(cardDestinationSize); 904 } 905 906 if (cardId && parentCard && parentCardId && currentCardId && tabId) { 907 wcgChangeCardAction(cardId, currentCardId, parentCard, parentCardId, tabId); 908 } 909} 910 911function wcgRemoveClickEventFromButtons() { 912 const buttons = document.querySelectorAll('[data-wcg-role-button="true"]'); 913 buttons.forEach(button => { 914 button.removeEventListener('click', wcgHandleButtonClick); 915 }); 916} 917 918function wcgChangeCardAction(cardId, currentCardId, parentCard, parentCardId, tabId) { 919 console.log('-------------------'); 920 console.log('-- Button Action:'); 921 console.log('-- -- cardId: '+cardId); 922 console.log('-- -- currentCardId: '+currentCardId); 923 console.log('-- -- parentCard: '+parentCard); 924 console.log('-- -- parentCardId: '+parentCardId); 925 console.log('-- -- tabId: '+tabId); 926 const currentElement = document.querySelector(`[data-wcg-card-id="${currentCardId}"]`); 927 const targetElement = document.querySelector(`[data-wcg-card-id="${cardId}"]`); 928 929 wcgChangeTabAction(tabId); 930 931 932 933 if (currentElement) { 934 currentElement.setAttribute('hidden', true); 935 } 936 937 if (targetElement) { 938 targetElement.removeAttribute('hidden'); 939 } 940} 941 942function wcgChangeCardActionFromTab(cardId, tabId) { 943 console.log('-------------------'); 944 console.log('-- Button TAB Action:'); 945 console.log('-- -- cardId: '+cardId); 946 console.log('-- -- tabId: '+tabId); 947 const targetElement = document.querySelector(`[data-wcg-card-id="${cardId}"]`); 948 949 const elements = document.querySelectorAll('[data-wcg-card-id]'); 950 951 elements.forEach(element => { 952 const cardId = element.getAttribute('data-wcg-card-id'); 953 954 element.setAttribute('hidden', 'true'); 955 }); 956 957 wcgChangeTabAction(tabId); 958 959 960 961 962 if (targetElement) { 963 targetElement.removeAttribute('hidden'); 964 } 965} 966 967function wcgChangeTabAction(tabId) { 968 const buttons = document.querySelectorAll('[data-wcg-tab-id]'); 969 970 buttons.forEach(button => { 971 button.classList.remove('active'); 972 }); 973 974 const activeButton = document.querySelector(`[data-wcg-tab-id="${tabId}"]`); 975 976 if (activeButton) { 977 activeButton.classList.add('active'); 978 } 979} 980 981 982 983 984onDocumentReady(function() { 985 986 var wcagHelpButtonsActivated = document.querySelectorAll('button[data-wcag-system-option="wcag_help"]'); 987 if (wcagHelpButtonsActivated){ 988 wcagHelpButtonsActivated.forEach(function(button) { 989 button.addEventListener('click', function(){ 990 const cardId = button.getAttribute('data-wcg-info-box-card'); 991 wcgOpenInfoBoxSystem(cardId,'small'); 992 }); 993 }); 994 } 995 996 var helpCenterButtonsActivated = document.querySelectorAll('button[data-wcag-system-option="help_center"]'); 997 if (helpCenterButtonsActivated){ 998 helpCenterButtonsActivated.forEach(function(button) { 999 button.addEventListener('click', function(){ 1000 const cardId = button.getAttribute('data-wcg-info-box-card'); 1001 wcgOpenInfoBoxSystem_helpCenter(cardId,'small'); 1002 }); 1003 }); 1004 } 1005 const contentInner = document.querySelector('.wcg-info-sw-push-content-wrapper'); 1006 const title = document.querySelector('.wcg-info-sw-push-content-title'); 1007 const topNavTitle = document.querySelector('.wcg-info-sw-top-nav-title'); 1008 1009 if (contentInner && title && topNavTitle) { 1010 const titleHeight = title.offsetHeight; 1011 1012 contentInner.addEventListener('scroll', () => { 1013 const scrollOffset = contentInner.scrollTop; 1014 1015 if (scrollOffset > titleHeight) { 1016 topNavTitle.style.opacity = '1'; 1017 topNavTitle.style.height = 'auto'; 1018 } else { 1019 topNavTitle.style.opacity = '0'; 1020 topNavTitle.style.height = '0'; 1021 } 1022 }); 1023 } 1024 1025 1026 1027}); 1028 1029 1030 1031 1032 1033var infoBoxCSSLoaded = false; 1034 1035function loadInfoBoxCSS(){ 1036 let xhrLinks = getXHRLinks(); 1037 var linkElement = document.createElement('link'); 1038 linkElement.href = '/live/'+xhrLinks.folder_css+'/pub-css-proportal/wcag-widget-info-box.min.css?v='+xhrLinks.timestamp; 1039 linkElement.type = 'text/css'; 1040 linkElement.rel = 'stylesheet'; 1041 document.head.appendChild(linkElement); 1042 infoBoxCSSLoaded = true; 1043} 1044 1045function wcgOpenInfoBoxSystem(cardId,size) { 1046 const container = document.querySelector('[data-wcg-window-role="wcg-info-main-container"]'); 1047 if (!infoBoxCSSLoaded){ 1048 loadInfoBoxCSS(); 1049 } 1050 if (container) { 1051 const infoBox = container.querySelector('[data-wcg-info-box-system="wcag"]'); 1052 1053 if (!infoBox) { 1054 const currentClass = container.className; 1055 container.className = currentClass.replace(/(wcg-theme-help|wcg-theme-wcag|window-offline|window-activated)/g, '').trim(); 1056 container.classList.add('window-offline'); 1057 1058 const xhr = new XMLHttpRequest(); 1059 let xhrLinks = getXHRLinks(); 1060 xhr.open('GET', window.location.origin + xhrLinks.link_minibox_wcag, true); 1061 1062 xhr.onreadystatechange = function() { 1063 if (xhr.readyState === 4) { 1064 if (xhr.status === 200) { 1065 try { 1066 const response = JSON.parse(xhr.responseText); 1067 if (response.status === "success" && response.html) { 1068 1069 wcgRemoveClickEventToTabsListeners(); 1070 wcgRemoveClickEventFromButtons(); 1071 wcgRemoveChangeSizeClickListeners(); 1072 wcgRemoveChangeSizeClickListeners(); 1073 1074 container.innerHTML = response.html; 1075 container.removeAttribute('hidden'); 1076 if (!size) size = 'small'; 1077 wcgChangeWindowSizeAction(size); 1078 container.classList.add('wcg-theme-wcag'); 1079 container.classList.remove('window-offline'); 1080 container.classList.add('window-activated'); 1081 1082 wcgAddClickEventToButtons(); 1083 wcgAddClickEventToTabs(); 1084 wcgAddChangeCloseClickListeners(); 1085 wcgAddChangeSizeClickListeners(); 1086 1087 if (cardId!=null && cardId>0){ 1088 wcgChangeCardAction(cardId, 0, 0, 0, cardId+1); 1089 } 1090 } 1091 } catch (e) { 1092 console.error("BÅÄ d parsowania odpowiedzi JSON", e); 1093 } 1094 } else { 1095 console.error("BÅÄ d Å¼Ä dania AJAX", xhr.statusText); 1096 } 1097 } 1098 }; 1099 1100 xhr.send(); 1101 } 1102 } 1103} 1104 1105 1106function wcgOpenInfoBoxSystem_helpCenter(cardId,size) { 1107 const container = document.querySelector('[data-wcg-window-role="wcg-info-main-container"]'); 1108 if (!infoBoxCSSLoaded){ 1109 loadInfoBoxCSS(); 1110 } 1111 if (container) { 1112 const infoBox = container.querySelector('[data-wcg-info-box-system="help"]'); 1113 1114 if (!infoBox) { 1115 const currentClass = container.className; 1116 container.className = currentClass.replace(/(wcg-theme-help|wcg-theme-wcag|window-offline|window-activated)/g, '').trim(); 1117 container.classList.add('window-offline'); 1118 1119 const xhr = new XMLHttpRequest(); 1120 let xhrLinks = getXHRLinks(); 1121 xhr.open('GET', window.location.origin + xhrLinks.link_minibox_help, true); 1122 1123 xhr.onreadystatechange = function() { 1124 if (xhr.readyState === 4) { 1125 if (xhr.status === 200) { 1126 try { 1127 const response = JSON.parse(xhr.responseText); 1128 if (response.status === "success" && response.html) { 1129 1130 wcgRemoveClickEventToTabsListeners(); 1131 wcgRemoveClickEventFromButtons(); 1132 wcgRemoveChangeSizeClickListeners(); 1133 wcgRemoveChangeSizeClickListeners(); 1134 1135 container.innerHTML = response.html; 1136 container.removeAttribute('hidden'); 1137 if (!size) size = 'small'; 1138 wcgChangeWindowSizeAction(size); 1139 container.classList.add('wcg-theme-help'); 1140 container.classList.remove('window-offline'); 1141 container.classList.add('window-activated'); 1142 1143 wcgAddClickEventToButtons(); 1144 wcgAddClickEventToTabs(); 1145 wcgAddChangeCloseClickListeners(); 1146 wcgAddChangeSizeClickListeners(); 1147 1148 if (cardId!=null && cardId>0){ 1149 wcgChangeCardAction(cardId, 0, 0, 0, cardId+1); 1150 } 1151 1152 } 1153 } catch (e) { 1154 console.error("BÅÄ d parsowania odpowiedzi JSON", e); 1155 } 1156 } else { 1157 console.error("BÅÄ d Å¼Ä dania AJAX", xhr.statusText); 1158 } 1159 } 1160 }; 1161 1162 xhr.send(); 1163 } 1164 } 1165} 1166 1167 1168onDocumentReady(function() { 1169 function handleShortcut(event) {
1170 const key = event.key.toUpperCase(); 1171 const ctrl = event.ctrlKey; 1172 const alt = event.altKey; 1173 const cmd = event.metaKey; 1174 const shift = event.shiftKey; 1175 1176 1177 switch(true) { 1178 case ctrl && key === 'K': 1179 event.preventDefault(); 1180 const keyShortcut_search_inpu_main = document.querySelector('input[data-key-shorcut="search-input-main"]'); 1181 if (keyShortcut_search_inpu_main){ 1182 keyShortcut_search_inpu_main.focus(); 1183 } 1184 break; 1185 case ctrl && shift && key === 'M': 1186 event.preventDefault(); 1187 const keyShortcut_menuSection = document.getElementById('section-landmark-header-menu'); 1188 if (keyShortcut_menuSection) { 1189 const keyShortcut_menu_firstLinkOrButton = keyShortcut_menuSection.querySelector('a, button'); 1190 if (keyShortcut_menu_firstLinkOrButton) { 1191 keyShortcut_menu_firstLinkOrButton.focus(); 1192 keyShortcut_menu_firstLinkOrButton.scrollIntoView(); 1193 } else { 1194 keyShortcut_menuSection.focus(); 1195 } 1196 keyShortcut_menuSection.scrollIntoView(); 1197 } 1198 break; 1199 case ctrl && shift && key === 'L': 1200 event.preventDefault(); 1201 const keyShortcut_breadcrumbsSection = document.getElementById('section-landmark-breadcrumbs'); 1202 if (keyShortcut_breadcrumbsSection) { 1203 const keyShortcut_breadcrumbs_firstLinkOrButton = keyShortcut_breadcrumbsSection.querySelector('a, button'); 1204 if (keyShortcut_breadcrumbs_firstLinkOrButton) { 1205 keyShortcut_breadcrumbs_firstLinkOrButton.focus(); 1206 keyShortcut_breadcrumbs_firstLinkOrButton.scrollIntoView(); 1207 } else { 1208 keyShortcut_breadcrumbsSection.focus(); 1209 } 1210 keyShortcut_breadcrumbsSection.scrollIntoView(); 1211 } 1212 break; 1213 case alt && shift && key === 'T': 1214 event.preventDefault(); 1215 document.getElementById('section-landmark-main-content').scrollIntoView(); 1216 break; 1217 case alt && shift && key === 'S': 1218 event.preventDefault(); 1219 const keyShortcut_footerSection = document.getElementById('section-landmark-footer'); 1220 if (keyShortcut_footerSection) { 1221 const keyShortcut_footer_firstLinkOrButton = keyShortcut_footerSection.querySelector('a, button'); 1222 if (keyShortcut_footer_firstLinkOrButton) { 1223 keyShortcut_footer_firstLinkOrButton.focus(); 1224 keyShortcut_footer_firstLinkOrButton.scrollIntoView(); 1225 } else { 1226 keyShortcut_footerSection.focus(); 1227 } 1228 keyShortcut_footerSection.scrollIntoView(); 1229 } 1230 break; 1231 case alt && shift && key === 'I': 1232 event.preventDefault(); 1233 document.getElementById('section-landmark-info-scrollbar').scrollIntoView(); 1234 break; 1235 1236 case alt && shift && key === 'G': 1237 event.preventDefault(); 1238 document.getElementById('section-landmark-big-map').scrollIntoView(); 1239 break; 1240 1241 case alt && shift && key === 'R': 1242 event.preventDefault(); 1243 const keyShortcut_metryka = document.getElementById('section-landmark-metryka'); 1244 if (keyShortcut_metryka) { 1245 const firstButton = keyShortcut_metryka.querySelector('button'); 1246 if (firstButton) { 1247 firstButton.focus(); 1248 } 1249 keyShortcut_metryka.scrollIntoView(); 1250 } 1251 break; 1252 case alt && shift && key === 'V': 1253 event.preventDefault();
1254 const keyShortcut_starsze = document.getElementById('section-landmark-starsze'); 1255 if (keyShortcut_starsze) { 1256 const firstButton = keyShortcut_starsze.querySelector('button'); 1257 if (firstButton) { 1258 firstButton.focus(); 1259 } 1260 keyShortcut_starsze.scrollIntoView(); 1261 } 1262 break; 1263 case alt && shift && key === 'H': 1264 event.preventDefault(); 1265 const keyShortcut_historia = document.getElementById('section-landmark-historia'); 1266 if (keyShortcut_historia) { 1267 const firstButton = keyShortcut_historia.querySelector('button'); 1268 if (firstButton) { 1269 firstButton.focus(); 1270 } 1271 keyShortcut_historia.scrollIntoView(); 1272 } 1273 break; 1274 case ctrl && shift && key === 'E': 1275 event.preventDefault(); 1276 const keyShortcut_shareSection = document.getElementById('m-share'); 1277 if (keyShortcut_shareSection) { 1278 keyShortcut_shareSection.click(); 1279 const keyShortcut_firstLinkOrButton = keyShortcut_shareSection.querySelector('a, button'); 1280 if (keyShortcut_firstLinkOrButton) { 1281 keyShortcut_firstLinkOrButton.focus(); 1282 keyShortcut_firstLinkOrButton.scrollIntoView(); 1283 } 1284 keyShortcut_shareSection.scrollIntoView(); 1285 } 1286 break; 1287 case ctrl && shift && key === 'A': 1288 event.preventDefault(); 1289 const keyShortcut_asideSection = document.getElementById('section-landmark-main-aside'); 1290 if (keyShortcut_asideSection) { 1291 const keyShortcut_aside_firstLinkOrButton = keyShortcut_asideSection.querySelector('a, button'); 1292 if (keyShortcut_aside_firstLinkOrButton) { 1293 keyShortcut_aside_firstLinkOrButton.focus(); 1294 keyShortcut_aside_firstLinkOrButton.scrollIntoView(); 1295 } else { 1296 keyShortcut_asideSection.focus(); 1297 } 1298 keyShortcut_asideSection.scrollIntoView(); 1299 } 1300 break; 1301 case alt && shift && key === 'D': 1302 event.preventDefault(); 1303 initMainWcagComponent(false); 1304 setTimeout(function() { 1305 const keyShortcut_wcagWidgetWindow = document.getElementById('iap-wcag-options'); 1306 if (keyShortcut_wcagWidgetWindow) { 1307 keyShortcut_wcagWidgetWindow.removeAttribute('hidden'); 1308 keyShortcut_wcagWidgetWindow.classList.add('opened'); 1309 keyShortcut_wcagWidgetWindow.focus(); 1310 } 1311 },100); 1312 break; 1313 case ctrl && key === '/': 1314 event.preventDefault(); 1315 initMainWcagComponent(false); 1316 wcgOpenInfoBoxSystem(4,'large'); 1317 break; 1318 case alt && shift && key === 'C': 1319 event.preventDefault(); 1320 initMainWcagComponent(false); 1321 wcgOpenInfoBoxSystem_helpCenter(1,'small'); 1322 break; 1323 } 1324 } 1325 1326 document.addEventListener('keydown', handleShortcut); 1327}); 1328
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.