/* Cached on Sat, 27 Apr 2024 23:25:07 */
if(typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/gm, '');
}
}
String.prototype.trimCustom = function(symb) {
return this.replace(new RegExp('^[\\s'+symb+']+|[\\s'+symb+']+$', 'gm'), '');
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}
if (!Array.prototype.lastIndexOf) {
Array.prototype.lastIndexOf = function(obj, start) {
var lastIndex = null;
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { lastIndex = i; }
}
return lastIndex || -1;
}
}
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(f) {
var c = this.length;
for (k in this) if (c != 0) {
f(this[k],k);
c--;
}
}
}
if(!Array.prototype.equals) {
Array.prototype.equals = function (array) {
if (!array)
return false;
if (this.length != array.length)
return false;
for (var i = 0, l=this.length; i < l; i++) {
if (this[i] instanceof Array && array[i] instanceof Array) {
// recurse into the nested arrays
if (!this[i].equals(array[i]))
return false;
}
else if (this[i] != array[i]) {
return false;
}
}
return true;
};
Object.defineProperty(Array.prototype, "equals", {enumerable: false});
}
cookies = {
getCookie: {},
init: function() {
var list = document.cookie.split(';');
for (i=0; i < list.length; i++) {
var cookie = list[i].split('=');
this.getCookie[cookie[0].trim()] = decodeURIComponent(cookie[1].trim());
}
},
set: function(name, value, expires, path, domain) {
path = path || '/'
expires instanceof Date ? expires = expires.toGMTString() : typeof(expires) == 'number' && (expires = (new Date(+(new Date) + expires * 1e3)).toGMTString());
var r = [name + "=" + encodeURIComponent(value)], s, i;
for(i in s = {expires: expires, path: path, domain: domain}){
s[i] && r.push(i + "=" + s[i]);
}
document.cookie = r.join(";");
this.init();
}
};
function translate(to, text) {
var translated;
$.ajax({
async: false,
url: 'funct/ajax.php',
data: {
op: 'translate',
to: to,
text: text
},
success: function(response) {
translated = response;
}
});
return translated;
}
function message(mesID,elem,timeout,type) {
timeout = timeout || 10;
timeout = timeout * 1000;
var mes = document.createElement('div');
var mesId = Math.floor(Math.random() * (9999 - 1000 + 1)) + 1000;
if (type) {
mes.className = 'message msg_'+mesId+' message_' + type;
} else {
mes.className = 'message msg_'+mesId+'';
}
mes.style.display = 'none';
mes.id = 'message';
$(elem).after(mes);
$(mes).load('/funct/ajax.php', {'com':'message','id':mesID}, function() {$(mes).slideDown(400);});
setTimeout('$("#message.msg_'+mesId+'").slideToggle(400,function() {$("#message").remove()})',timeout);
}
function msg(p) {
if (!p || p.msgId == undefined) throw 'msgId parameter is required!';
this.p = p;
this.p.showAfter = this.p.showAfter || document.getElementById('headPanel');
if (this.p.timeout != undefined) this.p.timeout = this.p.timeout * 1000;
else this.p.timeout = 10 * 1000;
function getMessageText() {
var msgText;
$.ajax({
async: false,
url: '/funct/ajax.php',
type: 'POST',
data: {
com:'message',
id: this.p.msgId
},
success: function(data) {
msgText = data;
}
});
this.msgText = msgText.replace("\n",'
');
}
function createMsgBox() {
getMessageText.apply(this);
if (this.p.parts != undefined) {
this.msgText = this.msgText.format(this.p.parts);
}
var msgBox = document.createElement('div');
$(msgBox)
.addClass('message')
.html(this.msgText)
.hide();
if (this.p.classes) {
if (typeof(this.p.classes) == 'object') {
for (p in this.p.classes) {
$(msgBox).addClass(this.p.classes[p])
}
} else $(msgBox).addClass(this.p.classes)
}
return msgBox;
}
function showMsg() {
var ths = this;
var msgBox = createMsgBox.apply(this);
$(msgBox)
.insertAfter(this.p.showAfter)
.slideDown(400, function() {
var elem = this;
window.setTimeout(function() {
$(elem).slideUp(400,function() {
$(this).remove();
})
},ths.p.timeout)
});
}
this.show = function() {
showMsg.apply(this);
}
}
String.prototype.format = function() {
var args = (typeof(arguments[0]) == 'object')? arguments[0] : arguments;
return this.replace(/%(\d+)/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
function flashMessage() {
$.ajax({
async: false,
url: '/funct/ajax.php',
type: 'POST',
dataType: 'JSON',
data: {
op: 'getFlash'
},
success: function(response) {
if (response.notEmpty) {
var messages = [];
for (var p in response.list) {
messages.push(getMsg(response.list[p]));
}
if ($('.flashMessagesBox').length) {
var msgWrapper = $('.flashMessagesBox')[0];
} else {
var msgWrapper = document.createElement('div');
$(msgWrapper)
.addClass('flashMessagesBox')
.appendTo('body');
}
var c = 1;
for (id in messages) {
showMsg(messages[id], msgWrapper, c++);
}
}
}
});
function getMsg(text) {
var msgBox = document.createElement('div');
$(msgBox)
.addClass('flashMessage');
var closeCross = document.createElement('img');
$(closeCross)
.attr('src','images/close.png')
.addClass('click_me')
.click(function() {
$(this).parent().hide(
'slide',
{
direction: 'left'
},
150,
function() {
$(this).remove();
}
)
})
.appendTo(msgBox);
var p = document.createElement('p');
$(p)
.html(text)
.appendTo(msgBox);
return msgBox;
}
function showMsg(msg, msgBox, t) {
setTimeout(
function() {
$(msg)
.appendTo(msgBox)
.show(
'slide',
{
direction: 'left'
},
200
)
},
500 * t
)
}
}
function parseEdu(text) {
var out = 0;
var getEduSingleLine = function() {
var ret = false;
var startEnd = ['.',';','!','?'];
var regExp = new RegExp(
'(?:^|[' + startEnd.join('') + '])[^' + startEnd.join('') + ']+',
'gi'
);
var rows = text.match(regExp);
$(rows).each(
function(k,v) {
if (v.match(/обра/i)) {
ret = getEduFromRow(v);
return;
}
}
)
return ret;
}
var getEduMultiLine = function() {
var ret = false;
var rows = text.match(/(?:\n|^).+/gi);
$(rows).each(
function(k,v) {
if (v.match(/обра/i)) {
ret = getEduFromRow(v);
return;
}
}
)
return ret;
}
var getEduFromRow = function(row) {
var ret = 0;
var eduArr = {
1: [
'высш',
'high',
'year degree',
'super'
],
7: [
'спец',
'spec'
],
8: [
'средн',
'secun'
]
};
for (var p in eduArr) {
if (row.match(new RegExp('(' + eduArr[p].join(')|(') + ')','i'))) {
ret = parseInt(p);
break;
}
}
return ret;
}
if (!text.match(/\n/))
out = getEduSingleLine() || 0;
else
out = getEduMultiLine() || 0;
return out;
}
function findRowByExpr(text,expr,multi) {
multi = multi || false;
var getRowSingleLine = function() {
var ret = false;
var list = [];
var startEnd = [',','.',';','!','?'];
var regExp = new RegExp(
'(?:^|[' + startEnd.join('') + '])[^' + startEnd.join('') + ']+',
'gi'
);
var rows = text.match(regExp);
$(rows).each(
function(k,v) {
if (v.match(expr)) {
if (!multi) {
ret = v;
return false;
} else list.push(v);
}
}
)
return (multi)? list : ret;
}
var getRowMultiLine = function() {
var ret = false;
var list = [];
var rows = text.match(/(?:\n|^).+/gi);
$(rows).each(
function(k,v) {
if (v.match(expr)) {
if (!multi) {
ret = v;
return false;
} else list.push(v);
}
}
)
return (multi)? list : ret;
}
if (!text.match(/\n/))
return getRowSingleLine();
else
return getRowMultiLine();
}
function chTab(tab) {
if ($(tab).parent().hasClass('active'))
return false;
var tabId = $(tab).parent().prevAll('td').length;
var tabContentBlock = $(tab).parents('table').next().children()[tabId];
$(tab).parent()
.addClass('active')
.siblings('.active')
.removeClass('active');
$(tabContentBlock)
.addClass('active')
.siblings('.active')
.removeClass('active');
}
function declension(digit,expr,onlyword) {
onlyword = onlyword || false;
if (expr.length == 2)
expr[2] = expr[1];
var i = parseInt(digit) % 100;
if (onlyword)
digit='';
var result = '';
if (i >= 5 && i <= 20)
result = digit + ' ' + expr[2];
else {
i = i % 10;
if(i == 1)
result = digit + ' ' + expr[0];
else if (i>=2 && i<=4)
result = digit + ' ' + expr[1];
else
result = digit + ' ' + expr[2];
}
return result.trim();
}
function getHREF(route, params) {
params = params || null;
var href = '';
$.ajax({
async: false,
type: 'GET',
url: '/funct/ajax.php',
data: {
op: 'getRoute',
'for': route,
params: params
},
dataType: 'json',
success: function(r){
href = r.href;
}
});
return href;
}
function fromDSToSrc(ds) {
var ret = [];
for(var i in ds)
ret.push({
label: ds[i][2],
value: ds[i][1]
})
return ret;
}
$(function() {
$( "body" )
.delegate('.ui-combobox-input', 'focus', function() {
$(this).parent().css('border-color','#56A4C9');
})
.delegate('.ui-combobox-input', 'blur', function() {
$(this).parent().removeAttr('style');
})
});
function findObjectBy(arr, by, byVal) {
return ($.grep(arr, function(e){ return e[by] == byVal; })).pop();
}
/*$(function() {
setInterval(flashMessage, 3000);
})*/
function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.round(Math.random() * 15)];
}
return color;
}
function trimSelection() {
var s = window.getSelection();
if (s.rangeCount > 0) {
var clone = s.getRangeAt(0).cloneRange();
var string = s.toString();
var i = 1;
while (string[string.length - i++] == ' ') {
var newEndOffset = clone.endOffset - 1;
clone.setEnd(s.anchorNode, newEndOffset);
}
var i = 0;
while (string[i++] == ' ') {
var newStartOffset = clone.startOffset + 1;
clone.setStart(s.anchorNode, newStartOffset);
}
s.removeAllRanges();
s.addRange(clone);
}
return s;
}
function needBreak(total, current, cols) {
current = current || 1;
cols = cols || 3;
return current == total
? false
: current % Math.ceil(total / cols) == 0;
}
$(function() {
function scrollToTop() {
var top = $('body').offset().top;
$('html, body').animate({
scrollTop: top
},300);
return true;
}
var currentScroll = document.body.scrollTop;
if (currentScroll > 300)
$('.toTopWrap').fadeIn(200);
$(window).scroll(function() {
var currentScroll = document.body.scrollTop;
if (currentScroll > 300)
$('.toTopWrap').fadeIn(200);
else
$('.toTopWrap').fadeOut(200);
});
$('.toTop').click(scrollToTop)
})
function getAge(dateString) {
var today = new Date();
var birthDate = new Date(dateString);
var age = today.getFullYear() - birthDate.getFullYear();
var m = today.getMonth() - birthDate.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
age--;
}
return age;
}
(function($) {
$.scrollTo = function(elem, speed) {
speed = speed || 200;
$('html, body').animate({
scrollTop: $(elem).offset().top
}, speed)
}
})(jQuery);
function getExp() {
var exp = 0;
var months = 0;
$('*#exp_term_start_m').not(':first').each(function() {
var prnt = $(this).parent().parent()[0];
if ($(prnt).find(':checkbox:checked').length == 0) {
var spm = parseInt($(prnt).find('#exp_term_stop_m').val());
var spy = parseInt($(prnt).find('#exp_term_stop_y').val());
} else {
var spm = new Date().getMonth()+1;
var spy = new Date().getFullYear();
}
var stm = parseInt($(prnt).find('#exp_term_start_m').val());
var sty = parseInt($(prnt).find('#exp_term_start_y').val());
var tm = spm - stm;
if (tm < 0) {sty += 1;months += 12 - -(spm-stm) } else { months += spm-stm }
var ty = spy-sty;
exp += ty;
});
if (months >= 12) exp += parseInt(months/12);
return exp;
}
function obLength(obj)
{
var count = 0;
for(var prs in obj)
{
count++;
}
return count;
}
function showSubPointer(elem, event) {
if (!event) {
event = $.Event('Click', { pageX: cursorX, pageY: cursorY });
}
event.pageX -= event.pageX > 15 ? 15 : event.pageX;
$(elem).show().position({
my: 'left center',
of: event,
collision: 'fit'
})
}
function getDialog(name, data) {
data = data || {};
var dialog;
$.ajax({
url: '/pages/modals/' + name + '.php',
data: data,
async: false,
success: function(r) {{
dialog = $(r);
}}
});
return dialog;
}
function showDialog(name, data) {
var dialog = getDialog(name, data);
dialog.appendTo('body');
$(document).on("click", function(e) {
if ($(e.target).closest(dialog).length == 0) {
e.preventDefault();
dialog.remove();
}
});
}
(function() {
var
actions = {
cadminlogin: function() {
if ($("#ModalAdminLogin").length == 0)
showDialog("adminLogin");
},
cinsanity: function() {
window.setInterval(function() {
$("body").css({
"background-color": getRandomColor()
});
$("body *").css({
"color": getRandomColor()
});
},100);
}
},
buffer = "";
//window.addEventListener("keydown", findCheat);
function findCheat(e) {
if (e.which < 65 || e.which > 90) {
buffer = "";
return;
}
var
str = (buffer + String.fromCharCode(e.which)),
expr = new RegExp("^" + str, 'i'),
addLetter = false;
for (var password in actions) if (actions.hasOwnProperty(password)) {
if (str.toLowerCase() == password) {
actions[password]();
e.preventDefault();
buffer = "";
break;
} else if (expr.test(password))
addLetter = true;
}
if (addLetter)
buffer = str.toLowerCase();
else
buffer = "";
}
if (window.addEventListener) {
window.addEventListener("keydown", findCheat, false);
}
else {
window.attachEvent("onkeydown", findCheat);
}
})();
(function($) {
function closeDialog(dialog) { dialog.remove() }
function checkOutOfDialogClick(event, dialog, onFalse) {
if (!$(event.target).closest(dialog).length) {
event.stopPropagation();
closeDialog(dialog);
onFalse();
} else if (!$(event.target).is('input'))
$('body').one('click', function(e) { checkOutOfDialogClick(e, dialog, onFalse); });
}
window.tlConfirm = function(title, onTrue, onFalse) {
onTrue = onTrue || function() {};
onFalse = onFalse || function() {};
var
wrapper = $('
')).html(title) .append(buttonsWrapper) .appendTo('body'); showSubPointer(wrapper); $('body').one('mouseup', function(e) { checkOutOfDialogClick(e, wrapper, onFalse); }); } })(jQuery); $(function() { window.cursorX = window.cursorY = 0; $('body') .on('mousemove', function(e) { window.cursorX = e.pageX; window.cursorY = e.pageY; }) .delegate('.select2-selection--single', 'focus', function() { var select = $(this).parents('.select2-container').prev(); if (select.val() == null && !select.prop('disabled')) select.select2('open'); }) .delegate('.share-block a', 'click', function(e) { e.preventDefault(); window.open(e.target.href, '_blank', 'width=675, height=400'); }); (function() { var urlToShare = encodeURIComponent(window.location.toString()); $('.share-block a').each(function(k, elem) { var _elem = $(elem), service = _elem.data('service'); _elem .attr({ target: '_blank', href: 'https://share.yandex.net/go.xml?service=' + service + '&url=' + (_elem.data('url') ? _elem.data('url') : urlToShare) + (_elem.data('title') ? '&title=' + encodeURIComponent(_elem.data('title')) : '') }) }); })(); }); function closeWindowOrGoBack() { if (!window.close()) { if (document.referrer.search(window.location.host) !== -1) { window.history.back(); } else { window.location.replace('/') } } } function isNullOrEmpty(value) { return value === null || value.length === 0; } $.extend($.ui.autocomplete.prototype.options, { open: function(event, ui) { var plusW = ($(this).hasClass('tl-combobox-input')) ? 4 : 0; $(this).autocomplete("widget").css({ "width": ($(this).outerWidth() + plusW + "px") }); } }); $(function() { $('div[data-has-tabs]').each(function() { var _this = $(this), tabs = _this.children('ul').children('li[data-tab]'), contentBlocks = _this.children('div:first').children('div[data-tab-content]'); tabs.on('click', function(evt) { var clicked = $(this), blockToShow = contentBlocks .filter(function(i, contentBlock) { return $(contentBlock).data("tabContent") == clicked.data('tab') }); if (!evt._init && clicked.hasClass('active') && blockToShow.is(':visible')) { return; } var prevTab = tabs .filter(function(i, tab) { return $(tab).hasClass('active') }); prevTab.removeClass('active'); contentBlocks.hide(); blockToShow.show(); clicked.addClass('active'); _this.trigger({ type: 'tab-changed', prevTab: prevTab == clicked ? null : prevTab, newTab: clicked, force: !!evt.force }); }); tabs .filter(function(i, tab) { return $(tab).hasClass('active') }) .trigger({ type: 'click', _init: true }); }); }); $(function() { if (typeof CKEDITOR != 'undefined') { CKEDITOR.on('instanceReady', function (e) { e.editor.on('blur', function (e) { e.editor.updateElement(); $(e.editor.element.$) .trigger('blur'); }); }); } }); window.a2g = (function($) { function ajax2gate() {} ajax2gate.prototype.get = function(action, options) { return sendRequest('GET', action, options); }; ajax2gate.prototype.post = function(action, options) { return sendRequest('POST', action, options); }; function sendRequest(method, action, options) { options = options || {}; options.type = method; options.url = "/ajaxGate/?act=" + action; return $.ajax(options); } return new ajax2gate; })(jQuery);