PageSourceSearch

https://steaklovers.menu/static/js/script.js?v=20260829lcp

js steaklovers.menu collected 2026-10-02 11:06:30 UTC 21,965 bytes, 675 lines download raw bytes

1steak = new function()
2{     
3    this.authorized = false;
4    this.toCommentResponse = function(hid)
5    {
6        if(!this.authorized)
7        {
8            this.showLogin();
9            return;
10        }
11        $("#comment_hid").val(hid);
12        $('html, body').animate({scrollTop:$(".comment_response").offset().top}, '500');
13    }
14    this.commentAdd = function(action)
15    {
16        if(!this.authorized)
17        {
18            this.showLogin();
19            return;
20        }
21        var comtext = CKEDITOR.instances.comment_text.getData();
22        
23        if(!comtext)
24            return;
25        
26        $.ajax({
27            url     : "/ajax/"+action,
28            type    : 'POST',
29            data    : { pid: $("#comment_pid").val(), hid: $("#comment_hid").val(), text: comtext, _auth_: true },
30            dataType: "html",
31            success : function(html)
32            {
33                if(!checkResponse(html))
34                    return;
35                if(!html)
36                    return;
37                
38                $('.comments_cont').removeClass('hidden');
39                $('.comment_response > .split').removeClass('hidden');
40                var cmnt = $(html);
41                var sort = cmnt.attr('sort');
42                var cs = $('.comment.sort_'+sort);
43                if(cs.length > 0)
44                    cs.last().after(cmnt);
45                else
46                    $('.comments_cont').append(cmnt);
47                steak.parseDate();
48            }
49        });
50        CKEDITOR.instances.comment_text.setData('');
51        $("#comment_hid").val('');
52    }
53    this.curEditCommentText = '';
54    this.curEditCommentId = null; 
55    this.editComment = function(id,action)
56    {
57        if(this.curEditCommentId != id && this.curEditCommentId != null)
58        {
59            $("#comment"+this.curEditCommentId).removeClass('editable');
60            $("#comment_text"+this.curEditCommentId).attr('contenteditable',null);
61            
62            $("#comment_text"+this.curEditCommentId).html(this.curEditCommentText);
63            this.curEditCommentId = null;
64        }
65        if(this.curEditCommentId == id && id != null)
66        {
67            $.ajax({
68                url     : "/ajax/"+action,
69                type    : 'POST',
70                data    : { id: id, text: $("#comment_text"+this.curEditCommentId).html(), _auth_: true },
71                dataType: "html",
72                success : function(html)
73                {
74                    if(!checkResponse(html))
75                        return;
76                    
77                    if(!html)
78                    {
79                        steak.curEditCommentText = $("#comment_text"+this.curEditCommentId).html(); 
80                        steak.editComment(null);
81                        return;
82                    }
83                    
84                    alert(html);
85                }
86            });
87        }else if(id != null){
88            this.curEditCommentId = id;
89            $("#comment"+this.curEditCommentId).addClass('editable');
90            $("#comment_text"+this.curEditCommentId).attr('contenteditable',true);
91            this.curEditCommentText = $("#comment_text"+this.curEditCommentId).html();
92        }
93        
94    }
95    this.deleteComment = function(id,action)
96    {
97        if(!confirm('Удалить комментарий и все ответы на него?'))
98                return;
99        $.ajax({
100            url     : "/ajax/"+action,
101            type    : 'POST',
102            data    : { id: id, _auth_: true },
103            dataType: "html",
104            success : function(html)
105            {
106                if(!checkResponse(html))
107                    return;
108                if(!html)
109                    return;
110                var ids = html.split(',');
111                
112                for(var i = 0; i < ids.length; i++)
113                {
114                    $('[commentid="'+ids[i]+'"]').remove();
115                }
116                
117                if($('[commentid]').length <= 0)
118                {
119                    $('.comment_response > .split').addClass('hidden');
120                    $('.comments_cont').addClass('hidden');
121                }
122            }
123        });
124    }
125    this.deleteRequest = function(id)
126    {
127        if(!confirm('Удалить популярный запрос?'))
128                return;
129        $.ajax({
130            url     : "/ajax/requestdel",
131            type    : 'POST',
132            data    : { id: id, _auth_: true },
133            dataType: "html",
134            success : function(html)
135            {
136                if(!checkResponse(html))
137                    return;
138                if(!html)
139                    return;
140                
141                $('[requestid="'+html+'"]').remove();
142            }
143        });
144    }
145    this.loadUser = function(id,unit)
146    {
147        if(this.currentUserLoad == 'user_'+unit)
148            return;
149        
150        $('.menuswitch > .active').removeClass('active');
151        $('.menuswitch > .'+unit+'btn').addClass('active');
152        this.currentUserLoad = 'user_'+unit;
153        $.ajax({
154            url     : "/ajax/user_"+unit+'/id:'+id,
155            type    : 'POST',
156            data    : {},
157            dataType: "html",
158            success : function(html)
159            {
160                if(!checkResponse(html))
161                    return;
162                if(!html)
163                    return;
164                
165                html = $(html);
166                
167                $('#container').html(html);
168                
169                if(html.filter('.moreitem').length < 10)
170                    $('.btn_more').hide(); 
171                else
172                    $('.btn_more').show();
173                
174                steak.parseDate();
175            }
176        });
177    }
178    this.showLogin = function()
179    {
180        this.hideRegister();
181        if($("#login_overlay").fadeIn().length > 0)
182            return;
183        $.ajax({
184            url     : "/ajax/showlogin",
185            type    : 'GET',
186            dataType: "html",
187            success : function(html)
188            {
189                if(!html)
190                    return;
191                $('body').append(html);
192                $("#login_overlay").fadeIn();
193            }
194        });
195    }
196    this.hideLogin = function()
197    {
198        $("#login_overlay").fadeOut();
199    }
200    this.authorize = function()
201    {
202        $.ajax({
203            url     : "/ajax/auth",
204            type    : 'POST',
205            data    : { login: $("#auth_login").val(), password: $("#auth_password").val() },
206            dataType: "json",
207            success : function(json)
208            {
209                if(json && json.result == 'OK')
210                {
211                    $(".auth_login").html(json.login);
212                    $(".auth_city").html(json.city);
213                    $(".auth_avatar").attr('src',json.avatar);
214                    $(".auth_button").remove();
215                    steak.authorized = true;
216                    steak.hideLogin();
217                    $("#auth_menu").remove();
218                    $.ajax({
219                        url     : "/ajax/authmenu",
220                        type    : 'GET',
221                        dataType: "html",
222                        success : function(html)
223                        {
224                            if(!html)
225                                return;
226                            $('.header').append(html);
227                        }
228                    });
229                    return; 
230                }else if(json)
231                    alert(json.result);
232            }
233        });
234    }
235    this.showRegister = function()
236    {
237        this.hideLogin();
238        if($("#regiser_overlay").fadeIn().length > 0)
239            return;
240        $.ajax({
241            url     : "/ajax/showregister",
242            type    : 'GET',
243            dataType: "html",
244            success : function(html)
245            {
246                if(!html)
247                    return;
248                $('body').append(html);
249                $("#register_overlay").fadeIn();
250            }
251        });
252    }
253    this.hideRegister = function()
254    {
255        $("#register_overlay").fadeOut();
256    }
257    this.registration = function()
258    {
259        $.ajax({
260            url     : "/ajax/registration",
261            type    : 'POST',
262            data    : { name: $("#reg_name").val(),email: $("#reg_email").val(),login: $("#reg_login").val(), password: $("#reg_password").val() },
263            dataType: "json",
264            success : function(json)
265            {
266                if(json && json.result == 'OK')
267                {
268                    steak.showLogin();
269                    return; 
270                }else if(json)
271                    alert(json.result);
272            }
273        });
274    }
275    this.logout = function()
276    {
277        $.ajax({
278            url     : "/ajax/logout",
279            type    : 'GET',
280            dataType: "html",
281            success : function(html)
282            {
283                document.location = '/';
284            }
285        });
286    }
287    function checkResponse(text)
288    {
289        switch(text)
290        {
291            case 'AUTH_ERROR':
292                    steak.showLogin();
293                    return false;
294                break;
295        }
296        return true;
297    }
298    this.saveProfile = function()
299    {
300        $.ajax({
301            url     : "/ajax/saveprofile",
302            type    : 'POST',
303            data    : { 
304                username: $("#pusername").val(), 
305                image: $("#pavatar").attr('src'),
306                city: $("#pcity").val(), 
307                site: $("#psite").val(),
308                email: $("#pemail").val(),
309                password: $("#newpassword").val(),
310                weeklysend: $("#weeklysend").is(':checked')?1:0,
311                commtheme: $("#commtheme").is(':checked')?1:0,
312                _auth_: true 
313            },
314            dataType: "html",
315            success : function(html)
316            {
317                if(!checkResponse(html))
318                    return;
319                if(html == '1')
320                {
321                    document.location = '/user';
322                }else
323                    alert(html);
324            }
325        });
326    }
327    this.masonryRun = function()
328    {
329        $('#container').imagesLoaded( function() {
330        // images have loaded
331        $('#container').masonry({
332            //columnWidth: 267,
333            stamp: '.stamp',
334            itemSelector: '.moreitem',
335            transitionDuration: 0
336          });
337      });
338    }
339    this.loadMore = function(type,masonry,subtype,ramount,thread,tag,filter,author)
340    {
341        $('.btn_more').hide();
342        $('#loadmore').addClass('is-visible');
343        
344        ramount = ramount || 10;
345        var url = "/ajax/more_"+type
346            +'/offset:'+$('#container .moreitem').length
347            +'/amount:'+ramount
348            +'/arg0:'+encodeURIComponent(subtype || '')
349            +(thread ? '/thread:'+encodeURIComponent(thread) : '')
350            +(tag ? '/tag:'+encodeURIComponent(tag) : '')
351            +(filter ? '/filter:'+encodeURIComponent(filter) : '')
352            +(author ? '/author:'+encodeURIComponent(author) : '');
353        $.ajax({
354            url     : url,
355            type    : 'GET',
356            dataType: "html",
357            success : function(html)
358            {
359                var addItems = function()
360                {
361                    window.addEventListener('popstate', function(e){
362                        console.log(e);
363                        e.back();
364                    }, false);
365                    $('#container').append(html);
366                    window.history && window.history.replaceState({},'',(document.location.pathname == '/'?'/index':'')+document.location.pathname.replace(/\/amount:[0-9]+/,'')+(/\/$/.test(document.location.pathname)?'':'/')+'amount:'+$('#container .moreitem').length);
367                    return true;
368                }
369                
370                if(html.search('<') == -1)
371                {
372                    $('.btn_more').hide() && $('#loadmore').removeClass('is-visible');
373                }else
374                {
375                    html = $(html);
376                    var showBtnMore = html.filter('.moreitem').length >= ramount || $('.moreitem',html).length >= ramount;
377                    steak.bindBrokenMatImgs(html);
378                    if(masonry)
379                    {
380                        var imgs = $('img',html).length;
381                        $('img',html).each(function(ind,img){
382                            img.onload = function(){
383                                if(imgs-- <= 1)
384                                   addItems() && $('#container').masonry('appended', html ) && $('#loadmore').removeClass('is-visible') && showBtnMore && $('.btn_more').show();
385                            };
386                            img.onerror = function(){
387                                steak.fixBrokenMatImg(img);
388                                if(imgs-- <= 1)
389                                    addItems() && $('#container').masonry('appended', html ) && $('#loadmore').removeClass('is-visible') && showBtnMore && $('.btn_more').show();
390                            }
391                        });
392                    }else
393                        addItems() && $('#loadmore').removeClass('is-visible') && showBtnMore && $('.btn_more').show();
394
395                    steak.parseDate();
396                }
397            }
398        });
399    }
400    this.saveTopic = function()
401    {
402        $.ajax({
403            url     : "/ajax/savetopic",
404            type    : 'POST',
405            data    : { 
406                id: $("#topic_id").val(), 
407                title: $("#topic_title").val(),
408                text: CKEDITOR.instances.topic_text.getData(),
409                _auth_: true 
410            },
411            dataType: "html",
412            success : function(html)
413            {
414                if(!checkResponse(html))
415                    return;
416                if(+html > 0)
417                {
418                    document.location = '/community/'+html;
419                }else
420                    alert(html);
421            }
422        });
423    }
424    this.delTopic = function(id)
425    {
426        if(!confirm('Удалить тему и все комментарии к ней?'))
427            return;
428        $.ajax({
429            url     : "/ajax/deltopic",
430            type    : 'POST',
431            data    : { 
432                id: id, 
433                _auth_: true 
434            },
435            dataType: "html",
436            success : function(html)
437            {
438                if(!checkResponse(html))
439                    return;
440                if(html == 'OK')
441                {
442                    document.location = '/community/';
443                }else
444                    alert(html);
445            }
446        });
447    }
448    this.topicFavoriteSwitch = function(starDom,id)
449    {
450        $(starDom).toggleClass('active');
451        
452        $.ajax({
453            url     : "/ajax/topicfavorite",
454            type    : 'POST',
455            data    : { 
456                topicid: id,
457                _auth_: true 
458            },
459            dataType: "html",
460            success : function(html)
461            {
462                if(!checkResponse(html))
463                {
464                    $(starDom).toggleClass('active');
465                    return;
466                }
467                if(html != 'OK')
468                {
469                    $(starDom).toggleClass('active');
470                    alert(html);
471                }
472            }
473        });
474    }
475    this.parseDate = function()
476    {
477        moment.lang('ru');
478        
479        $('.momentdate').each(function(i,dom){
480            $(dom).html(moment($(dom).html(),'YYYY-MM-DD hh:mm:ss').calendar()).removeClass('momentdate');
481        });
482    }
483    this.ckEditor = function(id,upload,rBtns)
484    {
485        var config = {};
486        config.toolbarGroups = [
487		{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },{ name: 'links' },
488		{ name: 'insert' },
489		{ name: 'tools'},
490		{ name: 'colors' },
491		{ name: 'about' }
492	];
493
494	// Remove some buttons provided by the standard plugins, which are
495	// not needed in the Standard(s) toolbar.
496	config.removeButtons = 'Anchor,Subscript,Superscript,ShowBlocks,PageBreak,Iframe,Table'+(rBtns?','+rBtns:'');
497
498	// Simplify the dialog windows.
499	config.removeDialogTabs = 'image:advanced;link:advanced';
500        
501        config.removePlugins = 'elementspath';
502        
503        config.filebrowserImageUploadUrl = '/ajax/'+upload+'_upload/?'+new Date().getTime();
504        
505        CKEDITOR.replace(id, config);
506    }
507    this.newTopicGo = function()
508    {
509        if(!this.authorized)
510        {
511            this.showLogin();
512            return;
513        }
514        document.location = '/community/new';
515    }
516    this.showChefs = function()
517    {
518        this.hideRegister();
519        $('body').append($("#chefs_overlay"));
520        $("#chefs_overlay").height(Math.max($('.wrapper').height(),$('#chefs_overlay .chefs').height()));
521        $("#chefs_overlay .chefs").css({marginTop:(($('body').scrollTop()||$('html').scrollTop())+236)+'px'})
522        if($("#chefs_overlay").fadeIn().length > 0)
523            return;
524    }
525    this.hideChefs = function()
526    {
527        $("#chefs_overlay").fadeOut();
528    }
529    this.globalData = new function()
530    {
531        this.storage = {};
532        if (window['localStorage'])
533        {
534            this.storage = window.localStorage;
535        }else if (window['globalStorage'])
536        {
537            this.storage = window.globalStorage[document.domain];
538        }
539
540        this.get = function(name,defaultValue){
541            if(this.storage[name] === undefined)
542                return defaultValue;
543            return String(this.storage[name]);
544        };
545        this.set = function(name,value){
546            if(value === undefined)
547            {
548                this.storage[name] = undefined;
549                delete this.storage[name];
550                return;
551            }
552            this.storage[name] = value;
553        }
554    }
555    this.setcookie = function(name, value, expires, path, domain, secure) {
556	if (!name || !value) return false;
557	var str = name + '=' + encodeURIComponent(value);
558	
559	if (expires) str += '; expires=' + expires.toGMTString();
560	if (path)    str += '; path=' + path;
561	if (domain)  str += '; domain=' + domain;
562	if (secure)  str += '; secure';
563	
564	document.cookie = str;
565	return true;
566    }
567    this.subscribe = function(elementid,type,unsubscribe)
568    {
569        if(!this.authorized)
570        {
571            this.showLogin();
572            return;
573        }
574        
575        $.ajax({
576            url     : "/ajax/subscribe",
577            type    : 'POST',
578            data    : { elementid: elementid, type: type, unsubscribe: unsubscribe?1:0, _auth_: true },
579            dataType: "html",
580            success : function(html)
581            {
582                if(!checkResponse(html))
583                    return;
584                if(html !== 'OK')
585                {
586                    alert(html);
587                    return;
588                }
589                $('.subscribes_count').html($('.subscribes_count').html()-(unsubscribe?1:-1));
590                $('.btn_subsc').toggleClass('hidden');
591                $('.btn_unsubsc').toggleClass('hidden');
592            }
593        });
594    }
595    this.rate = function(id)
596    {
597        $.ajax({
598            url     : "/ajax/rate/"+id,
599            type    : 'GET'
600        });
601    }
602    this.fixBrokenMatImg = function(img)
603    {
604        if (!img || img.classList.contains('matimg--missing'))
605            return;
606        img.classList.add('matimg--missing');
607        var $img = $(img);
608        var $mat = $img.closest('.material');
609        var $row = $mat.parent('.itemrow');
610        var isCover = $row.length && (
611            ($row.is(':nth-child(odd)') && $mat.is(':first-child')) ||
612            ($row.is(':nth-child(even)') && $mat.is(':last-child'))
613        );
614        if (!isCover)
615            $img.closest('.matimgcont').addClass('matimgcont--noimg');
616        $mat.addClass('material--noimg');
617    }
618    this.fixBrokenArticleCover = function(img)
619    {
620        if (!img || img.classList.contains('article-cover--missing'))
621            return;
622        img.classList.add('article-cover--missing');
623        var wrap = img.closest('.articleimg');
624        if (wrap)
625            wrap.classList.add('articleimg--hidden');
626        else
627            img.style.display = 'none';
628    }
629    this.bindBrokenArticleCovers = function(root)
630    {
631        var $root = root ? $(root) : $(document);
632        $root.find('img.article-cover').each(function()
633        {
634            var img = this;
635            if (img.classList.contains('article-cover--missing'))
636                return;
637            if (img.complete && img.naturalWidth === 0)
638            {
639                steak.fixBrokenArticleCover(img);
640                return;
641            }
642            img.addEventListener('error', function onArticleCoverError()
643            {
644                img.removeEventListener('error', onArticleCoverError);
645                steak.fixBrokenArticleCover(img);
646            });
647        });
648    }
649    this.bindBrokenMatImgs = function(root)
650    {
651        var $root = root ? $(root) : $(document);
652        $root.find('img.matimg').each(function()
653        {
654            var img = this;
655            if (img.classList.contains('matimg--missing'))
656                return;
657            if (img.complete && img.naturalWidth === 0)
658            {
659                steak.fixBrokenMatImg(img);
660                return;
661            }
662            img.addEventListener('error', function onMatImgError()
663            {
664                img.removeEventListener('error', onMatImgError);
665                steak.fixBrokenMatImg(img);
666            });
667        });
668    }
669    
670}
671$(function()
672{
673    steak.bindBrokenMatImgs('#container');
674    steak.bindBrokenArticleCovers(document);
675});

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.