1(function revwsBootstrap() { 2 if (! window.revwsData) { 3 setTimeout(revwsBootstrap, 1000); 4 return; 5 } 6 var tag = document.createElement('script'); 7 tag.src = window.revwsData.settings.appJsUrl; 8 tag.setAttribute('defer', ''); 9 tag.setAttribute('async', ''); 10 var firstScriptTag = document.getElementsByTagName('script')[0]; 11 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 12 13 // returns true, if reviews are displayed in tab. 14 var displayedInTab = function() { 15 return (window.revwsData && window.revwsData.settings.preferences.placement === 'tab'); 16 } 17 18 if (! window.revws) { 19 window.revws = function(action) { 20 if (window.revwsData) { 21 console.info('revws not loaded yet'); 22 window.revwsData.initActions = window.revwsData.initActions || []; 23 window.revwsData.initActions.push(action); 24 } 25 } 26 } 27 28 var warn = function(msg) { 29 if (console.warn) { 30 console.warn(msg); 31 } 32 return false; 33 } 34 35 /** 36 * this function will not work on all themes. Change it if you use tabs, 37 * and reviews tab will not open automatically when you click on 'read reviews' 38 */ 39 var openTab = function() { 40 var $elem = $("#idTabRevws"); 41 if (! $elem.length) { 42 return warn("Can't find #idTabRevws"); 43 } 44 45 var id = $elem.parent().attr('id'); 46 if (! id) { 47 return warn("Can't find id attribute of tab"); 48 } 49 50 var $handle = $('*[href="#'+id+'"]'); 51 if (! $handle.length) { 52 return warn("Can't find review tab "+id); 53 } 54 $handle.click(); 55 }; 56 57 var doScroll = function() { 58 var $elem = $("#idTabRevws"); 59 if (! $elem.length) { 60 $elem = $(".revws-review-list"); 61 } 62 if ($elem.length) { 63 var top = $elem.offset().top; 64 $('html, body').animate({ scrollTop: top - 80 }, 500); 65 } 66 } 67 68 var scrollToReviews = function() { 69 if (displayedInTab()) { 70 openTab(); 71 setTimeout(doScroll, 150); 72 } else { 73 doScroll(); 74 } 75 } 76 77 var s = window.location.search || ''; 78 if (s.indexOf('show=reviews') > -1) { 79 scrollToReviews(); 80 } 81 $('a[href="#idTabRevws"]').click(function(e) { 82 e.preventDefault(); 83 scrollToReviews(); 84 }); 85 $('[data-revws-create-trigger]').click(function(e) { 86 e.preventDefault(); 87 var entityId = parseInt($(this).data('revws-create-trigger'), 10); 88 var entityType = $(this).data('revws-entity-type') || 'product' 89 window.revws({ 90 type: 'TRIGGER_CREATE_REVIEW', 91 entityType: entityType, 92 entityId: entityId 93 }) 94 }); 95})();
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.