PageSourceSearch

https://cont.ws/js/main.js?t=1790326250

js cont.ws collected 2026-09-25 08:51:01 UTC 11,114 bytes, 353 lines download raw bytes

1var messagesOpen = false;
2var premiumOptionsOpen = false;
3
4function randomInteger(min, max) {
5    var rand = min + Math.random() * (max + 1 - min);
6    rand = Math.floor(rand);
7    return rand;
8}
9$(document).ready(function () {
10    var $body = $("body");
11    $(".promo_post").appear();
12    $body.on('appear', '.promo_post', function (e, $affected) {
13        var $post = $(this);
14
15        $.ajax({
16            type: "POST",
17            global: false,
18            url: "/ajax/promo.php",
19            data: ({
20                type: 'promo-viewed',
21                post: $post.attr("post_id"),
22                promo: $post.attr("promo_id")
23            }),
24            success: function (data) {
25                console.log('viewed ' + $post.attr("post_id") + ':' + $post.attr("promo_id"));
26            }
27        });
28
29        $.ajax({
30            type: "POST",
31            global: false,
32            url: "https://cont.ws/0x171qa483/promo/view-promo",
33            data: ({
34                promoID: $post.attr("promo_id")
35            }),
36            success: function (data) {
37                console.log('viewed ' + $post.attr("post_id") + ':' + $post.attr("promo_id"));
38            }
39        });
40
41        $post.removeClass("promo_post");
42    });
43
44    $(".ext-promo-post").appear();
45    $body.on('appear', '.ext-promo-post', function (e, $affected) {
46        var $post = $(this);
47
48        $.ajax({
49            type: "POST",
50            global: false,
51            url: "https://cont.ws/0x171qa483/external-promo/view",
52            data: ({
53                promo_id: $post.attr("ext-promo-id"),
54            }),
55            success: function (data) {
56                console.log('viewed external' + $post.attr("promo_id"));
57            }
58        });
59
60        $post.removeClass("ext-promo-post");
61    });
62
63    $(".exchange_post").appear();
64    $body.on('appear', '.exchange_post', function (e, $affected) {
65        var $post = $(this);
66
67        $.ajax({
68            type: "POST",
69            global: false,
70            url: "/ajax/exchange.php",
71            data: ({
72                type: 'post_view',
73                promo: $post.attr("promo_id")
74            }),
75            success: function (data) {
76                console.log('exchange viewed');
77            }
78        });
79        $post.removeClass("exchange_post");
80    });
81
82    $(".channels-list-item--promo").appear();
83    $body.on('appear', '.channels-list-item--promo', function (e, $affected) {
84        var $post = $(this);
85        var promoID = $post.data("ch-promoid");
86        var read = $post.data("promo-read");
87
88        if (!promoID || read === 1) return;
89
90        $.ajax({
91            type: "POST",
92            global: false,
93            url: "https://cont.ws/0x171qa483/channel/readPromo",
94            data: ({
95                promoID: promoID
96            }),
97            success: function (data) {
98                console.log('channel promo ' + promoID + ' viewed');
99            }
100        });
101
102        $post.data("promo-read", 1);
103    });
104
105    $(".ads-close").click(function (e) {
106        e.preventDefault();
107
108        var $this = $(this);
109
110        $this.parent().fadeOut(200, function () {
111            $this.parent().html("");
112        });
113    });
114
115    $(document).on('click', '#posts_container .fav-button, .post.w700 .fav-button', function (e) {
116        e.preventDefault();
117
118        var button = this;
119
120        var postBlock = button.closest('.new_post_prev');
121        if (!postBlock) {
122            return;
123        }
124
125        var postID = postBlock.dataset.postId || postBlock.getAttribute('post_prv');
126
127        if (!postID) {
128            return;
129        }
130
131        var activeClass = 'btn-active';
132        var isActive = button.classList.contains(activeClass);
133        var counter = button.querySelector('.bookmarks_counter');
134
135        var url = isActive
136            ? '/0x171qa483/bookmark/remove'
137            : '/0x171qa483/bookmark/add';
138
139        fetch(url, {
140            method: 'POST',
141            headers: {
142                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
143            },
144            body: new URLSearchParams({
145                post_id: postID
146            })
147        })
148            .then(function (response) {
149                if (!response.ok) {
150                    throw new Error('Request failed');
151                }
152
153                return response.json();
154            })
155            .then(function (data) {
156
157                var bookmarkCount = Number(data.bookmark_count || 0);
158
159                if (isActive) {
160                    button.classList.remove(activeClass);
161                } else {
162                    button.classList.add(activeClass);
163                }
164
165                if (counter) {
166                    if (bookmarkCount === 0) {
167                        counter.style.display = 'none';
168                    } else {
169                        counter.style.display = '';
170                    }
171
172                    counter.textContent = String(bookmarkCount);
173                }
174            })
175            .catch(function (err) {
176                console.error(err);
177            });
178    });
179
180    $(".top_menu_dropdown").dropdown();
181    $(".top_menu_dropdown").tooltip();
182
183    $(".post-actions").dropdown();
184    $(".post-actions").tooltip();
185
186    var tmp1 = $(window).scrollTop() - 50;
187    var tmp2 = $(window).scrollTop() + 50;
188    var $dropMoreBlock = $('#headline').find('.header_menu_right__more');
189    var $dropUserBlock = $('#headline').find('.header_menu_right__user');
190    //if($(window).height()>=768){
191    $(window).scroll(function () {
192        if (!messagesOpen && !premiumOptionsOpen && !$('.header_menu_right__notifications').hasClass('active')) {
193            if ($(window).scrollTop() >= tmp2) {
194                tmp1 = $(window).scrollTop() - 50;
195                tmp2 = $(window).scrollTop() + 50;
196                $('#headline').addClass('nav-up');
197                if ($dropMoreBlock.hasClass('open')) $dropMoreBlock.click();
198                if ($dropUserBlock.hasClass('open')) $dropUserBlock.click();
199                if ($('#more_link button').hasClass('active')) $('#more_link button').click();
200
201                if ("vue_main_side_menu" in window) {
202                    vue_main_side_menu.$refs.sidemenu.setHeaderVisibilityStatus(false);
203                }
204            } else if ($(window).scrollTop() <= tmp1) {
205                tmp1 = $(window).scrollTop() - 50;
206                tmp2 = $(window).scrollTop() + 50;
207                $('#headline').removeClass('nav-up');
208
209                if ("vue_main_side_menu" in window) {
210                    vue_main_side_menu.$refs.sidemenu.setHeaderVisibilityStatus(true);
211                }
212            }
213        }
214    });
215    //}
216
217    $('[data-toggle="tooltip"]').tooltip();
218
219    $('.navmenu').on('show.bs.offcanvas', function () {
220        $('button[data-toggle="offcanvas"]').html('<i class="fa fa-times" aria-hidden="true"></i>');
221    });
222
223    $('.navmenu').on('hide.bs.offcanvas', function () {
224        $('button[data-toggle="offcanvas"]').html('<i class="fa fa-bars" aria-hidden="true"></i>');
225    });
226
227    function hideSearch() {
228        $('.search').hide();
229        $('.search').css('opacity', '0');
230
231    };
232
233    $('#search_link button').click(function () {
234        let $searchIcon = $('#search_link button');
235
236        if (!($('.search').is(':visible'))) {
237
238            $('.search').css('opacity', '1');
239            $('.search').show(
240                { done: function () { $('#header_menu').toggleClass("search_show"); } }
241            );
242            $searchIcon.html('<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>');
243
244        } else {
245            $('#header_menu').toggleClass("search_show");
246            $searchIcon.html('<span class="glyphicon glyphicon-search" aria-hidden="true"></span>')
247            setTimeout(hideSearch, 1000);
248        }
249
250    });
251
252    $('#more_link button').click(function () {
253        $('.header_menu_more').fadeToggle('fast', function () {
254            $('.header_menu_more').is(':visible') ? $('#more_link button').addClass('active') : $('#more_link button').removeClass('active');
255        });
256    });
257
258    $('#sub-menu3-link').click(function (event) {
259        event.stopPropagation();
260        event.preventDefault();
261        $('.header_menu_more').hide();
262        $('#more_link button').removeClass('active')
263        $('#sub-menu5').fadeToggle('fast');
264        $('#sub_menu3_arrow').fadeToggle('fast');
265
266    });
267
268    $(".premium-sub-info-button").click(function (event) {
269        event.preventDefault();
270        $('.premium-sub-info-block').fadeToggle();
271        $('.premium-sub-button').toggleClass('goldpulse');
272    });
273
274    $(".premium-sub-info-block .close").click(function (event) {
275        $(this).parent().fadeOut();
276        $('.premium-sub-button').removeClass('goldpulse');
277    });
278
279    $(".lenta").on("click", ".channels-list-item__sub-button", function (e) {
280        e.preventDefault();
281
282        var $this = $(this);
283        var sub = $this.closest(".channels-list-item--promo").data("sub");
284        var channelId = $this.closest(".channels-list-item--promo").data("channel-id");
285
286        var method = sub ? "unsubscribe" : "subscribe";
287        var text = sub ? "Подписаться" : "Вы подписаны";
288
289        $this.text(text);
290        $this.closest(".channels-list-item--promo").data("sub", true);
291
292        $.ajax({
293            type: "POST",
294            global: false,
295            url: "https://cont.ws/0x171qa483/channel/" + method,
296            data: ({
297                channelID: channelId
298            }),
299            dataType: "json",
300        });
301    });
302});
303
304
305
306
307$(document).click(function (e) {
308    var elem = $("#sub-menu");
309    if (e.target != elem[0] && !elem.has(e.target).length) elem.hide();
310    var elem = $("#sub-menu2");
311    if (e.target != elem[0] && !elem.has(e.target).length) elem.hide();
312    elem = $("#sub-menu5").add($("#sub_menu3_arrow"));
313    if (e.target != elem[1] && elem[0] && !elem.has(e.target).length) elem.hide();
314
315
316
317})
318
319function getNoun(number, one, several, many) {
320    number = Math.abs(number);
321    number %= 100;
322    if (number >= 5 && number <= 20) {
323        return many;
324    }
325    number %= 10;
326    if (number == 1) {
327        return one;
328    }
329    if (number >= 2 && number <= 4) {
330        return several;
331    }
332    return many;
333}
334
335
336$.fn.textWidth = function (text, font) {
337    if (!$.fn.textWidth.fakeEl) $.fn.textWidth.fakeEl = $('<span>')
338        .css({ visibility: "hidden", "pointer-events": "none", "position": "absolute", top: 0, left: 0 }).appendTo(document.body);
339
340    var elemFontCss = {
341        "font-family": $(this).css("font-family"),
342        "font-size": $(this).css("font-size"),
343        "line-height": $(this).css("line-height"),
344        "font-stretch": $(this).css("font-stretch"),
345        "font-weight": $(this).css("font-weight"),
346        "font-style": $(this).css("font-style"),
347        "font-variant": $(this).css("font-variant"),
348    }
349
350    $.fn.textWidth.fakeEl.text(text || $(this).val() || $(this).text() || $(this).attr('placeholder')).css(elemFontCss);
351
352    return $.fn.textWidth.fakeEl.width();
353};

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.