PageSourceSearch

https://www.andro.gr/wp-content/themes/andro/js/custom.js?q=1790255109

js andro.gr collected 2026-09-24 19:40:58 UTC 16,213 bytes, 537 lines download raw bytes

1var $ = jQuery.noConflict();
2
3window.twttr = (function(d, s, id) {
4    var js, fjs = d.getElementsByTagName(s)[0],
5        t = window.twttr || {};
6    if (d.getElementById(id)) return t;
7    js = d.createElement(s);
8    js.id = id;
9    js.src = "https://platform.twitter.com/widgets.js";
10    fjs.parentNode.insertBefore(js, fjs);
11
12    t._e = [];
13    t.ready = function(f) {
14        t._e.push(f);
15    };
16
17    return t;
18}(document, "script", "twitter-wjs"));
19
20$(window).on('load', function() {
21    // get_live_images();
22});
23
24$(document).ready(function() {
25
26	// Simulation Click event for Infinite Scrolling in Categories
27	if ($("body").hasClass("category")) {
28
29		if (document.querySelector("#appendlink")){
30			const boxElement = document.querySelector("#appendlink");
31			let observer;
32			let options = {
33			  root: null,
34			  rootMargin: "0px",
35			  threshold: 1.0
36			};
37		  
38			observer = new IntersectionObserver(intersectionCallback, options);
39			observer.observe(boxElement);
40		
41			function intersectionCallback(entries) {
42				entries.forEach(entry => {
43				  if (entry.isIntersecting) {
44						boxElement.click();
45				  }
46				});
47			  }
48		}
49
50	}
51	// .Simulation Click event for Infinite Scrolling in Categories
52
53    var $related_posts_call = 0;
54
55    // Cookie bar
56    var $cookieModal = $('.pea_cook_wrapper');
57
58    if ($cookieModal.length) {
59
60        var $check = $('#pea_cook_btn');
61
62        if (Cookies.get('andro-cookies') == 'true') {
63            //console.log('true');
64            $cookieModal.hide();
65        } else {
66            $check.on('click', function() {
67                Cookies.set('andro-cookies', true, {
68                    expires: 1
69                });
70                $cookieModal.hide();
71            });
72        }
73    }
74    // Initialize all ads
75    // init_ads('all');
76
77    // get_live_images();
78    postViewsCount();
79
80    // Scroll in articles
81    var passMe = $("#passMe");
82    var $load_posts_parrent = $("#load-posts-parrent");
83
84    $(window).scroll($.throttle(800, function() {
85
86        var top_offset = $(window).scrollTop();
87        var the_bottom = $(document).height();
88
89        var scroll_trigger = top_offset + $(window).height() + 3100;
90
91
92
93        // When have ajax posts container
94        if ($load_posts_parrent.length) {
95
96            // When at bottom
97            if (scroll_trigger >= the_bottom) {
98
99                // console.log( 'scroll_trigger: ' + scroll_trigger );
100
101                var pending_container = $('.next-post-pending');
102                if (pending_container.length && !pending_container.hasClass('waiting')) {
103                    pending_container.addClass('waiting'); // Will remove after ajax
104                    // get_the_adjacent_post();
105                    // get_same_category_post();
106                    get_related_posts($related_posts_call);
107                    $related_posts_call++;
108                }
109            }
110
111            // ==========================================
112            // Rewriting URL in Ajax Get New Post
113            // ==========================================
114            // var $url_trigger = $('.the-single-post');
115            // if( $url_trigger.length ) {
116
117            //     $url_trigger.each( function(i) {
118
119            //         var $that = $(this);
120            //         var the_url = $that.data('url');
121            //         var the_id = $that.data('id');
122            //         var the_title = $that.data('title');
123
124            //         if( top_offset >= $that.offset().top && top_offset <= ( $that.offset().top + $that.height() ) ) {
125
126            //             if( ! $load_posts_parrent.hasClass( 'id_' + the_id ) ) {
127            //                 $load_posts_parrent.attr('class', 'id_' + the_id );
128            //                 change_history(the_id, the_url, the_title, $load_posts_parrent);
129            //             }
130
131            //         }
132            //     });
133
134            // }
135            // ==========================================
136
137        } // If can load more posts
138
139        // Bottom share popup
140        if (passMe.length) {
141            var topOfOthDiv = passMe.offset().top;
142            if ($(window).scrollTop() > topOfOthDiv - 200 & !$('#likeMe').hasClass('stayClose')) {
143                $("#likeMe").addClass('effect-open');
144            } else {
145                $("#likeMe").removeClass('effect-open');
146            }
147        }
148
149    })); // End scroll events
150
151    $('.closeMe').on('click', function() {
152        $("#likeMe").removeClass('effect-open').addClass('stayClose');
153    });
154    // .Scroll in articles
155
156    $('figure[style], .bg-left-box[style], .next-post-grid-image[style], .popular-image-bg[style]').each(function() {
157        var newSrc = $(this).attr('style');
158        newSrc = newSrc.replace('local.andro', 'www.andro');
159        $(this).attr('style', newSrc);
160    });
161
162    $('.carousel').carousel({
163        interval: 7000
164    });
165
166    $('.carousel').carousel('cycle');
167
168    $(".carousel").swiperight(function() {
169        $(".carousel").carousel('prev');
170    });
171    $(".carousel").swipeleft(function() {
172        $(".carousel").carousel('next');
173    });
174
175    $('nav > ul > li').hover(function() {
176            $(this).find('.sub,.sub-menu,.graybar').css('display', 'block');
177        },
178        function() {
179            $(this).find('.sub,.sub-menu,.graybar').css('display', 'none');
180        });
181
182    $('#post-slider').nivoSlider({
183        effect: 'fade',
184        pauseTime: 8000,
185        controlNavThumbs: false,
186        controlNav: false
187    });
188
189    create_black_hover_blocks();
190
191    $('#appendlink').click(function() {
192        setTimeout(function() {
193            create_black_hover_blocks();
194        }, 500);
195    });
196
197    $('.col_next').click(function() {
198        var items = $('.col_articles article').size();
199        if (items > 3 && parseInt($('.col_articles').css('top')) > (-(items - 3) * 164))
200            $('.col_articles').filter(':not(:animated)').animate({
201                top: '-=164'
202            });
203    });
204
205    $('.col_previous').click(function() {
206        var items = $('.col_articles article').size();
207        if (items > 3 && parseInt($('.col_articles').css('top')) < 0)
208            $('.col_articles').filter(':not(:animated)').animate({
209                top: '+=164'
210            });
211    });
212
213    $('.quadthemata .span3').hover(function() {
214        $(this).children('.img-caption').animate({
215            bottom: '+=165px'
216        });
217    }, function() {
218        $(this).children('.img-caption').animate({
219            bottom: '-=165px'
220        });
221    });
222
223    $('#most_view a').click(function(e) {
224        e.preventDefault();
225        $(this).tab('show');
226    });
227
228
229    if ($('body').width() > 768) {
230        
231        var $leaderboard = $('.leaderboard-container');
232        var headerHeight = 171;
233        var menuHeight = 46;
234        var stickyUntil = 770;
235
236        $(window).bind('scroll', function() {
237            var leaderboardHeight = $leaderboard.outerHeight();
238            var scrollTop = $(window).scrollTop();
239		
240            if (scrollTop > headerHeight) {
241                $('.navbar-inverse').css('position', 'fixed').css('top', -headerHeight).addClass('shadow-main');
242				$('body > .container').first().css('padding', '226px 20px 0');
243            } else {
244                $('.navbar-inverse').css('position', 'static').css('top', '0').removeClass('shadow-main');
245                $('body > .container').first().css('padding', '20px 20px 0');
246			}
247		
248			// Leaderboard
249			if (!($("body").hasClass("category-geusi") || $("body").hasClass("category-empneusi") || $("body").hasClass("single") || $("body").hasClass("home"))){
250				if (scrollTop > headerHeight && scrollTop < 450) {
251					
252					$('.category').css('padding-top', leaderboardHeight + headerHeight + menuHeight);
253					if ( leaderboardHeight > 41 /* Leaderboard container with paddings */ ) {
254						$('.leaderboard-container').css('position', 'fixed').css('top', menuHeight).css('left','50%').css('z-index','999').css('transform', 'translateX(-50%)');
255						if ( scrollTop > stickyUntil ) {
256							$('.leaderboard-container').css('position', 'absolute').css('top', menuHeight + stickyUntil);
257						}
258					}
259				} else {
260					$('.category').css('padding-top', 'unset');
261					$('.leaderboard-container').css('position', 'unset').css('top', 'unset').css('left','unset').css('z-index','unset').css('transform', 'unset');
262				}
263			}
264
265        });
266	}
267	
268	// Watch for Leaderboard change
269	// const targetNode = document.querySelector(".leaderboard-container");
270	// const observerOptions = {
271	// childList: true,
272	// attributes: true,
273	// // Omit (or set to false) to observe only changes to the parent node
274	// subtree: true 
275	// }
276	// const observer = new MutationObserver(callback);
277	// observer.observe(targetNode, observerOptions);
278	
279	// function callback(mutationList, observer) {
280	// 	mutationList.forEach( (mutation) => {
281	// 		var LleaderBoardHeight = mutation.target.offsetHeightl;
282	// 		mutation.target.style.position = "sticky"
283	// 		mutation.target.style.top = "45px"
284	// 		mutation.target.style.zIndex = "100"
285
286	// 		document.getElementById('container-index').style.padding = 290 + LleaderBoardHeight + 'px';
287			
288	// 	});
289	//   }
290	// .Watch for Leaderboard change
291
292    function addLink() {
293        var body_element = document.getElementsByTagName('body')[0];
294        var selection;
295        selection = window.getSelection();
296        var pagelink = "<br /><br /> Πηγή : Andro.gr [ <a href='" + document.location.href + "'>" + document.location.href + "</a> ]";
297        var copytext = selection + pagelink;
298        var newdiv = document.createElement('div');
299        newdiv.style.position = 'absolute';
300        newdiv.style.left = '-99999px';
301        body_element.appendChild(newdiv);
302        newdiv.innerHTML = copytext;
303        selection.selectAllChildren(newdiv);
304        window.setTimeout(function() {
305            body_element.removeChild(newdiv);
306        }, 0);
307    }
308    document.oncopy = addLink;
309
310    function create_black_hover_blocks() {
311        $('.block-post').not('.is_single_author_column').find('img').on({
312            mouseenter: function() {
313                var parent_div = $(this).closest('.block-post');
314
315                parent_div.find('.block-info').css('display', 'none');
316                parent_div.find('.block-content').css('display', 'block');
317                parent_div.find('.arrow-down').css('border-top', '20px solid #000');
318
319            },
320            mouseleave: function() {
321                var parent_div = $(this).closest('.block-post');
322
323                parent_div.find('.block-info').css('display', 'block');
324                parent_div.find('.block-content').css('display', 'none');
325                parent_div.find('.arrow-down').css('border-top', '20px solid #f0f
3250f0');
326            }
327        });
328    }
329
330    $('#back_to_top').click(function() {
331        $("html, body").animate({
332            scrollTop: 0
333        }, 1000);
334        return false;
335    });
336
337});
338
339$(window).scroll(function() {
340    if ($(this).scrollTop() > 100) {
341        $('#back_to_top').fadeIn();
342    } else {
343        $('#back_to_top').fadeOut();
344    }
345});
346
347// Fucntions
348
349function get_the_adjacent_post() {
350    var postData = {
351        'action': 'sw_get_adjacent_post',
352        'id': $('.the-single-post').last().data('id') // Get the id of the last post
353    };
354    $.post(theme.ajaxUrl, postData, function(data) {
355        if (data !== false) {
356            $('.next-post-pending').last().append(data).removeClass('next-post-pending');
357        } else {
358            $('.next-post-pending').remove();
359        }
360    }).fail(function() {
361        console.log('Ajax error');
362    }).always(function() {
363        // get_live_images();
364        $('.waiting').removeClass('waiting').addClass('next-post-loaded');
365    });
366}
367
368function get_same_category_post() {
369    console.log('Ajax get_same_category_post Call');
370
371    // term_ids are depends on the variable in post-templates/simple-post.php
372    var terms = [];
373    if (term_ids.length) {
374        terms = term_ids;
375    }
376
377    // excldues are depends each time on the count of post divs
378    var excldues = $('.the-single-post').map(function() {
379        return $(this).data('id');
380    }).get();
381
382    var postData = {
383        'action': 'sw_get_new_post',
384        'excludes': excldues, // Get the ids of viewed posts
385        'terms': terms
386    };
387
388    $.post(theme.ajaxUrl, postData, function(data) {
389        if (data !== false) {
390
391            $('.next-post-pending').last().append(data).removeClass('next-post-pending');
392            var $last = $('.the-single-post').last();
393            // console.log('post counted(ajax): ' +$last.data('id'));
394            // ADTECH.executeQueue();
395            twttr.widgets.load();
396
397        } else {
398            $('.next-post-pending').remove();
399        }
400
401    }).fail(function() {
402        console.log('Ajax error');
403    }).always(function() {
404
405        // get_live_images();
406
407        $('.waiting').removeClass('waiting').addClass('next-post-loaded');
408
409        // init_ads('one');
410        // init_ads('two');
411        // init_ads('three');
412        // init_ads('four');
413
414    });
415
416}
417
418function get_related_posts($related_posts_call) {
419    console.log('Ajax get_related_posts Call');
420
421    // term_ids are depends on the variable in post-templates/simple-post.php
422    var terms = [];
423    if (term_ids.length) {
424        terms = term_ids;
425    }
426
427    // excldues are depends each time on the count of post divs
428    var excldues = $('.the-single-post').map(function() {
429        return $(this).data('id');
430    }).get();
431
432    var postData = {
433        'action': 'sw_get_related_posts',
434        'excludes': excldues, // Get the ids of viewed posts
435        'terms': terms,
436        'call': $related_posts_call
437    };
438
439    $.post(theme.ajaxUrl, postData, function(data) {
440        if (data !== false) {
441
442            $('.next-post-pending').last().append(data).removeClass('next-post-pending');
443            var $last = $('.the-single-post').last();
444            // console.log('post counted(ajax): ' +$last.data('id'));
445            // ADTECH.executeQueue();
446            twttr.widgets.load();
447
448        } else {
449            $('.next-post-pending').remove();
450        }
451
452    }).fail(function() {
453        console.log('Ajax error');
454    }).always(function() {
455
456        // get_live_images();
457
458        $('.waiting').removeClass('waiting').addClass('next-post-loaded');
459
460        // init_ads('one');
461        // init_ads('two');
462        // init_ads('three');
463        // init_ads('four');
464
465    });
466
467}
468
469function get_live_images() {
470    // Turn local.andro url to www.andro for images only
471    $('img').not('.recipe-icon, .ignorem').each(function() {
472        var newSrc = $(this).attr('src');
473        newSrc = newSrc.replace('local.andro', 'www.andro');
474        newSrcset = newSrc.replace('local.andro', 'www.andro');
475        $(this).attr('src', newSrc);
476        $(this).attr('srcset', newSrcset);
477    });
478}
479
480function is_mobile_viewport() {
481    if ($(window).width() > 768) {
482        $('.mobile-spot').remove();
483        return false;
484    } else {
485        $('.main-leaderboard-wrapper').remove();
486        return true;
487    }
488}
489
490function change_history(the_id, the_url, the_title, posts_parrent) {
491    history.pushState('', '', the_url);
492    document.title = the_title;
493}
494
495function move_diqus(that, link, id) {
496
497    var disq_container = $('.disqus-container');
498    if (disq_container.length) {
499
500        $('.disqus-container').html('');
501        var that_disq_container = that.find('.disqus-container');
502
503        if (that_disq_container.length) {
504            that_disq_container.html('<div id="disqus_thread"></div>');
505        }
506
507        DISQUS.reset({
508            reload: true,
509            config: function() {
510                this.page.identifier = 'newidentifier-' + $id;
511                this.page.url = link;
512            }
513        });
514    }
515
516}
517
518function postViewsCount() {
519    // console.log('post counted: ' + $('[data-id]').data('id'));
520    var id = $('[data-id]').data('id');
521    $.ajax({
522        url: theme.ajaxUrl,
523        method: 'POST',
524        cache: false,
525        data: {
526            action: 'sw_post_views_count',
527            id: id
528        },
529        success: function(data) {},
530        error: function() {
531
532        }
533    });
534}
535
536
537

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.