1(function () { 2 var $ = jQuery; 3 var UPDATE_DOM_TIMEOUT = 700; 4 5 /** 6 * Get all ad units codes from page 7 * @returns array ad units codes 8 */ 9 function getAllAdDivId() { 10 var adUnitIdCodes = []; 11 if (typeof smConfig.adUnits === 'object' && typeof smConfig.adUnits.forEach === 'function') { 12 smConfig.adUnits.forEach(function (adUnit) { 13 adUnitIdCodes.push(adUnit.code); 14 }); 15 } 16 return adUnitIdCodes; 17 } 18 19 /** 20 * Get Id's for ad units block which we will update at the mobile layout 21 * @returns adUnitsBlock configuration 22 */ 23 function getAdUnitsForMobileLayout() { 24 var adUnitCodes = getAllAdDivId(); 25 var adUnitsBlocks = { 26 top: { 27 search: 'mob-top' 28 }, 29 mid: { 30 search: 'mob-mid' 31 }, 32 bot: { 33 search: 'mob-bot' 34 } 35 }; 36 var blocks = ['top', 'mid', 'bot']; 37 38 adUnitCodes.forEach(function (adUnit) { 39 blocks.forEach(function (block) { 40 if (adUnit.indexOf(adUnitsBlocks[block]['search']) > 0) { 41 adUnitsBlocks[block]['id'] = adUnit; 42 } 43 }) 44 }) 45 46 return adUnitsBlocks; 47 } 48 49 function getCookie(name) { 50 var matches = document.cookie.match(new RegExp( 51 "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)" 52 )); 53 return matches ? decodeURIComponent(matches[1]) : undefined; 54 } 55 56 function isNumeric(value) { 57 return /^-?\d+$/.test(value); 58 } 59 60 function isFirstPage() { 61 var lastPartOfPathname = window.location.pathname.split('/').pop(); 62 return !isNumeric(lastPartOfPathname); 63 } 64 65 function initMobilePageStructure() { 66 if (('.wp-pagenavi').length === 0) { 67 console.log('! Not inited ML') 68 return false; 69 } else { 70 console.log('! Inited ML') 71 } 72 73 var imageHtml = ''; 74 var captionImgWrapHtml = ''; 75 var pageNaviBlock = ''; 76 var pageNaviButtons = ''; 77 78 var adUnitsBlocks = getAdUnitsForMobileLayout(); 79 console.log(adUnitsBlocks) 80 if (isFirstPage()) { 81 if ($('.entry-content .wp-caption').length > 0) { 82 // Move picture 83 imageHtml = $('.entry-content .wp-caption').html(); 84 captionImgWrapHtml = `<div id="attachment_0000" class="wp-caption aligncenter">${imageHtml}</div> `; 85 $('.entry-content .wp-caption').remove(); 86 $('.entry-content').before(captionImgWrapHtml); 87 88 // Copy next button 89 pageNaviButtons = $('.wp-pagenavi').html(); 90 console.log(pageNaviButtons); 91 if (typeof pageNaviButtons === 'undefined') { 92 setTimeout(function() { 93 pageNaviButtons = $('.wp-pagenavi').html(); 94 pageNaviBlock = `<div class="wp-pagenavi">${pageNaviButtons}</div>`; 95 console.log(pageNaviBlock) 96 $('.wp-caption').after(pageNaviBlock); 97 }, UPDATE_DOM_TIMEOUT); 98 } else { 99 pageNaviButtons = $('.wp-pagenavi').html(); 100 pageNaviBlock = `<div class="wp-pagenavi">${pageNaviButtons}</div>`; 101 console.log(pageNaviBlock) 102 $('.wp-caption').after(pageNaviBlock); 103 } 104 105 // Remove other blocks 106 $('.top-mpu-mobile').parent().remove(); 107 $('.related-posts').remove(); 108 $('.ad2').remove(); 109 console.log('STRUCTURE: First page') 110 } 111 } else { 112 if ($('.entry-content .wp-caption').length > 0) { 113 // Move picture 114 imageHtml = $('.entry-content .wp-caption').html(); 115 captionImgWrapHtml = `<div id="attachment_0000" class="wp-caption aligncenter">${imageHtml}</div> `; 116 $('.entry-content .wp-caption').remove(); 117 $('.entry-content h1, .entry-content h2, .entry-content h3').after(captionImgWrapHtml); 118 119 // Copy next button 120 console.log('PAGE NAVI'); 121 pageNaviButtons = $('.wp-pagenavi').html(); 122 console.log(pageNaviButtons); 123 if (typeof pageNaviButtons === 'undefined') { 124 setTimeout(function() { 125 pageNaviButtons = $('.wp-pagenavi').html(); 126 pageNaviBlock = `<div class="wp-pagenavi">${pageNaviButtons}</div>`; 127 console.log('Again page navi: ' + pageNaviButtons); 128 $('.wp-caption').after(pageNaviBlock); 129 $('.wp-pagenavi').css({'padding-bottom': '70px'}); 130 }, UPDATE_DOM_TIMEOUT); 131 } else { 132 pageNaviBlock = `<div class="wp-pagenavi">${pageNaviButtons}</div>`; 133 $('.wp-caption').after(pageNaviBlock); 134 $('.wp-pagenavi').css({'padding-bottom': '70px'}); 135 } 136 137 // Remove other blocks 138 $('.related-posts').remove(); 139 140 // First ad unit (Top ad unit [top-ad-new shortcode]) 141 if (jQuery('.top-mpu-mobile').parent().parent().find('.ad2:eq(0)').length > 0) { 142 var topAdContent = $('.top-mpu-mobile').parent().parent().find('.ad2:eq(0)').html(); 143 $('.top-mpu-mobile').parent().parent().find('.ad2')[0].remove(); 144 var topAdBlock = `<div class="ad2">${topAdContent}</div>`; 145 //$('.wp-caption').after('TOP AD'); 146 $('.wp-caption').after(topAdBlock); 147 $('.top-mpu-mobile').parent().parent().find('.ad2').css('display', 'block'); 148 } else { 149 var topAdContent = $('#' + adUnitsBlocks.top.id).parent().html(); 150 var topAdBlock = `<div class="ad2">${topAdContent}</div>`; 151 $('#' + adUnitsBlocks.top.id).parent().remove(); 152 $('.wp-caption').after(topAdBlock); 153 } 154 console.log("!!!"); 155 //console.log(topAdBlock) 156 157 // Second ad unit (Mid ad unit [bottom-ad shortcode]) 158 if ($('.top-mpu-mobile').parent().parent().find('.ad2:eq(1)').length > 0) { 159 var midAdContent = $('.top-mpu-mobile').parent().parent().find('.ad2:eq(1)').html(); 160 $('.top-mpu-mobile').parent().parent().find('.ad2')[1].remove(); 161 var midAdBlock = `<div class="ad2">${midAdContent}</div>`; 162 //$('.wp-pagenavi')[1].after('MID AD'); 163 } else { 164 var midAdContent = $('#' + adUnitsBlocks.mid.id).parent().html(); 165 $('#' + adUnitsBlocks.mid.id).parent().remove(); 166 var midAdBlock = `<div class="ad2">${midAdContent}</div>`; 167 } 168 if ($('.wp-pagenavi:eq(1)').length > 0) { 169 $('.wp-pagenavi:eq(1)').after(midAdBlock); 170 $('.wp-pagenavi:eq(1)').css({'padding-bottom': '90px'}); 171 } else { 172 setTimeout(function() { 173 $('#sm-mr-bottom').before(midAdBlock); 174 $('#sm-mr-bottom').css({'padding-bottom': '90px'}); 175 }, UPDATE_DOM_TIMEOUT) 176 } 177 console.log("!!!"); 178 console.log($('#sm-mr-bottom').length); 179 180 // Remove bottom ad unit div block 181 if (typeof $('.top-mpu-mobile').parent().parent().find('.ad2')[2] === 'object' && typeof $('.top-mpu-mobile').parent().parent().find('.ad2')[2].remove === 'function') { 182 $('.top-mpu-mobile').parent().parent().find('.ad2')[2].remove(); 183 } else { 184 $('#' + adUnitsBlocks.bot.id).parent().remove(); 185 } 186 } 187 } 188 } 189 190 function initSecondPageStructure() { 191 if (wtTeraDevice === 'mobile') { 192 initMobilePageStructure(); 193 } 194 } 195 196 initSecondPageStructure(); 197 198 window.smInitSecondPageStructure = initSecondPageStructure; 199}());
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.