PageSourceSearch

https://dota2lounge.com/scripts/scripts.js?1655477481

js dota2lounge.com collected 2026-10-02 05:12:52 UTC 16,269 bytes, 541 lines download raw bytes

1// TODO delete it?
2function Ending($value, $a, $b, $c) {
3	$value = $value % 100;
4	if($value < 20 && $value > 10)
5		return $c;
6	$value = $value %10;
7	if($value == 1)
8		return $a;
9	if($value < 5 && $value > 1)
10		return $b;
11	return $c	;
12}
13
14function getCookie(c_name)  {
15    var i,x,y,ARRcookies=document.cookie.split(";");
16
17    for (i=0; i<ARRcookies.length; i++)
18    {
19        x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
20        y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
21        x=x.replace(/^\s+|\s+$/g,"");
22
23        if (x == c_name) {
24            return unescape(y);
25        }
26    }
27
28	return false;
29}
30
31function setCookie(c_name, value, exdays, exstime) {
32    var exdate = new Date();
33
34    if (typeof exdays !== 'undefined' && exdays > 0) {
35        exdate.setDate(exdate.getDate() + exdays);
36    }
37    else if (typeof exstime !== 'undefined' && exstime > 0) {
38        exdate.setTime(exdate.getTime() + exstime);
39    }
40    else {
41        return;
42    }
43
44    var c_value = escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()) + "; path=/";
45    document.cookie = c_name + "=" + c_value;
46
47	// and expire page cookie
48	if ((document.location.host != "localhost")&&(document.location.pathname != "/")){
49	    var c_value = escape(value) + ";expires=Thu, 01 Jan 1970 00:00:01 GMT; path="+document.location.pathname;
50	    document.cookie = c_name + "=" + c_value;
51	}
52}
53
54function isMobile() {
55    if (navigator.userAgent.match(/Android/i)
56	|| navigator.userAgent.match(/webOS/i)
57	|| navigator.userAgent.match(/iPhone/i)
58	|| navigator.userAgent.match(/iPad/i)
59	|| navigator.userAgent.match(/iPod/i)
60	|| navigator.userAgent.match(/BlackBerry/i)
61	|| navigator.userAgent.match(/Windows Phone/i)
62	|| navigator.userAgent.match(/Opera Mini/i)
63	|| navigator.userAgent.match(/IEMobile/i)
64	)
65    { return true; }
66    else{return false}
67}
68
69jQuery.fn.mouseIsOver = function () {
70    if($(this[0]).is(":hover"))
71    {
72        return true;
73    }
74    return false;
75};
76
77function htmlspecialchars_decode (string, quote_style) {
78  // From: http://phpjs.org/functions
79  // +   original by: Mirek Slugen
80  // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
81  // +   bugfixed by: Mateusz "loonquawl" Zalega
82  // +      input by: ReverseSyntax
83  // +      input by: Slawomir Kaniecki
84  // +      input by: Scott Cariss
85  // +      input by: Francois
86  // +   bugfixed by: Onno Marsman
87  // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
88  // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
89  // +      input by: Ratheous
90  // +      input by: Mailfaker (http://www.weedem.fr/)
91  // +      reimplemented by: Brett Zamir (http://brett-zamir.me)
92  // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
93  // *     example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');
94  // *     returns 1: '<p>this -> &quot;</p>'
95  // *     example 2: htmlspecialchars_decode("&amp;quot;");
96  // *     returns 2: '&quot;'
97  var optTemp = 0,
98    i = 0,
99    noquotes = false;
100  if (typeof quote_style === 'undefined') {
101    quote_style = 2;
102  }
103  string = string.toString().replace(/&lt;/g, '<').replace(/&gt;/g, '>');
104  var OPTS = {
105    'ENT_NOQUOTES': 0,
106    'ENT_HTML_QUOTE_SINGLE': 1,
107    'ENT_HTML_QUOTE_DOUBLE': 2,
108    'ENT_COMPAT': 2,
109    'ENT_QUOTES': 3,
110    'ENT_IGNORE': 4
111  };
112  if (quote_style === 0) {
113    noquotes = true;
114  }
115  if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags
116    quote_style = [].concat(quote_style);
117    for (i = 0; i < quote_style.length; i++) {
118      // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4
119      if (OPTS[quote_style[i]] === 0) {
120        noquotes = true;
121      } else if (OPTS[quote_style[i]]) {
122        optTemp = optTemp | OPTS[quote_style[i]];
123      }
124    }
125    quote_style = optTemp;
126  }
127  if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) {
128    string = string.replace(/&#0*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should
129    // string = string.replace(/&apos;|&#x0*27;/g, "'"); // This would also be useful here, but not a part of PHP
130  }
131  if (!noquotes) {
132    string = string.replace(/&quot;/g, '"');
133  }
134  // Put this in last place to avoid escape being double-decoded
135  string = string.replace(/&amp;/g, '&');
136
137  return string;
138}
139
140////////////////////////////////////////////////////////////////////////////
141
142function removeCfParamsFromUrl(url) {
143    var paramsArr = url.split('?');
144
145    url = paramsArr[0];
146
147    if (typeof paramsArr[1] === 'undefined' || !paramsArr[1].length) {
148        return url;
149    }
150
151    var getParams = paramsArr[1];
152    var newGetParamsArr = [];
153
154    getParams.split('&').forEach(function (e) {
155        if(e.indexOf('__cf_chl_jschl_tk__') === -1) {
156            newGetParamsArr.push(e);
157        }
158    });
159
160    if (newGetParamsArr.length) {
161        url += newGetParamsArr.join('&')
162    }
163
164    return url;
165}
166
167var _dt = {
168    abbrs : {
169        '-1200': 'Etc/Gmt+12', '-1100': 'Etc/Gmt+11', '-1000': 'Etc/Gmt+10', '-0900': 'Etc/Gmt+9',
170        '-0800': 'Etc/Gmt+8', '-0700': 'Etc/Gmt+7', '-0600': 'Etc/Gmt+6', '-0500': 'Etc/Gmt+5',
171        '-0400': 'Etc/Gmt+4', '-0300': 'Etc/Gmt+3', '-0200': 'Etc/Gmt+2', '-0100': 'Etc/Gmt+1',
172        '-0000': 'Etc/Gmt+0', '+0100': 'Etc/Gmt-1', '+0200': 'Etc/Gmt-2', '+0300': 'Etc/Gmt-3',
173        '+0400': 'Etc/Gmt-4', '+0500': 'Etc/Gmt-5', '+0600': 'Etc/Gmt-6', '+0700': 'Etc/Gmt-7',
174        '+0800': 'Etc/Gmt-8', '+0900': 'Etc/Gmt-9', '+1000': 'Etc/Gmt-10', '+1100': 'Etc/Gmt-11',
175        '+1200': 'Etc/Gmt-12', '+1300': 'Etc/Gmt-13', '+1400': 'Etc/Gmt-14'
176    },
177    zone : null,
178    serverTime : null,
179    serverDivergence: 0,
180    init : function () {
181        if ((typeof USER_TIMEZONE_OFFSET === 'undefined' || USER_TIMEZONE_OFFSET === '')) {
182            USER_TIMEZONE_OFFSET = moment.tz(moment.tz.guess()).format('ZZ');
183            this.setServerZone(USER_TIMEZONE_OFFSET);
184        }
185        this.zone = this.getZoneByOffset(USER_TIMEZONE_OFFSET);
186        setCookie("timezone", USER_TIMEZONE_OFFSET, 365);
187
188        this.getServerTime();
189    },
190    setZone : function (zoneOffset){
191        this.zone = this.getZoneByOffset(zoneOffset);
192        setCookie("timezone", zoneOffset, 365);
193
194        if (typeof _bets === 'undefined') { // Main page
195            location.href = removeCfParamsFromUrl(location.href);
196            return false;
197        }
198
199        updateBetsDate();
200        return this;
201    },
202    setServerZone : function (zoneOffset) {
203        $("#loading_img").show("slow");
204
205        zoneOffset = zoneOffset.slice(0, -2) + '00';
206
207        $.ajax(RELATIVE_PATH + "index/save_timezone/" + GetSessionToken + "/?timezone=" + encodeURIComponent(zoneOffset))
208            .done(function(msg) {
209                try {
210                    var res = JSON.parse(msg);
211                    if (!res.success) {
212                        if (res.error) {
213                            alert(res.error);
214                        } else {
215                            alert(Lang("Ошибка сохранения часового пояса"));
216                        }
217                    } else {
218                        _dt.setZone(zoneOffset);
219                        $("#sys-timerange-timezone").html('UTC' + _dt.getZoneFormat('Z'));
220                        $('.sys-user-timezone-item[data-value="' + zoneOffset + '"]').addClass('active');
221                    }
222                } catch (e) {
223                    if (msg !== ""){
224                        alert(e + msg);
225                    }
226                }
227            })
228            .fail(function(jqXHR, textStatus) {
229                if (isLangKey('Произошла ошибка: :error')) {
230                    alert(Lang('Произошла ошибка: :error', {error: textStatus}));
231                } else {
232                    //alert(textStatus)
233                }
234            })
235            .always(function() {
236                $("#loading_img").hide("fast");
237            })
238        ;
239    },
240    getZoneByOffset : function (offset) {
241        if (typeof this.abbrs[offset] !== 'undefined') {
242            return this.abbrs[offset];
243        }
244
245        return 'Etc/Gmt-3';
246    },
247    getZoneFormat : function (format) {
248        return moment.tz(this.zone).format(format);
249    },
250    getServerTime : function () {
251        var self = this;
252
253        if (typeof SERVER_TIME !== 'undefined') {
254            self.serverTime = SERVER_TIME*1000;
255            setInterval( function(){self.incrementServerTime();}, 1000);
256            return;
257        }
258
259        if (typeof RELATIVE_PATH === 'undefined')
260            return;
261
262        var load_url = RELATIVE_PATH+"index/gtime/";
263        loader=$.ajax(load_url)
264            .done(function(data){
265                self.serverTime = data*1000;
266                setInterval( function(){self.incrementServerTime();}, 1000);
267            })
268            .fail(function(){
269                return false;
270            });
271    },
272    incrementServerTime : function(){
273        if (this.serverTime){
274            this.serverTime += 1000;
275        }
276    },
277    getDate : function(time, format){
278        var date = moment(new Date(time*1000));
279
280        if (typeof format === 'undefined')
281            format = "DD.MM";
282
283        return date.tz(this.zone).format(format);
284    },
285    getTime : function(time){
286        var date = moment(new Date(time*1000));
287        return date.tz(this.zone).format("H:mm");
288    },
289    getFormatedDate : function(time, format){
290        var date = moment(new Date(time*1000));
291
292        return date.tz(this.zone).format(format);
293    },
294    timestampToLeftString: function(time){
295        if (!this.serverTime)
296            return '';
297
298        var now  = moment(this.serverTime);
299        time = moment(new Date(time*1000));
300
301        if (now+50 > time) {
302            if (isLangKey("Скоро старт")) {
303                return Lang("Скоро старт");
304            }
305            if (typeof CURRENT_LOCALE !== 'undefined' && CURRENT_LOCALE === 'ru') {
306                return "Скоро старт";
307            } else {
308                return "Coming soon";
309            }
310        }
311
312        var difference = moment.utc(time.diff(now));
313        var days =  parseInt(difference.format("D"))-1;
314        var hours = parseInt(difference.format("H"));
315
316        if (typeof CURRENT_LOCALE !== 'undefined' && CURRENT_LOCALE === 'ru')
317            return (days?days+'д':'')+ " " + (hours?hours+'ч':'') + " " + (days?'':difference.format("mm")+'м');
318        else
319            return (days?days+'d':'')+ " " + (hours?hours+'h':'') + " " + (days?'':difference.format("mm")+'m');
320    },
321    timestampLeft: function(time) {
322        var now  = moment(this.serverTime);
323        time = moment(new Date(time*1000));
324        return time.diff(now);
325    }
326};
327_dt.init();
328
329////////////////////////////////////////////////////////////////////////////
330
331function makeTeamCharts(container, options, theme) {
332    var defaultOptions = {
333        "type": "serial",
334        "theme": theme,
335        "marginTop":0,
336        "marginRight": 80,
337        "dataProvider": null,
338        "valueAxes": [{
339            "axisAlpha": 0,
340            "position": "left"
341        }],
342        "graphs": [{
343            "id":"g1",
344            "balloonText": "",
345            "bullet": "round",
346            "bulletSize": 8,
347            "lineColor": "#d1655d",
348            "lineThickness": 2,
349            "negativeLineColor": "#637bb6",
350            "type": "smoothedLine",
351            "valueField": "value"
352        }],
353        "chartScrollbar": {
354            "graph":"g1",
355            "gridAlpha":0,
356            "color":"#888888",
357            "scrollbarHeight":40,
358            "backgroundAlpha":0.05,
359            "selectedBackgroundAlpha":0.1,
360            "selectedBackgroundColor":"#888888",
361            "graphFillAlpha":0,
362            "autoGridCount":false,
363            "selectedGraphFillAlpha":0,
364            "graphLineAlpha":0.3,
365            "graphLineColor":"#c2c2c2",
366            "selectedGraphLineColor":"#888888",
367            "selectedGraphLineAlpha":1
368        },
369        "chartCursor": {
370            "cursorAlpha": 0,
371            "valueLineEnabled":true,
372            "valueLineBalloonEnabled":true,
373            "valueLineAlpha":0.5,
374            "fullWidth":true
375        },
376        "categoryField": "date",
377        "categoryAxis": {
378            "minPeriod": "M",
379            "minorGridAlpha": 0.1,
380            "minorGridEnabled": true
381        },
382        "export": {
383            "enabled": true
384        },
385        "listeners": [{
386            "event": "rendered",
387            "method": zoomChart
388        }]
389    };
390
391    options = objectDeepExtend(defaultOptions, options);
392
393    function zoomChart (e) {
394        var length = e.chart.chartData.length;
395        if (length > 10) {
396            e.chart.zoomToIndexes(Math.round(length * 0.7), Math.round(length));
397        } else {
398            e.chart.zoomToIndexes(0, length);
399        }
400    }
401
402    return AmCharts.makeChart(container, options);
403}
404
405function objectDeepExtend(obj, ext) {
406    var typeObj = Object.prototype.toString.call(obj).split(/\W/)[2];
407    for (item in obj) {
408        if (!obj.hasOwnProperty(item)) {
409            continue;
410        }
411
412        var typeItem = Object.prototype.toString.call(obj[item]).split(/\W/)[2];
413        if (typeItem === 'Array' || typeItem === 'Object') {
414            if (ext.hasOwnProperty(item)) {
415                ext[item] = objectDeepExtend(obj[item], ext[item]);
416            }
417        }
418    }
419
420    if (typeObj === 'Object') {
421        $.extend(obj, ext);
422    }
423
424    return obj;
425}
426
427////////////////////////////////////////////////////////////////////////////
428
429var userTZ = {
430  items: null,
431  init: function () {
432    this.items = $('.sys-user-timezone-item');
433    this.bind();
434  },
435  bind: function () {
436    var self = this;
437    this.items.on('click', function () {
438      self.items.removeClass('active');
439      $e = $(this);
440      $e.addClass('active');
441      self.ajax($e.data('value'));
442    });
443  },
444  ajax: function (timezone) {
445    _dt.setServerZone(timezone);
446  }
447};
448
449$(function () {
450  userTZ.init();
451
452  setInterval(function () {
453    var date = moment(new Date()).tz(_dt.zone);
454    $('.sys-current-time').text(date.format('H:mm'));
455  }, 1000);
456});
457
458////////////////////////////////////////////////////////////////////////////
459
460Tabs = {
461
462    selector: null,
463    wrap: null,
464    tabs: null,
465    items: null,
466
467    init: function ($e) {
468        var wrap = $e.parents('[data-tab-wrapper]').first();
469        var selector = wrap.data('tab-wrapper');
470
471        if (selector === this.selector) {
472            return false;
473        }
474
475        this.wrap = wrap;
476        this.tabs = this.wrap.find('.sys-tab-item');
477        this.items = this.wrap.find('.sys-tab-content');
478        this.selector = selector;
479
480        return true;
481    },
482
483    showTab: function (e) {
484        var $e = $(e);
485        this.init($e);
486        var target = $e.data('target');
487
488        if (this.items.filter('[data-tab="' + target + '"]').html()) {
489            this.toggleTab(target);
490            return true;
491        }
492    },
493
494    toggleTab: function (target) {
495        this.tabs.removeClass('active');
496        this.tabs.filter('[data-target="' + target + '"]').addClass('active');
497
498        this.items.removeClass('active');
499        this.items.filter('[data-tab="' + target + '"]').addClass('active');
500    }
501};
502
503LANGS = {
504    items: {},
505
506    add: function (items) {
507        if ($.isEmptyObject(this.items)) {
508            this.items = items;
509        } else {
510            $.extend(this.items, items);
511        }
512    },
513
514    get: function (key, replace) {
515        if (this.isset(key)) {
516            if (typeof replace === 'object') {
517                var lang = this.items[key];
518                for (item in replace) {
519                    lang = lang.replace(':' + item, replace[item]);
520                }
521                return lang;
522            } else {
523                return this.items[key];
524            }
525        }
526
527        return key;
528    },
529
530    isset: function (key) {
531        return !(typeof this.items !== "object" || typeof this.items[key] !== 'string');
532    }
533};
534
535function Lang(key, replace) {
536    return LANGS.get(key, replace);
537}
538
539function isLangKey(key) {
540    return LANGS.isset(key);
541}

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.