PageSourceSearch

https://www.topseos.com/js/main_global.js

js topseos.com collected 2026-10-02 14:38:16 UTC 13,419 bytes, 383 lines download raw bytes

1jQuery(document).ready(function($) {
2
3    window.attachStarRating = function(el) {
4        el = typeof el !== 'undefined' ? el : 'ul.rate_item_list';
5        if ($(el).length > 0) {
6            var $ul = $(el);
7            var $li = $(el + " > li");
8            var $is_in_ul = false;
9            $li.on('mouseover', function() {
10                var $rate = $(this).data('rate');
11                if ($rate > 2){
12                    $( "ul.rate_item_list" ).find( ".red_mod" ).addClass('green_mod');
13                    $( "ul.rate_item_list" ).find( ".red_mod" ).removeClass('red_mod');
14                }
15                $is_in_ul = true;
16                $.each($li, function(key, value) {
17                    var $child = $(this).children('div');
18                    $child.removeClass('gray_mod');
19                    if (key < $rate) {
20                        if ($rate > 2){
21                            $child.addClass('green_mod');
22                        }else{
23                            $child.addClass('red_mod');
24                        }
25                    } else {
26                        $child.addClass('gray_mod');
27                    }
28                });
29            });
30
31            $li.on('mouseleave', function() {
32                $is_in_ul = false;
33            });
34
35            $li.on('click', function() {
36                var $rate = $(this).data('rate');
37                $ul.next().val($rate);
38            });
39
40            $ul.on('mouseleave', function() {
41                if ($is_in_ul) { return false; }
42                $rate = $ul.next().val();
43                $.each($li, function(key, value) {
44                    var $child = $(this).children('div');
45                    $child.removeClass('gray_mod');
46                    if (key < $rate) {
47                        $child.addClass('green_mod');
48                    } else {
49                        $child.addClass('gray_mod');
50                    }
51                });
52            });
53        }
54    }
55
56    window.attachStarRating();
57
58    var $companyElement = $('.tare_list.rate_item_list');
59    if ($companyElement.length > 0) {
60        var company_id = $companyElement.attr('id').split('_').pop();
61        // Prefill the Ratings when the ratings is set by User before Linkedin login
62        if (readCookie('last_star_rating_' + company_id) != null) {
63            var $star = readCookie('last_star_rating_' + company_id);
64            // Reset Ratings
65            //$('.rate_item_list li.rate_item_w > div').removeClass('gray_mod').addClass('green_mod');
66            // Apply Ratings from cookie
67           // $('.rate_item_list li.rate_item_w:gt(' + ($star - 1) + ') > div').addClass('gray_mod');
68           // $('#comment_rating').val($star);
69        }
70
71        if ($('#mod-linkedin').length > 0) {
72            // Add a cookie When the user clicks on Linkedin Sign in button
73            $('.sign-in-button').click(function() {
74                createCookie(
75                    'last_star_rating_' + company_id,
76                    $('#comment_rating').val(),
77                    1
78                );
79            });
80        }
81    }
82
83    window.openWriteReview = function($postid) {
84        $.colorbox({
85            width: '60%',
86            href: ajaxurl,
87            data: {
88                'action': 'write_review_popover',
89                'id': $postid
90            },
91            onComplete: function() {
92                window.attachStarRating("#rate_item_popover_" + $postid);
93                window.attachReviewWordCount();
94            }
95        });
96    }
97
98    var $hashes = window.location.hash.substr(1).split('=');
99    if ($hashes.length == 2 && $hashes[0] == 'write-review') {
100        window.openWriteReview($hashes[1]);
101    }
102
103    if ($('#mod-linkedin').length < 1) {
104        /*$(".write_review_p").on('click', function() {
105            window.openWriteReview($(this).data('id'));
106            return false;
107        });*/
108    }
109
110    if ($(".most_helpful").length > 0) {
111        $(".most_helpful").on('click', function() {
112            var $elem = $(this).parents('.most_helpful_box');
113            $.colorbox({
114                html:'<div class="reviews_helpful_item mbox">' + $elem.html() + '</div>',
115                closeButton:false,
116                onComplete: function() {
117                    $(".mbox").find('.reviews_helpful_content').hide();
118                    $(".mbox").find('.reviews_helpful_content_full').show();
119                    $.colorbox.resize();
120                }
121            });
122        });
123    }
124
125    $(".clients_review_author_reply").click(function() {
126        var _self = $(this);
127        var reviewId = _self.data("id");
128        $("#reply-form-" + reviewId).addClass('active');
129
130        return false;
131    });
132
133    $(".clients_review_replies_reply").click(function() {
134        var _self = $(this);
135        var reviewId = _self.data("id");
136        $("#reply-form-reply-" + reviewId).show();
137
138        return false;
139    });
140
141    if ($(".clients_review_list").length > 0) {
142        $(".clients_review_list").infiniteScroll({
143            path: '.pagination__next',
144            append: '.clients_review_item',
145            history: 'push',
146            status: '.page-load-status'
147        });
148    }
149
150    window.relayout = true;
151    var Shuffle = window.Shuffle;
152
153    if (typeof(Shuffle) !== 'undefined') {
154        Shuffle.ShuffleItem.Css.INITIAL.width = '100%';
155    }
156
157    var Ranking = function (element) {
158        this.element = element;
159        this.shuffle = new Shuffle(element, {
160            itemSelector: '.listing-item',
161            sizer: null,
162            useTransforms: false
163        });
164
165        this.addSorting();
166        this.mode = 'exclusive';
167
168        this.shuffle.on(Shuffle.EventType.LAYOUT, function(data) {
169            console.log('on.layout')
170            var sortable = [];
171            for (var item in data.shuffle.items) {
172                sortable.push([
173                    data.shuffle.items[item].element.id,
174                    data.shuffle.items[item].point.y
175                ]);
176            }
177
178            sortable.sort(function(a, b) {
179                return a[1] - b[1];
180            });
181
182            reorderListings(sortable);
183
184            if (window.relayout) {
185                window.relayout = false;
186                window.rankingShuffle.shuffle.layout();
187            }
188        });
189    };
190
191    Ranking.prototype.addSorting = function () {
192        var _self = this;
193        $(".sort_ranking").on('change', function(e) {
194            var value = $(this).val();
195
196            function sortByOrder(element) {
197                return parseInt(element.getAttribute('data-order'));
198            }
199            function sortByReview(element) {
200                return parseInt(element.getAttribute('data-review'));
201            }
202            function sortByLatest(element) {
203                return parseInt(element.getAttribute('data-latest'));
204            }
205
206            var options;
207            if (value === '1') {
208                options = {
209                    by: sortByOrder
210                };
211            } else if (value === '2') {
212                options = {
213                    reverse: true,
214                    by: sortByReview
215                };
216            } else if (value === '3') {
217                options = {
218                    reverse: true,
219                    by: sortByLatest
220                };
221            } else {
222                options = {};
223            }
224
225            window.relayout = true;
226            _self.shuffle.sort(options);
227        });
228    };
229
230    function reorderListings(items) {
231        var _id;
232        var _c;
233        var _class;
234
235        var _lead = $("#leaders_t").detach();
236        var _perf = $("#performers_t").detach();
237        var _cont = $("#contenders_t").detach();
238
239        var _crit_0 = $("#criteria_0").detach();
240        var _crit_1 = $("#criteria_1").detach();
241        var _crit_2 = $("#criteria_2").detach();
242        var _crit_3 = $("#criteria_3").detach();
243        var _crit_4 = $("#criteria_4").detach();
244
245        for (var i = 0; i < items.length; i++) {
246            _id = items[i][0];
247            _c = i + 1;
248            _class = '';
249            if (i > 0) { _class = 'crown'; }
250            if (i > 4) { _class = 'none'; }
251            $("#" + _id + " .statistic_col.v1_mod").html("<div class=\"statistic_w_position " + _class + "\">" +
252                "<span class=\"statistic_position\">" + _c + "</span>" +
253                "</div>");
254
255            if (i == 0) { $("#" + _id + " .statistic").prepend(_lead); }
256            if (i == 3) { $("#" + _id + " .statistic").prepend(_perf); }
257            if (i == 6) { $("#" + _id + " .statistic").prepend(_cont); }
258
259            if (i == 49) { $("#" + _id).append(_crit_0); }
260            if (i == 59) { $("#" + _id).append(_crit_1); }
261            if (i == 69) { $("#" + _id).append(_crit_2); }
262            if (i == 79) { $("#" + _id).append(_crit_3); }
263            if (i == 89) { $("#" + _id).append(_crit_4); }
264        }
265    }
266
267    if ($("#ranks_table").length > 0) {
268        // window.rankingShuffle = new Ranking(document.getElementById('ranks_table'));
269    }
270
271    var $placeCookie = false;
272    if (window.location.pathname.search("/write-review") > 0) { $placeCookie = true; }
273    if (window.location.pathname.search("/record-review") > 0) { $placeCookie = true; }
274    if (window.location.pathname.search("/reviews") > 0) { $placeCookie = true; }
275    if ($placeCookie) { createCookie('li_redirect', window.location.href, ''); }
276
277    function checkReviewType() {
278        $val = $('.review_check_list .radio_check_input:checked').val();
279        if ($val == 'employee') {
280            $('.block_2').show();
281            $('.block_1').hide();
282        } else {
283            $('.block_1').show();
284            $('.block_2').hide();
285        }
286    }
287    $('.review_check_list .radio_check_input').click(function() {
288        checkReviewType();
289    });
290
291    function wordCount(val) {
292        var wom = val.match(/\S+/g);
293        return {
294            charactersNoSpaces: val.replace(/\s+/g, '').length,
295            characters: val.length,
296            words: wom ? wom.length : 0
297        };
298    }
299
300    window.attachReviewWordCount = function() {
301        $("textarea.form_field").on('input', function() {
302            var $v = wordCount($(this).val());
303            var $text = $v.words + ' words';
304            if (parseInt($v.words) == 1) { $text = $v.words + ' word'; }
305            $(this).parents('div.form_block').find('.word_count').html('(Word count: ' + $text + ')');
306        });
307    }
308
309    window.attachReviewWordCount();
310
311    // Rankings form
312    var $formQuote = $('#mod-request-quote form');
313    if ($formQuote.length > 0) {
314        $formQuote.on('submit', function (e) {
315            e.preventDefault();
316            if ($(this).valid()) {
317                $.ajax({
318                    type: "POST",
319                    url: $(this).attr('action'),
320                    data: $(this).serialize(),
321                    dataType: 'JSON',
322                    success: function (res) {
323                        if (res.status == 'success') {
324                            jQuery('#mod-request-quote .gform_wrapper').addClass('hidden');
325                            jQuery('#mod-request-quote form').prepend('<div class="confirmation_message">' + res.message + '</div>');
326                            jQuery('#mod-request-quote form')[0].reset();
327                        }
328                    }
329                });
330            } else {
331                $.colorbox.resize();
332            }
333        });
334    }
335
336    var $formCall = $('#mod-request-call form');
337    if ($formCall.length > 0) {
338        $formCall.on('submit', function(e) {
339            e.preventDefault();
340            if ($(this).valid()) {
341                $.ajax({
342                    type: "POST",
343                    url: $(this).attr('action'),
344                    data: $(this).serialize(),
345                    dataType: 'JSON',
346                    success: function( res ) {
347                        if (res.status == 'success') {
348                            jQuery('#mod-request-call .gform_wrapper').addClass('hidden');
349                            jQuery('#mod-request-call form').prepend('<div class="confirmation_message">' + res.message + '</div>');
350                            jQuery('#mod-request-call form')[0].reset();
351                        }
352                    }
353                });
354            } else {
355                $.colorbox.resize();
356            }
357        });
358    }
359
360    var $formVisit = $('#mod-schedule-visit form');
361    if ($formVisit.length > 0) {
362        $formVisit.on('submit', function(e) {
363            e.preventDefault();
364            if ($(this).valid()) {
365                $.ajax({
366                    type: "POST",
367                    url: $(this).attr('action'),
368                    data: $(this).serialize(),
369                    dataType: 'JSON',
370                    success: function( res ) {
371                        if (res.status == 'success') {
372                            jQuery('#mod-schedule-visit .gform_wrapper').addClass('hidden');
373                            jQuery('#mod-schedule-visit form').prepend('<div class="confirmation_message">' + res.message + '</div>');
374                            jQuery('#mod-schedule-visit form')[0].reset();
375                        }
376                    }
377                });
378            } else {
379                $.colorbox.resize();
380            }
381        });
382    }
383});

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.