1/** 2 * Owl Carousel Randomizer 3 * nowprocket 4 * 5 * ТаÑÑÐµÑ ÑÐ»Ð°Ð¹Ð´Ñ Ð´Ð¾ иниÑиализаÑии Owl, ÑÑÐ¾Ð±Ñ WP Rocket (кÑÑ HTML) не ÑикÑиÑовал поÑÑдок. 6 */ 7(function () { 8 'use strict'; 9 10 var ATTR = 'data-owl-randomized'; 11 var SELECTOR = '.owl-carousel'; 12 13 function collectItems(el) { 14 var items = []; 15 var named = []; 16 var kids = el.children; 17 var i; 18 var child; 19 var tag; 20 var cls; 21 22 for (i = 0; i < kids.length; i++) { 23 child = kids[i]; 24 if (!child || child.nodeType !== 1) { 25 continue; 26 } 27 28 tag = child.tagName; 29 if (tag === 'SCRIPT' || tag === 'STYLE' || tag === 'LINK') { 30 continue; 31 } 32 33 cls = child.classList; 34 if ( 35 cls.contains('owl-nav') || 36 cls.contains('owl-dots') || 37 cls.contains('owl-stage-outer') || 38 cls.contains('cloned') 39 ) { 40 continue; 41 } 42 43 items.push(child); 44 if (cls.contains('item')) { 45 named.push(child); 46 } 47 } 48 49 return named.length ? named : items; 50 } 51 52 function shuffleArray(arr) { 53 var i; 54 var j; 55 var tmp; 56 57 for (i = arr.length - 1; i > 0; i--) { 58 j = Math.floor(Math.random() * (i + 1)); 59 tmp = arr[i]; 60 arr[i] = arr[j]; 61 arr[j] = tmp; 62 } 63 64 return arr; 65 } 66 67 function shuffleEl(el) { 68 if (!el || el.getAttribute(ATTR) === '1') { 69 return; 70 } 71 72 if (el.classList.contains('owl-no-random')) { 73 el.setAttribute(ATTR, '1'); 74 return; 75 } 76 77 if (el.classList.contains('owl-loaded')) { 78 return; 79 } 80 81 var items = collectItems(el); 82 if (items.length < 2) { 83 el.setAttribute(ATTR, '1'); 84 return; 85 } 86 87 shuffleArray(items); 88 89 var i; 90 for (i = 0; i < items.length; i++) { 91 el.appendChild(items[i]); 92 } 93 94 el.setAttribute(ATTR, '1'); 95 } 96 97 function shuffleAll() { 98 var list = document.querySelectorAll(SELECTOR); 99 var i; 100 101 for (i = 0; i < list.length; i++) { 102 shuffleEl(list[i]); 103 } 104 } 105 106 function wrapOwlCarousel(fn) { 107 if (!fn || fn._owlRandomizer) { 108 return fn; 109 } 110 111 function wrapped(option) { 112 var isInit = option == null || (typeof option === 'object' && !Array.isArray(option)); 113 114 if (isInit && this && typeof this.each === 'function') { 115 this.each(function () { 116 shuffleEl(this); 117 }); 118 } 119 120 return fn.apply(this, arguments); 121 } 122 123 wrapped._owlRandomizer = true; 124 return wrapped; 125 } 126 127 function hookJQuery() { 128 var $ = window.jQuery || window.$; 129 130 if (!$ || !$.fn) { 131 return false; 132 } 133 134 if ($.fn._owlRandomizerHooked) { 135 return true; 136 } 137 138 $.fn._owlRandomizerHooked = true; 139 140 try { 141 var current = $.fn.owlCarousel; 142 143 Object.defineProperty($.fn, 'owlCarousel', { 144 configurable: true, 145 enumerable: true, 146 get: function () { 147 return current; 148 }, 149 set: function (fn) { 150 current = wrapOwlCarousel(fn); 151 } 152 }); 153 154 if (typeof current === 'function') { 155 current = wrapOwlCarousel(current); 156 } 157 } catch (e) { 158 if (typeof $.fn.owlCarousel === 'function') { 159 $.fn.owlCarousel = wrapOwlCarousel($.fn.owlCarousel); 160 } 161 } 162 163 return true; 164 } 165 166 function startHookPolling() { 167 if (hookJQuery()) { 168 return; 169 } 170 171 var tries = 0; 172 var timer = setInterval(function () { 173 tries += 1; 174 if (hookJQuery() || tries > 2000) { 175 clearInterval(timer); 176 } 177 }, 10); 178 } 179 180 startHookPolling(); 181 182 if (document.readyState === 'loading') { 183 document.addEventListener('DOMContentLoaded', shuffleAll, true); 184 } else { 185 shuffleAll(); 186 } 187})();
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.