1(function($){ 2 3 let google_search = []; 4 google_search['key'] = ''; 5 google_search['results'] = []; 6 google_search['results'][1] = []; 7 google_search['results'][2] = []; 8 google_search['results'][3] = []; 9 google_search['results'][4] = []; 10 google_search['results'][5] = []; 11 google_search['results'][1]['list'] = []; 12 google_search['results'][2]['list'] = []; 13 google_search['results'][3]['list'] = []; 14 google_search['results'][4]['list'] = []; 15 google_search['results'][5]['list'] = []; 16 google_search['page'] = []; 17 google_search['page'][1] = 1; 18 google_search['page'][2] = 1; 19 google_search['page'][3] = 1; 20 google_search['page'][4] = 1; 21 google_search['page'][5] = 1; 22 23 let thumbnail_color = $('#lvivcenter-google-search').attr('data-thumbnail-color'); 24 25 //пеÑÐµÐºÐ»Ð°Ð´ÐµÐ½Ñ ÑÑÑÑÑки 26 let lang = $('html').attr('lang'); 27 let string_more = lang == 'uk' ? 'ÐведÑÑÑ Ð±ÑлÑÑе Ð´Ð»Ñ ÑезÑлÑÑаÑÑ' : 'Enter more for results'; 28 let string_enter_search = lang == 'uk' ? 'ÐведÑÑÑ Ñлова Ð´Ð»Ñ Ð¿Ð¾ÑÑкÑ' : 'Enter search words'; 29 let string_search_running = lang == 'uk' ? 'ÐоÑÑк ÑезÑлÑÑаÑÑв' : 'Searching is running'; 30 let string_no_results = lang == 'uk' ? 'ÐÑÑого не знайдено' : 'No results'; 31 32 if($('#lvivcenter-google-search').length > 0){ 33 //пеÑÐµÐºÐ»Ð°Ð´ÐµÐ½Ñ ÑÑÑÑÑки 34 let lang = $('html').attr('lang'); 35 let tab_1 = lang == 'uk' ? 'ЦенÑÑ' : 'The Center'; 36 let tab_2 = lang == 'uk' ? 'ÐнÑеÑакÑивний ÐÑвÑв' : 'Lviv Interactive'; 37 let tab_3 = lang == 'uk' ? 'ÐÑÑÑкий медÑааÑÑ Ñв' : 'Urban Media Archive'; 38 let tab_4 = lang == 'uk' ? 'ÐÑвÑÑÐ½Ñ Ð¿Ð»Ð°ÑÑоÑма' : 'Educational platform'; 39 let tab_5 = lang == 'uk' ? 'ÐÑблÑоÑека' : 'Library'; 40 41 let search_icon = '<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">'; 42 search_icon += '<ellipse cx="8.94444" cy="8.86842" rx="7.94444" ry="7.86842" stroke="#3E4244" stroke-width="2" stroke-linecap="square" fill="transparent"/>'; 43 search_icon += '<path d="M14.4443 15.5263L21.8011 22.8127" stroke="#3E4244" stroke-width="2" stroke-linecap="square"/>'; 44 search_icon += '</svg>'; 45 46 //ÑоÑма Ð´Ð»Ñ Ð²Ð²ÐµÐ´ÐµÐ½Ð½Ñ Ð·Ð°Ð¿Ð¸ÑÑ 47 let html = '<button id="lvivcenter-google-search-close" aria-label="Search close"><img src="https://www.lvivcenter.org/wp-content/themes/sitegist-theme/images/close.svg" alt="close icon"></button>'; 48 html += '<form id="lvivcenter-google-search-form" style="position:relative;">'; 49 html += '<div style="padding:11px 30px 11px 20px;border-bottom:2px solid #3E4244;background:transparent;overflow:hidden;display:flex;align-items:center;position:relative;">'; 50 html += '<input style="background:transparent;height:30px;width:100%;padding-right:25px;border:0;outline:0;font-size:16px;" name="lvivcenter-google-search" type="text" placeholder="' + string_enter_search + '">'; 51 html += '<button style="background:transparent;border:none;outline:none;margin-right:10px;cursor:pointer;">' + search_icon + '</button></div>'; 52 //html += '<div class="lvivcenter-google-search-loader"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>'; 53 html += '<div class="lvivcenter-google-search-loader-new lvivcenter-google-search-loader-new-form"><svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M22.5 4.74205C20.0217 3.31117 17.1404 2.73806 14.3031 3.11161C11.4659 3.48515 8.83113 4.78447 6.80757 6.80805C4.78402 8.83164 3.48473 11.4664 3.11122 14.3037C2.73771 17.1409 3.31086 20.0222 4.74177 22.5005C6.17268 24.9789 8.38139 26.9158 11.0253 28.0109C13.6693 29.106 16.6007 29.2981 19.3649 28.5574C22.1291 27.8166 24.5717 26.1845 26.3138 23.9141C28.0559 21.6436 29.0001 18.8618 29 16.0001" stroke="#3E4244" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div>'; 54 html += '</form>'; 55 56 //Ñаби 57 html += '<div class="lvivcenter-google-search-tabs-wrapper" style="display:flex;width:100%;overflow-x:auto;padding-bottom:5px;margin-bottom:15px;">'; 58 html += '<div class="lvivcenter-google-search-tabs" style="display:flex;justify-content:space-between;padding:20px 0 0;width:920px;">'; 59 html += '<div class="lvivcenter-google-search-tab-item active" data-site="1">' + tab_1 + '<span style="margin-left:5px;"></span></div>'; 60 html += '<div class="lvivcenter-google-search-tab-item" data-site="2">' + tab_2 + '<span style="margin-left:5px;"></span></div>'; 61 html += '<div class="lvivcenter-google-search-tab-item" data-site="3">' + tab_3 + '<span style="margin-left:5px;"></span></div>'; 62 html += '<div class="lvivcenter-google-search-tab-item" data-site="4">' + tab_4 + '<span style="margin-left:5px;"></span></div>'; 63 html += '<div class="lvivcenter-google-search-tab-item" data-site="5">' + tab_5 + '<span style="margin-left:5px;"></span></div>'; 64 html += '</div>'; 65 html += '</div>'; 66 67 //кнопки ÑÐ¸Ð¿Ñ Ð¿ÐµÑеглÑÐ´Ñ 68 html += '<div class="lvivcenter-google-search-views" style="display:flex;width:100%;justify-content:flex-end;">'; 69 html += '<div class="lvivcenter-google-search-views-item active" data-type="list"><svg width="26" height="26" viewBox="0 0 26 26" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M23.1562 13C23.1562 13.3232 23.0278 13.6332 22.7993 13.8618C22.5707 14.0903 22.2607 14.2188 21.9375 14.2188H4.0625C3.73927 14.2188 3.42927 14.0903 3.20071 13.8618C2.97215 13.6332 2.84375 13.3232 2.84375 13C2.84375 12.6768 2.97215 12.3668 3.20071 12.1382C3.42927 11.9097 3.73927 11.7812 4.0625 11.7812H21.9375C22.2607 11.7812 22.5707 11.9097 22.7993 12.1382C23.0278 12.3668 23.1562 12.6768 23.1562 13ZM4.0625 7.71875H21.9375C22.2607 7.71875 22.5707 7.59035 22.7993 7.36179C23.0278 7.13323 23.1562 6.82323 23.1562 6.5C23.1562 6.17677 23.0278 5.86677 22.7993 5.63821C22.5707 5.40965 22.2607 5.28125 21.9375 5.28125H4.0625C3.73927 5.28125 3.42927 5.40965 3.20071 5.63821C2.97215 5.86677 2.84375 6.17677 2.84375 6.5C2.84375 6.82323 2.97215 7.13323 3.20071 7.36179C3.42927 7.59035 3.73927 7.71875 4.0625 7.71875ZM21.9375 18.2812H4.0625C3.73927 18.2812 3.42927 18.4097 3.20071 18.6382C2.97215 18.8668 2.84375 19.1768 2.84375 19.5C2.84375 19.8232 2.97215 20.1332 3.20071 20.3618C3.42927 20.5903 3.73927 20.7188 4.0625 20.7188H21.9375C22.2607 20.7188 22.5707 20.5903 22.7993 20.3618C23.0278 20.1332 23.1562 19.8232 23.1562 19.5C23.1562 19.1768 23.0278 18.8668 22.7993 18.6382C22.5707 18.4097 22.2607 18.2812 21.9375 18.2812Z" fill="#939293"/></svg></div>'; 70 html += '<div class="lvivcenter-google-search-views-item" data-type="grid"><svg width="24" height="23" viewBox="0 0 24 23" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 10.5417V2.875H11V10.5417H3ZM3 20.125V12.4583H11V20.125H3ZM13 10.5417V2.875H21V10.5417H13ZM13 20.125V12.4583H21V20.125H13Z" fill="#939293"/></svg></div>'; 71 html += '</div>'; 72 73 //мÑÑÑе, Ð´Ð»Ñ Ð²Ð¸Ð²ÐµÐ´ÐµÐ½Ð½Ñ ÑезÑлÑÑаÑÑв 74 html += '<div id="lvivcenter-google-search-results" style="max-height:50vh;overflow-y:auto;margin:15px 0;"></div>'; 75 html += '<div id="lvivcenter-google-search-results-last"></div>'; 76 html += '</div>'; 77 html += '<div class="lvivcenter-google-search-loader-new lvivcenter-google-search-loader-new-bottom"><svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M22.5 4.74205C20.0217 3.31117 17.1404 2.73806 14.3031 3.11161C11.4659 3.48515 8.83113 4.78447 6.80757 6.80805C4.78402 8.83164 3.48473 11.4664 3.11122
7714.3037C2.73771 17.1409 3.31086 20.0222 4.74177 22.5005C6.17268 24.9789 8.38139 26.9158 11.0253 28.0109C13.6693 29.106 16.6007 29.2981 19.3649 28.5574C22.1291 27.8166 24.5717 26.1845 26.3138 23.9141C28.0559 21.6436 29.0001 18.8618 29 16.0001" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg></div>'; 78 //html += '<div class="lvivcenter-google-search-loader lvivcenter-google-search-loader-bottom"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>'; 79 80 81 //ÑÑилÑ, ÑÐºÑ Ð½Ðµ пÑопиÑÐ°Ð½Ñ inline 82 html += '<style>'; 83 html += '#lvivcenter-google-search-close{padding:0;margin:0;width:30px;height:30px;position:absolute;right:0;top:-80px;background:transparent!important;cursor:pointer;border:none!important;outline:none!important;}'; 84 html += '.lvivcenter-google-search-tabs-wrapper::-webkit-scrollbar{width:2px;}'; 85 html += '.lvivcenter-google-search-tabs-wrapper::-webkit-scrollbar-thumb{border-radius:2px;background:#3E4244;}'; 86 html += '.quick-srch{background-color:rgba(255, 255, 255, 0.95)!important;}'; 87 html += '.quick-srch:before{content:"";position:fixed;background:#F4D1A8;top:0;left:0;right:0;width:100%;display:flex;height:70px;pointer-events:none;}'; 88 html += '#lvivcenter-google-search{position:relative;}'; 89 html += '.lvivcenter-google-search-loader.lvivcenter-google-search-loader-bottom{bottom:-50px;top:auto;right:calc(50% - 30px);}'; 90 html += '.lvivcenter-google-search-loader.lvivcenter-google-search-loader-bottom.active{opacity:1;}'; 91 html += '.lvivcenter-google-search-tab-item.active{background:#F4D1A8;border-color:#F4D1A8;}'; 92 html += '.lvivcenter-google-search-tab-item{font-size:15px;min-width:calc(20% - 5px);margin-bottom:-3px;line-height:14px;height:48px;display:flex;align-items:center;text-align:center;justify-content:center;padding:10px 35px 10px;cursor:pointer;flex-wrap:wrap;border:1px solid #3E4244;font-weight:600;}'; 93 html += '#lvivcenter-google-search-results::-webkit-scrollbar{width:5px;}'; 94 html += '#lvivcenter-google-search-results::-webkit-scrollbar-track{box-shadow: none;}'; 95 html += '#lvivcenter-google-search-results::-webkit-scrollbar-thumb{background:#3E4244;}'; 96 html += '#lvivcenter-google-search-results a strong,.lvivcenter-google-search-results-item-link{transition:all .3s;}'; 97 html += '#lvivcenter-google-search-results a:hover strong,.lvivcenter-google-search-results-item-link:hover{color:#000;}'; 98 html += '.lvivcenter-google-search-results-item-link:hover{font-weight:600;}'; 99 html += '#lvivcenter-google-search-form.active .lvivcenter-google-search-loader{opacity:1;}'; 100 html += '#lvivcenter-google-search-form.active .lvivcenter-google-search-loader-new-form{opacity:1;}'; 101 html += '.lvivcenter-google-search-loader{display:inline-block;position:absolute;width:60px;height:60px;transform:scale(0.4);right:-24px;top:-8px;opacity:0;}'; 102 html += '.lvivcenter-google-search-loader div{position:absolute;width:6px;height:6px;background:#4C5051;border-radius:50%;animation:lvivcenter-google-search-loader-animation 1.2s linear infinite;}'; 103 html += '.lvivcenter-google-search-loader div:nth-child(1){animation-delay:0s;top:37px;left:66px;}'; 104 html += '.lvivcenter-google-search-loader div:nth-child(2){animation-delay:-0.1s;top:22px;left:62px;}'; 105 html += '.lvivcenter-google-search-loader div:nth-child(3){animation-delay:-0.2s;top:11px;left:52px;}'; 106 html += '.lvivcenter-google-search-loader div:nth-child(4){animation-delay:-0.3s;top:7px;left:37px;}'; 107 html += '.lvivcenter-google-search-loader div:nth-child(5){animation-delay:-0.4s;top:11px;left:22px;}'; 108 html += '.lvivcenter-google-search-loader div:nth-child(6){animation-delay:-0.5s;top:22px;left:11px;}'; 109 html += '.lvivcenter-google-search-loader div:nth-child(7){animation-delay:-0.6s;top:37px;left:7px;}'; 110 html += '.lvivcenter-google-search-loader div:nth-child(8){animation-delay:-0.7s;top:52px;left:11px;}'; 111 html += '.lvivcenter-google-search-loader div:nth-child(9){animation-delay:-0.8s;top:62px;left:22px;}'; 112 html += '.lvivcenter-google-search-loader div:nth-child(10){animation-delay:-0.9s;top:66px;left:37px;}'; 113 html += '.lvivcenter-google-search-loader div:nth-child(11){animation-delay:-1s;top:62px;left:52px;}'; 114 html += '.lvivcenter-google-search-loader div:nth-child(12){animation-delay:-1.1s;top:52px;left:62px;}'; 115 html += '#lvivcenter-google-search.active #lvivcenter-google-search-results{opacity:.6;}'; 116 html += '.lvivcenter-google-search-loader-new{opacity:0;width:32px;height:32px;animation:lvivcenter-google-search-loader-animation-round 1s linear infinite;}'; 117 html += '.lvivcenter-google-search-loader-new.lvivcenter-google-search-loader-new-bottom{display:block;margin:auto;}'; 118 html += '.lvivcenter-google-search-loader-new.lvivcenter-google-search-loader-new-bottom.active{opacity:1;}'; 119 html += '.lvivcenter-google-search-loader-new svg path{f
119ill:transparent;}'; 120 html += '.lvivcenter-google-search-loader-new-form{position:absolute;right:0;top:10px;display:flex;align-items:center;justify-content:center;}'; 121 html += '.lvivcenter-google-search-loader-new-form svg{width:27px;}'; 122 html += '@keyframes lvivcenter-google-search-loader-animation{0%,20%,80%,100%{transform:scale(1);}50%{transform:scale(1.5);}}'; 123 html += '@keyframes lvivcenter-google-search-loader-animation-round{0%{transform:rotate(360deg);}}'; 124 html += '.lvivcenter-google-search-views-item{margin-left:8px;display:flex;align-items:center;justify-content:center;cursor:pointer;}'; 125 html += '.lvivcenter-google-search-views-item svg{width:25px;height:25px;}'; 126 html += '.lvivcenter-google-search-views-item.active svg path{fill:#3e4244;}'; 127 html += '#lvivcenter-google-search-results.result-grid{display:flex;flex-wrap:wrap;width:100%;}'; 128 html += '#lvivcenter-google-search-results.result-grid a{width:33%!important;}'; 129 html += '#lvivcenter-google-search-results.result-grid a img{width:100%!important;height:175px!important;}'; 130 html += '#lvivcenter-google-search-results.result-grid a div{width:100%!important;padding-left:0!important;}'; 131 html += '#lvivcenter-google-search-results.result-grid .lvivcenter-serach-image-wrapper{margin-bottom:15px;height:175px!important;}'; 132 html += '@media(max-width: 996px){'; 133 html += ' .lvivcenter-google-search-tab-item{margin-right:5px;white-space:nowrap;padding-right:10px!important;padding-left:10px!important;}'; 134 html += ' .lvivcenter-google-search-tab-item{min-width:calc(40% - 5px);}'; 135 html += '}'; 136 html += '@media(max-width: 768px){'; 137 html += ' .lvivcenter-google-search-tab-item{min-width:calc(60% - 5px);}'; 138 html += ' #lvivcenter-google-search-close{top:-50px;}'; 139 html += ' #lvivcenter-google-search-results.result-grid a{width:100%!important;}'; 140 html += ' #lvivcenter-google-search-results a img,#lvivcenter-google-search-results .lvivcenter-serach-image-wrapper{display:none;}'; 141 html += ' #lvivcenter-google-search-results a div{width:100%!important;}'; 142 //html += ' .lvivcenter-google-search-tabs{flex-wrap:wrap;justify-content:center!important;}'; 143 144 html += ' .lvivcenter-google-search-tab-item{justify-content:center;text-align:center;padding-left:20px;padding-right:20px;margin-bottom:5px;}'; 145 html += '}'; 146 html += '</style>'; 147 148 $('#lvivcenter-google-search').html(html); 149 150 lvivcenter_search_tab_item_width_regenerate(); 151 152 let lvivcenter_google_search_view_cookie = lvivcenter_google_search_get_cookie('lvivcenter-google-search-view'); 153 if(lvivcenter_google_search_view_cookie != undefined && lvivcenter_google_search_view_cookie.length > 0){ 154 $('#lvivcenter-google-search-results').addClass('result-' + lvivcenter_google_search_view_cookie); 155 $('.lvivcenter-google-search-views-item').removeClass('active'); 156 $('.lvivcenter-google-search-views-item[data-type="' + lvivcenter_google_search_view_cookie + '"]').addClass('active'); 157 } 158 } 159 160 function lvivcenter_search_tab_item_width_regenerate(){ 161 let lvivcenter_search_tab_item = $('.lvivcenter-google-search-tab-item'); 162 if(lvivcenter_search_tab_item.length > 0){ 163 lvivcenter_search_tab_item.each(function(){ 164 console.log($(this).width()); 165 $(this).css('width', $(this).width() + 60); 166 $(this).css('padding', '10px 0'); 167 }); 168 } 169 } 170 171 let lvivcenter_google_search_timer; 172 let lvivcenter_google_search_timer_interval = 300; 173 // $('[name=lvivcenter-google-search]').on('keyup paste', function(){ 174 // //ÑкÑо лÑдина пÑодовжÑÑ Ð½Ð°Ð±Ð¸ÑаÑи, Ñо не запÑÑкаÑи поÑÑк 175 // clearTimeout(lvivcenter_google_search_timer); 176 // $('.lvivcenter-google-search-loader-bottom').removeClass('active'); 177 // 178 // let results_wrapper = $('#lvivcenter-google-search-results'); 179 // let value = $(this).val().toLowerCase(); 180 // let active = $('.lvivcenter-google-search-tab-item.active').attr('data-site'); 181 // 182 // if(value.length > 1){ 183 // lvivcenter_google_search_timer = setTimeout(function(){ 184 // $('#lvivcenter-google-search').addClass('active'); 185 // $('#lvivcenter-google-search-form').addClass('active'); 186 // lvivcenter_google_search_run(value, active, lang); 187 // }, lvivcenter_google_search_timer_interval); 188 // }else{ 189 // $('#lvivcenter-google-search').removeClass('active'); 190 // $('#lvivcenter-google-search-form').removeClass('active'); 191 // results_wrapper.html('<div style="font-size:18px;text-align:center;font-weight:600;padding:10px 0;">' + string_more + '</div>'); 192 // } 193 // }); 194 195 196 $('#lvivcenter-google-search-close').on('click', function(e){
197 e.preventDefault(); 198 $('body').removeClass('quick-srch-opened'); 199 }); 200 201 $('.lvivcenter-google-search-views-item').on('click', function(e){ 202 let view = $(this).attr('data-type'); 203 $('#lvivcenter-google-search-results').removeClass('result-list'); 204 $('#lvivcenter-google-search-results').removeClass('result-grid'); 205 $('#lvivcenter-google-search-results').addClass('result-' + view); 206 $('.lvivcenter-google-search-views-item').removeClass('active'); 207 $('.lvivcenter-google-search-views-item[data-type="' + view + '"]').addClass('active'); 208 lvivcenter_google_search_set_cookie('lvivcenter-google-search-view', view, 30); 209 }); 210 211 $('#lvivcenter-google-search-form').on('submit', function(e){ 212 e.preventDefault(); 213 $('.lvivcenter-google-search-loader-bottom').removeClass('active'); 214 $('.lvivcenter-google-search-loader-new-bottom').removeClass('active'); 215 $('#lvivcenter-google-search').addClass('active'); 216 $('#lvivcenter-google-search-form').addClass('active'); 217 clearTimeout(lvivcenter_google_search_timer); 218 219 for(let i = 0; i <= google_search['page'].length; i++){ 220 if(google_search['page'][i] !== undefined){ 221 google_search['page'][i] = 1; 222 } 223 } 224 225 let results_wrapper = $('#lvivcenter-google-search-results'); 226 let value = $('#lvivcenter-google-search-form [name=lvivcenter-google-search]').val().toLowerCase(); 227 let active = $('.lvivcenter-google-search-tab-item.active').attr('data-site'); 228 229 if(value != google_search['key']){ 230 if(value.length > 1){ 231 lvivcenter_google_search_timer = setTimeout(function(){ 232 lvivcenter_google_search_run(value, active, lang, true); 233 }, 500); 234 }else{ 235 lvivcenter_google_search_clear_results(); 236 google_search['key'] = value; 237 $('#lvivcenter-google-search').removeClass('active'); 238 $('#lvivcenter-google-search-form').removeClass('active'); 239 results_wrapper.html('<div style="font-size:18px;text-align:center;font-weight:600;padding:10px 0;width:100%;">' + string_more + '</div>'); 240 } 241 }else{ 242 $('#lvivcenter-google-search').removeClass('active'); 243 $('#lvivcenter-google-search-form').removeClass('active'); 244 } 245 }); 246 247 //обÑоÑка дованÑÐ°Ð¶ÐµÐ½Ð½Ñ Ð¿Ñи ÑкÑÐ¾Ð»Ñ 248 let lvivcenter_google_search_timer_scroll; 249 let lvivcenter_google_search_timer_scroll_interval = 300; 250 $('#lvivcenter-google-search-results').scroll(function(e){ 251 e.preventDefault(); 252 let results_wrapper = $('#lvivcenter-google-search-results'); 253 let active = $('.lvivcenter-google-search-tab-item.active').attr('data-site'); 254 let height = document.getElementById('lvivcenter-google-search-results').scrollHeight; 255 let height_minus = $(this).height() + 100; 256 let scroll = $(this).scrollTop(); 257 if(scroll > height - height_minus){ 258 if(lvivcenter_google_search_check_page(active)){ 259 $('.lvivcenter-google-search-loader-bottom').addClass('active'); 260 $('.lvivcenter-google-search-loader-new-bottom').addClass('active'); 261 clearTimeout(lvivcenter_google_search_timer_scroll); 262 lvivcenter_google_search_timer_scroll = setTimeout(function(){ 263 $('#lvivcenter-google-search-form').addClass('active'); 264 let value = $('[name=lvivcenter-google-search]').val().toLowerCase(); 265 let active = $('.lvivcenter-google-search-tab-item.active').attr('data-site'); 266 google_search['page'][active]++; 267 //lvivcenter_google_search_run(value, active, lang); 268 let data = { 269 action: 'lvivcenter_google_search_run_one', 270 site: $('.lvivcenter-google-search-tab-item.active').attr('data-site'), 271 value: value, 272 page: google_search['page'][active], 273 lang: lang 274 }; 275 jQuery.post('https://www.lvivcenter.org/wp-admin/admin-ajax.php', data, function(response){ 276 if(response.length > 0){ 277 let data = JSON.parse(response); 278 279 //ÑкÑо Ñлово не збÑгаÑÑÑÑÑ Ñз попеÑеднÑо внеÑеним, ÑÐ¾Ð´Ñ Ð¿Ð¾ÑаÑи маÑив з нÑÐ»Ñ 280 // if(google_search['key'] != value){ 281 // google_search['results'][active]['list'] = []; 282 // google_search['key'] = value; 283 // } 284 285 //об'ÑкÑи поÑÑÑбно додаÑи до вже ÑÑнÑÑÑÐ¸Ñ 286 if(lv_undefined(data['list'])){ 287 console.log('SCROLL: push results ' + active); 288 for(let j = 0; j < data['list'].length; j++){ 289 google_search['results'][active]['list'].push(data['list'][j]); 290 } 291 } 292 293 console.log('SCROLL: run results ' + active); 294 if(google_search['results'][active]['list'].length > 0) { 295 let html = lvivcenter_google_search_html_list(google_search['results'][active]['list']); 296 results_wrapper.html(html); 297 console.log('SCROLL: put results'); 298 } 299 console.log(google_search); 300 } 301 }); 302 }, lvivcenter_google_search_timer_scroll_interval); 303 } 304 //$('.lvivcenter-google-search-loader-bottom').removeClass('active'); 305 setTimeout(function(){ 306 $('#lvivcenter-google-search-form').removeClass('active'); 307 $('.lvivcenter-google-search-loader-bottom').removeClass('active'); 308 $('.lvivcenter-google-search-loader-new-bottom').removeClass('active'); 309 }, 5000); 310 } 311 });
312 313 function lvivcenter_google_search_check_page(site){ 314 if(lv_undefined(google_search['results'][site]) && lv_undefined(google_search['results'][site]['count'])){ 315 if(lv_undefined(google_search['page'][site])){ 316 if(google_search['page'][site] * 10 < google_search['results'][site]['count']){ 317 return true; 318 } 319 } 320 } 321 return false; 322 } 323 324 function lvivcenter_google_search_run(value, active = 1, lang = 'uk', scroll = false){ 325 //console.log(google_search); 326 let results_wrapper = $('#lvivcenter-google-search-results'); 327 let data = { 328 action: 'lvivcenter_google_search_run', 329 site: $('.lvivcenter-google-search-tab-item.active').attr('data-site'), 330 value: value, 331 page: google_search['page'][active], 332 lang: lang 333 }; 334 jQuery.post('https://www.lvivcenter.org/wp-admin/admin-ajax.php', data, function(response){ 335 if(response.length > 0){ 336 let data = JSON.parse(response); 337 //console.log(data); 338 339 //ÑкÑо Ñлово не збÑгаÑÑÑÑÑ Ñз попеÑеднÑо внеÑеним, ÑÐ¾Ð´Ñ Ð¿Ð¾ÑаÑи маÑив з нÑÐ»Ñ 340 if(google_search['key'] != value) { 341 lvivcenter_google_search_clear_results(); 342 google_search['key'] = value; 343 } 344 //змÑнна Ð´Ð»Ñ ÑоÑмÑÐ²Ð°Ð½Ð½Ñ ÑпиÑкÑв Ñз ÑезÑлÑÑаÑами 345 let body = ''; 346 for (let i = 1; i <= Object.keys(data).length; i++){ 347 //запиÑÑÐ²Ð°Ð½Ð½Ñ ÐºÑлÑкоÑÑÑ Ð·Ð½Ð°ÑÐµÐ½Ñ Ñ Ñаби 348 let tab = $('.lvivcenter-google-search-tab-item[data-site=' + i + ']'); 349 tab.find('span').text('(' + data[i]['count'] + ')'); 350 351 //Ð·Ð°Ð¿Ð¾Ð²Ð½ÐµÐ½Ð½Ñ Ð¼Ð°ÑÐ¸Ð²Ñ Ð· ÑезÑлÑÑаÑами 352 google_search['results'][i]['count'] = data[i]['count']; 353 //об'ÑкÑи поÑÑÑбно додаÑи до вже ÑÑнÑÑÑÐ¸Ñ 354 if (lv_undefined(data[i]['list'])) { 355 //console.log(i + ' => ' + data[i]['list'].length); 356 for (let j = 0; j < data[i]['list'].length; j++) { 357 google_search['results'][i]['list'].push(data[i]['list'][j]); 358 } 359 } 360 } 361 362 //Ð²Ð¸Ð²ÐµÐ´ÐµÐ½Ð½Ñ ÑезÑлÑÑаÑÑв Ñз глобалÑного маÑÐ¸Ð²Ñ 363 if(google_search['results'][active]['list'].length > 0){ 364 console.log('TAB: run results ' + active); 365 //google_search['page'][active]++; 366 let html = lvivcenter_google_search_html_list(google_search['results'][active]['list']); 367 results_wrapper.html(html); 368 }else{ 369 results_wrapper.html('<div style="font-size:18px;text-align:center;font-weight:600;padding:10px 0;width:100%;">' + string_no_results + '</div>'); 370 } 371 $('#lvivcenter-google-search').removeClass('active'); 372 $('#lvivcenter-google-search-form').removeClass('active'); 373 if(scroll){ 374 // 375 } 376 console.log(google_search); 377 } 378 }); 379 } 380 381 function lvivcenter_google_search_clear_results(){ 382 for(let i = 1; i <= 5; i++){ 383 google_search['results'][i]['list'] = []; 384 google_search['results'][i]['count'] = 0; 385 } 386 } 387 388 function lvivcenter_google_search_html_list(items){ 389 let html = ''; 390 for(let i = 0; i < items.length; i++){ 391 html += lvivcenter_google_search_html_list_item(items[i]); 392 } 393 return html; 394 } 395 396 function lvivcenter_google_search_html_list_item(item){ 397 if(item != undefined){ 398 let image = false; 399 if(lv_undefined(item['pagemap']) && lv_undefined(item['pagemap']['metatags']) && lv_undefined(item['pagemap']['metatags'][0]) && lv_undefined(item['pagemap']['metatags'][0]['og:image'])){ 400 image = item['pagemap']['metatags'][0]['og:image']; 401 }else{ 402 if(lv_undefined(item['pagemap']) && lv_undefined(item['pagemap']['cse_thumbnail']) && lv_undefined(item['pagemap']['cse_thumbnail'][0]) && lv_undefined(item['pagemap']['cse_thumbnail'][0]['src'])){ 403 image = item['pagemap']['cse_thumbnail'][0]['src']; 404 } 405 } 406 407 let html = '<a href="' + item['link'] + '" target="_blank" style="display:flex;width:100%;flex-wrap:wrap;color:#4C5051;margin:20px 0;padding-right:15px;overflow:hidden;">'; 408 if(image){ 409 html += '<div class="lvivcenter-serach-image-wrapper" style="background-color:'+thumbnail_color+';width:95px;height:95px;background-size:34px;background-position:center;background-repeat:no-repeat;background-image:url(https://www.lvivcenter.org/wp-content/uploads/2023/07/lvivcenter-logo.png);">';
410 html += '<img src="' + image + '" alt="" style="width:95px;height:95px;object-fit:cover;object-position:center;">'; 411 html += '</div>'; 412 }else { 413 html += '<div class="lvivcenter-serach-image-wrapper" style="background-color:'+thumbnail_color+';width:95px;height:95px;background-size:34px;background-position:center;background-repeat:no-repeat;background-image:url(https://www.lvivcenter.org/wp-content/uploads/2023/07/lvivcenter-logo.png);"></div>'; 414 } 415 html += '<div style="display:flex;width:calc(100% - 95px);flex-direction:column;padding-left:30px;">'; 416 if(lv_undefined(item['htmlTitle'])){ 417 html += '<strong style="font-size:18px;line-height:24px;font-weight:400;margin-bottom:5px;">' + item['htmlTitle'] + '</strong>'; 418 } 419 if(lv_undefined(item['htmlSnippet'])){ 420 html += '<span style="font-size:14px;line-height:20px;font-weight:400;margin-bottom:3px;">' + item['htmlSnippet'] + '</span>'; 421 } 422 html += '<span class="lvivcenter-google-search-results-item-link" style="font-size:12px;line-height:18px;font-weight:400;">' + item['link'] + '</span>'; 423 html += '</div>'; 424 html += '</a>'; 425 return html; 426 } 427 return ''; 428 } 429 430 function lv_undefined(item){ 431 return item != undefined && item != null; 432 } 433 434 $('.lvivcenter-google-search-tab-item').on('click', function(){ 435 $('.lvivcenter-google-search-loader-bottom').removeClass('active'); 436 $('.lvivcenter-google-search-loader-new-bottom').removeClass('active'); 437 $('#lvivcenter-google-search-form').removeClass('active'); 438 $('.lvivcenter-google-search-tab-item').removeClass('active'); 439 $(this).addClass('active'); 440 let site = $(this).attr('data-site'); 441 442 let results_wrapper = $('#lvivcenter-google-search-results'); 443 if(lv_undefined(google_search['results'][site]) && lv_undefined(google_search['results'][site]['list']) && google_search['results'][site]['list'].length > 0){ 444 console.log(google_search['results'][site]); 445 let html = lvivcenter_google_search_html_list(google_search['results'][site]['list']); 446 results_wrapper.html(html); 447 }else{ 448 results_wrapper.html('<div style="font-size:18px;text-align:center;font-weight:600;padding:10px 0;width:100%;">' + string_no_results + '</div>'); 449 } 450 }); 451 452})(jQuery); 453 454function lvivcenter_google_search_set_cookie(name,value,days){ 455 var expires = ""; 456 if (days) { 457 var date = new Date(); 458 date.setTime(date.getTime() + (days*24*60*60*1000)); 459 expires = "; expires=" + date.toUTCString(); 460 } 461 document.cookie = name + "=" + (value || "") + expires + "; path=/"; 462} 463function lvivcenter_google_search_get_cookie(name){ 464 var nameEQ = name + "="; 465 var ca = document.cookie.split(';'); 466 for(var i=0;i < ca.length;i++) { 467 var c = ca[i]; 468 while (c.charAt(0)==' ') c = c.substring(1,c.length); 469 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 470 } 471 return null; 472} 473function lvivcenter_google_search_delete_cookie(name){ 474 setCookie(name,'', -1) 475}
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.