1if (typeof window.JEyed === 'undefined') { 2 window.JEyed = function(result) { 3 var _private = { 4 inited: false, 5 speakTimer: false, 6 options: typeof result === 'object' && typeof result.OPTIONS === 'object' ? result.OPTIONS : {}, 7 }; 8 9 Object.defineProperties(this, { 10 inited: { 11 get: function() { 12 return _private.inited; 13 }, 14 set: function(value) { 15 if (value) { 16 _private.inited = true; 17 } 18 } 19 }, 20 speakTimer: { 21 get: function() { 22 return _private.speakTimer; 23 }, 24 set: function(value) { 25 _private.speakTimer = value; 26 } 27 }, 28 }); 29 30 this.result = function(key) { 31 if (typeof result === 'object') { 32 if (typeof key !== 'undefined') { 33 if (Object.keys(result).indexOf(key) > -1) { 34 return result[key]; 35 } 36 } 37 } 38 39 return undefined; 40 } 41 42 this.options = function(key, value) { 43 var that = this; 44 45 if (typeof key !== 'undefined') { 46 if (Object.keys(_private.options).indexOf(key) > -1) { 47 if (typeof value !== 'undefined') { 48 if (that.node) { 49 var item = that.node.querySelector('.eyed-panel__item[data-option=' + key + ']'); 50 if (item) { 51 var itemValues = Array.prototype.slice.call(item.querySelectorAll('.eyed-panel__item-value')); 52 if (itemValues) { 53 for (var i in itemValues) { 54 BX.removeClass(itemValues[i], 'active'); 55 } 56 } 57 58 var itemValue = item.querySelector('.eyed-panel__item-value[data-option_value="' + value + '"]'); 59 if (itemValue) { 60 _private.options[key] = value; 61 62 if (key === 'SPEAKER') { 63 if (value == 0) { 64 that.stopSpeak(); 65 } 66 } 67 else if (key === 'FONT-SIZE') { 68 that.dispatchWindowResize(); 69 } 70 else if (key === 'IMAGES') { 71 that.dispatchWindowResize(); 72 } 73 74 BX.addClass(itemValue, 'active'); 75 } 76 } 77 } 78 } 79 else { 80 return _private.options[key]; 81 } 82 } 83 } 84 85 return undefined; 86 } 87 88 this.getClasses = function() { 89 var classes = []; 90 91 for (var key in _private.options) { 92 if (Object.hasOwnProperty.call(_private.options, key)) { 93 var value = _private.options[key]; 94 if (value == 0) { 95 value = 'off'; 96 } 97 else if (value == 1) { 98 value = 'on'; 99 } 100 101 classes.push('eyed--' + key.toLowerCase() + '--' + value.toLowerCase()); 102 } 103 } 104 105 classes.push('eyed'); 106 107 return classes; 108 } 109 110 this.save = function() { 111 BX.setCookie( 112 this.result('COOKIE')['OPTIONS'], 113 JSON.stringify(_private.options), 114 { 115 path: arAsproOptions['SITE_DIR'], 116 expires: 355 * 86400 // 1 year 117 } 118 ); 119 120 this.updateBodyClasses(); 121 } 122 123 var that = this; 124 125 that.init(); 126 } 127 128 window.JEyed.prototype = { 129 node: null, 130 textNode: null, 131 textRate: 1.1, 132 handlers: {}, 133 134 init: function() { 135 var that = this; 136 137 if (!that.inited) { 138 that.inited = true; 139 140 that.node = BX('eyed-panel'); 141 that.node.eyed = that; 142 143 that.textNode = BX.create({ 144 tag: 'div', 145 props: {'class': 'eyed-panel__speech'}, 146 style: {'display': 'none'}, 147 events: {}, 148 children: {}, 149 text: '', 150 html: '', 151 }); 152 153 that.bindEvents(); 154 155 that.speak(document.title); 156 } 157 }, 158 159 bindEvents: function() { 160 var that = this; 161 162 if (that.node) { 163 if (typeof that.onToggleClick !== 'function') { 164 // live click on document 165 that.onToggleClick = function(e) { 166 if (!e) { 167 e = window.event; 168 } 169 170 var target = e.target || e.srcElement; 171 172 if ( 173 typeof target !== 'undefined' && 174 target 175 ) { 176 // there is need IE hack for svg target here
177 // var toggle = target.closest('.eyed-toggle'); 178 179 var toggle = null; 180 var parent = target; 181 while (parent) { 182 if ( 183 typeof parent.matches !== 'undefined' && 184 parent.matches('.eyed-toggle') 185 ) { 186 toggle = parent; 187 break; 188 } 189 else{ 190 parent = parent.parentElement || parent.parentNode; 191 } 192 } 193 194 if (toggle) { 195 if (that.isActive()) { 196 that.disable(); 197 } 198 else { 199 that.activate(); 200 } 201 } 202 } 203 } 204 } 205 document.addEventListener('click', that.onToggleClick); 206 207 if (that.getSynth()) { 208 that.getSynth().onerror = function(e) { 209 that.stopSpeak(); 210 } 211 } 212 else { 213 if (that.options('SPEAKER')) { 214 that.options('SPEAKER', 0); 215 that.save(); 216 217 var item = that.node.querySelector('.eyed-panel__item[data-option="SPEAKER"]') 218 if (item) { 219 BX.remove(item); 220 } 221 } 222 } 223 224 if (navigator.userAgent.indexOf('MSIE') !== -1) { 225 that.options('COLOR-SCHEME', 'black'); 226 that.save(); 227 228 var item = that.node.querySelector('.eyed-panel__item[data-option="COLOR-SCHEME"]') 229 if (item) { 230 var itemValues = Array.prototype.slice.call(item.querySelectorAll('.eyed-panel__item-value:not([data-option_value="black"])')); 231 if (itemValues) { 232 for (var i in itemValues) { 233 BX.remove(itemValues[i]); 234 } 235 } 236 } 237 } 238 239 that.bindEyedEvents(); 240 } 241 }, 242 243 unbindEvents: function() { 244 if (typeof this.onToggleClick === 'function') { 245 document.removeEventListener('click', this.onToggleClick); 246 } 247 248 this.unbindEyedEvents(); 249 }, 250 251 bindEyedEvents: function() { 252 var that = this; 253 254 if (that.node) { 255 if (typeof that.onDocClick !== 'function') { 256 // live click on document 257 that.onDocClick = function(e) { 258 if (that.isActive()) { 259 if (!e) { 260 e = window.event; 261 } 262 263 var target = e.target || e.srcElement; 264 265 if ( 266 typeof target !== 'undefined' && 267 target 268 ) { 269 // there is need IE hack for svg target here 270 // var block = target.closest('#eyed-panel'); 271 272 var panel = null; 273 var parent = target; 274 while (parent) { 275 if ( 276 typeof parent.matches !== 'undefined' && 277 parent.matches('#eyed-panel') 278 ) { 279 panel = parent; 280 break; 281 } 282 else{ 283 parent = parent.parentElement || parent.parentNode; 284 } 285 } 286 287 if (panel) { 288 // there is need IE hack for svg target here 289 // var itemValue = target.closest('.eyed-panel__item-value'); 290 291 var itemValue = null; 292 var parent = target; 293 while (parent) { 294 if ( 295 typeof parent.matches !== 'undefined' && 296 parent.matches('.eyed-panel__item-value') 297 ) { 298 itemValue = parent; 299 break; 300 } 301 else{ 302 parent = parent.parentElement || parent.parentNode; 303 } 304 } 305 306 if (itemValue) { 307 BX.PreventDefault(e); 308 309 if (!BX.hasClass(itemValue, 'active')) { 310 var item = itemValue.closest('.eyed-panel__item'); 311 if (item) { 312 var key = BX.data(item, 'option'); 313 var value = BX.data(itemValue, 'option_value').toString(); 314 if (key.length && value.length) { 315 that.options(key, value); 316 that.save(); 317 } 318 } 319 } 320 } 321 } 322 } 323 } 324 } 325 } 326 document.addEventListener('click', that.onDocClick); 327 328 if (that.getSynth()) { 329 if (typeof that.onDocMouseDown !== 'function') { 330 // live mouse down on document 331 that.onDocMouseDown = function(e) { 332 if (that.isActive()) { 333 if (!e) { 334 e = window.event; 335 } 336 337 var target = e.target || e.srcElement; 338 339 if ( 340 typeof target !== 'undefined' && 341 target 342 ) { 343 // there is need IE hack for svg target here
344 // var panel = target.closest('#eyed-panel'); 345 346 var panel = null; 347 var parent = target; 348 while (parent) { 349 if ( 350 typeof parent.matches !== 'undefined' && 351 parent.matches('#eyed-panel') 352 ) { 353 panel = parent; 354 break; 355 } 356 else{ 357 parent = parent.parentElement || parent.parentNode; 358 } 359 } 360 361 if (!panel) { 362 if ( 363 that.isActive() && 364 that.options('SPEAKER') != 0 365 ) { 366 that.stopSpeak(); 367 } 368 } 369 } 370 } 371 } 372 } 373 document.addEventListener('mousedown', that.onDocMouseDown); 374 375 if (typeof that.onDocMouseUp !== 'function') { 376 // live mouse up on document 377 that.onDocMouseUp = function(e) { 378 if (that.isActive()) { 379 if (!e) { 380 e = window.event; 381 } 382 383 var target = e.target || e.srcElement; 384 385 if ( 386 typeof target !== 'undefined' && 387 target 388 ) { 389 // there is need IE hack for svg target here 390 // var panel = target.closest('#eyed-panel'); 391 392 var panel = null; 393 var parent = target; 394 while (parent) { 395 if ( 396 typeof parent.matches !== 'undefined' && 397 parent.matches('#eyed-panel') 398 ) { 399 panel = parent; 400 break; 401 } 402 else{ 403 parent = parent.parentElement || parent.parentNode; 404 } 405 } 406 407 if (!panel) { 408 setTimeout(function() { 409 var text = that.getSelection(); 410 if ( 411 typeof text !== 'undefined' && 412 text.length 413 ) { 414 that.speak(text); 415 } 416 else { 417 that.stopSpeak(); 418 } 419 }, 100); 420 } 421 } 422 } 423 } 424 } 425 document.addEventListener('mouseup', that.onDocMouseUp); 426 427 if (typeof that.onDocMouseOver !== 'function') { 428 // live mouse enter on document 429 that.onDocMouseOver = function(e) { 430 if (that.isActive()) { 431 if (!e) { 432 e = window.event; 433 } 434 435 var target = e.target || e.srcElement; 436 if ( 437 typeof target !== 'undefined' && 438 target 439 ) { 440 var link = target.closest('a') || target.closest('.btn') || target.closest('.switcher-title') || target.closest('[data-eyed_speak]') || target.closest('[title]') || target.closest('[data-event="jqm"]'); 441 if (link) { 442 var overTimer = setInterval(function() { 443 if (!that.speakTimer) { 444 if (overTimer) { 445 clearInterval(overTimer); 446 overTimer = false; 447 } 448 449 var text = that.getNodeText(link); 450 451 if ( 452 typeof text !== 'undefined' && 453 text.length 454 ) { 455 that.speak(text); 456 } 457 } 458 }, 100); 459 460 var onLinkMouseOut = function() { 461 if (overTimer) { 462 clearInterval(overTimer); 463 overTimer = false; 464 } 465 466 link.removeEventListener('mouseout', onLinkMouseOut); 467 } 468 469 link.addEventListener('mouseout', onLinkMouseOut); 470 } 471 } 472 } 473 } 474 } 475 document.addEventListener('mouseover', that.onDocMouseOver); 476 } 477 478 } 479 }, 480 481 unbindEyedEvents: function() { 482 if (typeof this.onDocClick === 'function') { 483 document.removeEventListener('click', this.onDocClick); 484 } 485 486 if (typeof this.onDocMouseDown === 'function') { 487 document.removeEventListener('mousedown', this.onDocMouseDown); 488 } 489 490 if (typeof this.onDocMouseUp === 'function') { 491 document.removeEventListener('mouseup', this.onDocMouseUp); 492 } 493 494 if (typeof this.onDocMouseOver === 'function') { 495 document.removeEventListener('mouseover', this.onDocMouseOver); 496 } 497 }, 498 499 isActive: function() { 500 return BX.getCookie(this.result('COOKIE')['ACTIVE']) === 'Y'; 501 }, 502 503 activate: function() { 504 var that = this; 505 506 BX.setCookie( 507 that.result('COOKIE')['ACTIVE'], 508 'Y', 509 { 510 path: arAsproOptions['SITE_DIR'], 511 expires: 355 * 86400 // 1 year 512 } 513 ); 514 515 that.updateBodyClasses(); 516 that.bindEyedEvents(); 517 518 var toggles = Array.prototype.slice.call(document.querySelectorAll('.eyed-toggle')); 519 if (toggles) { 520 for (var i in toggles) { 521 toggles[i].setAttribute('title', BX.message('EA_T_NORMAL_VERSION')); 522 523 if (BX.hasClass(toggles[i], 'footer__eyed')) { 524 var title = BX.findChild(toggles[i], { 525 tag: 'span', 526 class: 'footer-eyed__name' 527 }, true); 528 if (title) { 529 title.innerText = BX.message('EA_T_NORMAL_VERSION'); 530 } 531 } else if (BX.hasClass(toggles[i], 'header-eyed')) { 532 var title = BX.findChild(toggles[i], { 533 tag: 'span', 534 class: 'header-eyed__name' 535 }, true); 536 if (title) { 537 title.innerText = BX.message('EA_T_NORMAL_VERSION'); 538 } 539 } 540 } 541 } 542 }, 543 544 disable: function() { 545 var that = this; 546 547 BX.setCookie( 548 that.result('COOKIE')['ACTIVE'], 549 '', 550 { 551 path: arAsproOptions['SITE_DIR'], 552 expires: 355 * 86400 // 1 year 553 } 554 ); 555 556 that.updateBodyClasses(); 557 that.unbindEyedEvents(); 558 559 var toggles = Array.prototype.slice.call(document.querySelectorAll('.eyed-toggle')); 560 if (toggles) { 561 for (var i in toggles) { 562 toggles[i].setAttribute('title', BX.message('EA_T_EYED_VERSION')); 563 564 if (BX.hasClass(toggles[i], 'footer__eyed')) { 565 var title = BX.findChild(toggles[i], { 566 tag: 'span', 567 class: 'footer-eyed__name' 568 }, true); 569 if (title) { 570 title.innerText = BX.message('EA_T_EYED_VERSION'); 571 } 572 } else if (BX.hasClass(toggles[i], 'header-eyed')) { 573 var title = BX.findChild(toggles[i], { 574 tag: 'span', 575 class: 'header-eyed__name' 576 }, true); 577 if (title) { 578 title.innerText = BX.message('EA_T_EYED_VERSION'); 579 } 580 } 581 } 582 } 583 }, 584 585 dispatchWindowResize: function() { 586 if ( 587 typeof Event == 'function' || 588 ( 589 navigator.userAgent.indexOf('MSIE') !== -1 || 590 navigator.appVersion.indexOf('Trident/') > 0 591 ) 592 ) { 593 var resizeEvent = window.document.createEvent('UIEvents'); 594 resizeEvent.initUIEvent('resize', true, false, window, 0); 595 window.dispatchEvent(resizeEvent); 596 } 597 else { 598 var event = new Event('resize'); 599 window.dispatchEvent(event); 600 } 601 }, 602 603 updateBodyClasses: function() { 604 var that = this; 605 606 var classes = that.getClasses(); 607 if (classes) { 608 var attrClass = document.body.getAttribute('class'); 609 attrClass = attrClass.replace(/eyed[^\s]*/gi, ''); 610 attrClass = attrClass.replace(/\s{2,}/gi, ' '); 611 612 if (that.isActive()) { 613 for (var key in classes) { 614 if (Object.hasOwnProperty.call(classes, key)) { 615 attrClass += ' ' + classes[key]; 616 } 617 } 618 } 619 620 document.body.setAttribute('class', attrClass); 621 } 622 }, 623 624 refresh: function(){ 625 var componentAction = 'getEyed'; 626 var componentName = 'aspro:eyed.allcorp3medc'; 627 var sessid = BX.message('bitrix_sessid'); 628 var lang = BX.message('LANGUAGE_ID'); 629 var siteId = arAsproOptions.SITE_ID; 630 var signedParams = this.result('SIGNED_PARAMS'); 631 632 var that = this; 633 BX.ajax({ 634 url: '/bitrix/services/main/ajax.php?mode=ajax&c=' + encodeURIComponent(componentName) +'&action=' + componentAction + '&sessid=' + sessid + '&SITE_ID=' + siteId + '&siteId=' + siteId + '&lang=' + lang + '&signedParameters='
634+ encodeURIComponent(signedParams) + '&clear_cache_session=Y', 635 method: 'POST', 636 async: true, 637 processData: true, 638 scriptsRunFirst: true, 639 emulateOnload: true, 640 start: true, 641 cache: false, 642 onsuccess: function(response){ 643 if(response.trim().length){ 644 if(that.node){ 645 that.unbindEvents(); 646 that.node.parentElement.insertAdjacentHTML('afterBegin', response); 647 that.node.remove(); 648 649 that.node = BX('eyed-panel'); 650 that.node.eyed = that; 651 that.bindEvents(); 652 } 653 } 654 }, 655 onfailure: function(){ 656 657 } 658 }); 659 }, 660 661 checkState: function() { 662 var toggles = Array.prototype.slice.call(document.querySelectorAll('.eyed-toggle')); 663 var togglesInPanel = Array.prototype.slice.call(document.querySelectorAll('.eyed-panel .eyed-toggle')); 664 if (toggles.length > togglesInPanel.length) { 665 this.enable(); 666 } 667 else { 668 this.destroy(); 669 } 670 }, 671 672 isEnabled: function() { 673 if (this.node) { 674 if (this.node.querySelector('.eyed-panel__inner')) { 675 return true; 676 } 677 } 678 679 return false; 680 }, 681 682 destroy: function() { 683 if (this.isEnabled()) { 684 this.disable(); 685 this.unbindEvents(); 686 687 if (this.node) { 688 this.node.innerHTML = ''; 689 } 690 } 691 }, 692 693 enable: function() { 694 if (!this.isEnabled()) { 695 this.refresh(); 696 this.bindEvents(); 697 } 698 }, 699 700 getSelection: function() { 701 var text = ( 702 window.getSelection && 703 window.getSelection().toString() 704 ) || ( 705 document.selection && 706 document.selection.createRange().text 707 ); 708 709 return typeof text === 'undefined' ? false : this.clearText(text); 710 }, 711 712 getNodeText: function(node) { 713 var text = ''; 714 715 if (node) { 716 if (node.closest('.header-cart[title]')) { 717 var text = this.clearText(node.closest('.header-cart').getAttribute('title').toString().trim()); 718 } 719 else { 720 if ( 721 !BX.hasClass(node, 'developer') && 722 !BX.hasClass(node, 'HEADER') 723 ) { 724 var text = this.clearText(node.innerText.toString().trim()); 725 } 726 } 727 728 if ( 729 ( 730 typeof text === 'undefined' || 731 !text.length 732 ) && 733 BX.data(node, 'eyed-speak') 734 ) { 735 var text = this.clearText(BX.data(node, 'eyed_speak').toString().trim()); 736 } 737 738 if ( 739 ( 740 typeof text === 'undefined' || 741 !text.length 742 ) && 743 node.getAttribute('title') 744 ) { 745 var text = this.clearText(node.getAttribute('title').toString().trim()); 746 } 747 748 if ( 749 ( 750 typeof text === 'undefined' || 751 !text.length 752 ) && 753 node.tagName === 'A' 754 ) { 755 var item = node.closest('.grid-list__item') || node.closest('.owl-item'); 756 if (item) { 757 var title = item.querySelector('.switcher-title'); 758 var text = title.innerText.toString().trim(); 759 } 760 } 761 } 762 763 return text; 764 }, 765 766 clearText: function(text) { 767 this.textNode.innerHTML = text; 768 text = this.textNode.innerText.replace(' *', ''); 769 var regex = BX.message('__EA_T_TEXT_REGEX'); 770 771 if (regex.length) { 772 regex = new RegExp(regex, 'i'); 773 774 if (text.match(regex)) { 775 return text; 776 } 777 else { 778 text = ''; 779 } 780 } 781 782 return text; 783 }, 784 785 getTextLang: function(text) { 786 return 'ru-RU'; 787 }, 788 789 getSynth: function() { 790 return window.speechSynthesis || window.mozspeechSynthesis || window.webkitspeechSynthesis; 791 }, 792 793 speak: function(text) { 794 var that = this; 795 796 if ( 797 that.textNode && 798 that.isActive() && 799 that.options('SPEAKER') != 0 && 800 that.getSynth() 801 ) { 802 that.stopSpeak(); 803 804 if ( 805 typeof text !== 'undefined' && 806 text.length 807 ) { 808 text = that.clearText(text); 809 810 try { 811 var message = new SpeechSynthesisUtterance(text); 812 message.lang = that.getTextLang(text); 813 message.rate = that.textRate; 814 815 message.onerror = function(e) { 816 throw e; 817 } 818 819 message.onend = function(e) { 820 if (that.speakTimer) { 821 clearInterval(that.speakTimer); 822 that.speakTimer = false;
823 } 824 } 825 826 that.getSynth().speak(message); 827 828 that.speakTimer = setInterval(function(){ 829 if (that.getSynth().paused) { 830 that.getSynth().resume(); 831 } 832 }, 100); 833 } 834 catch (e) { 835 console.error(e); 836 837 that.stopSpeak(); 838 } 839 } 840 } 841 }, 842 843 stopSpeak: function() { 844 var that = this; 845 846 if (that.speakTimer) { 847 clearInterval(that.speakTimer); 848 that.speakTimer = false; 849 } 850 851 if (that.getSynth()) { 852 that.getSynth().cancel(); 853 } 854 }, 855 } 856}
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.