var framework = function ()
{
var t = this;
this.get = function(dt, succ, send, compl, err, a)
{
switch(typeof dt)
{
case 'string':
dg = dt;
dp='';
break;
case 'object':
dg = dt.g;
dp = dt.p+'&';
break;
}
dp+='__k='+__k;
$.ajax({
url: dg,
type: 'POST',
data: dp,
dataType: 'JSON',
timeout: 30000,
beforeSend: function(){
if(send && $.isFunction(send)) send();
},
complete: function(){
if(compl)eval(compl+'();');
},
success: function(response){
if(succ){
var data = response;
if(succ && $.isFunction(succ)) succ(data);
}
},
error: function(response){
if(response&&response.responseText&&(response.responseText=='tohome'||response.responseText.indexOf('Just a moment...')!=-1))top.location.href='/';
if(err && $.isFunction(err)) err(response)
else alert('Error!');
return false;
}
});
}
this.encode = function(s) {return encodeURIComponent(s);}
this.note = function(m,i,t){
var svgshape = document.getElementById('notification-shape'),s = Snap(svgshape.querySelector('svg')),path = s.select('path'),
pathConfig = {
from: path.attr('d'),
to: svgshape.getAttribute('data-path-to')
}
if(!i)i='exclamation-triangle';
if(!t)t='notice';
$(svgshape).show()
path.animate({'path': pathConfig.to}, 300, mina.easeinout);
$(svgshape).removeClass('path-error').addClass('path-'+t)
var notification = new NotificationFx({
ttl: 10000,
wrapper: svgshape,
message: '
'+m+'
',
layout: 'other',
effect: 'cornerexpand',
type: t, // notice, warning or error
onClose: function () {
setTimeout(function () {
path.animate({'path': pathConfig.from}, 300, mina.easeinout);
}, 200);
}
});
// show the notification
notification.show();
}
this.rand = function(min_random, max_random)
{
var range = max_random - min_random + 1;
return Math.floor(Math.random()*range) + min_random;
}
this.pass = function(n)
{
return Math.random().toString(36).slice(2, 2 + Math.max(1, Math.min(n, 10)) );
}
this.copy = function(t)
{
t=t.get(0)
var range = document.createRange();
range.selectNode(t);
window.getSelection().addRange(range);
document.execCommand('copy');
window.getSelection().removeAllRanges();
}
this.set_ge = function(ge){
t.ge = ge;
}
this.number_format=function( number, decimals, dec_point, thousands_sep ) {
var i, j, kw, kd, km;
if( isNaN(decimals = Math.abs(decimals)) ){
decimals = 2;
}
if( dec_point == undefined ){
dec_point = ",";
}
if( thousands_sep == undefined ){
thousands_sep = ".";
}
i = parseInt(number = (+number || 0).toFixed(decimals)) + "";
if( (j = i.length) > 3 )j = j % 3;
else j = 0;
km = (j ? i.substr(0, j) + thousands_sep : "");
kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
//kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : "");
kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");
return km + kw + kd;
}
}
var F = new framework();
(function($, F){
//get id
$.fn.getid = function(s){
if(!$(this).length||!$(this).attr('id'))return 0;
if(s)return $(this).attr('id').replace(s, '');
return parseInt($(this).attr('id').replace(/\D/g, ''));
};
//trim
$.fn.trim = function(s){
return s.replace( /^\s+/, '').replace( /\s+$/, '');
};
$.fn.ialert = function(s,t){
return $(this).html(s?''+s+'
':'')
};
$.fn.getform = function(o,nd){
var s='';
if(!o)o={}
$(this).find('input, select, textarea').each(function(){
var t=$(this),v=$.trim(t.val())
if(('break' in o) && o.break==v)return;
var n=t.attr('name');
if(!n||n=='')return;
if(('disabled' in o) && t.prop('disabled'))return;
switch(t.attr('type'))
{
case 'radio':case 'checkbox':
if(t.prop('checked')) s += (s==''?'':'&')+n+'='+encodeURIComponent(v)
break;
default:
s += (s==''?'':'&')+n+'='+encodeURIComponent(v)
}
})
return s;
};
$.fn.page = function(g,p,f,e){
var t=$(this).show(),h=t.height();
if(e===1||(!e&&$.trim(t.html())==''))e='@
';
if(t.find('.loader').length||$('.superloading').hasClass('act')) return false;
if(e)t.html(e.replace('@', 'Loading...'));
else t.loading(1);
//t.html('')
//return t;
F.get({g:g,p:p},function(d){
t.loading(0);
if(d.err){
if(e) t.html(e.replace('@',d.err))
else t.ialert(d.err, 'danger')
}else t.html(d.html)
if(f)f()
F.ge.set()
},0,0,function(){
t.loading(0);
})
return t;
}
$.fn.loading = function(a){
var t=$(this),b=$('.superloading')
if(!t.length)return;
if(!a)
{
b.hide().removeClass('act');
return t;
}
var p=t.offset()
var w=t.css('width'),h=t.css('height');
if(t.hasClass('pload')){
w=(parseInt(w)-20)+'px';
h=(parseInt(h)-20)+'px';
//p.top=(parseInt(p.top)+10)+'px';
p.left=(parseInt(p.left)+11)+'px';
}
b.css({width:w,height:h,top:p.top,left:p.left}).show().addClass('act')
return t;
}
$.fn.go = function(){
var t=$(this)
if(t.length==1) $("html, body").animate({scrollTop: t.offset().top}, 600);
return t
}
$.fn.keyboard = function(f,sf,lg){
var t=$(this).show(),p,s,h=$('');
//t.html('')
if(!sf)sf=0
if(!lg)lg=0
a=['1','2','3','4','5','6','7','8','9','0','br',
'q|й','w|ц','e|у','r|к','t|е','y|н','u|г','i|ш','o|щ','p|з','|х','|ъ','br',
'a|ф','s|ы','d|в','f|а','g|п','h|р','j|о','k|л','l|д','|ж','|э','br',
'z|я','x|ч','c|с','v|м','b|и','n|т','m|ь','|б','|ю','br',
'(',')','-','+','=','*','&','?','!','/',':',';',',','.','br',
'SHIFT','SPACER','LANG'];
$.each(a,function(i,v){
v=v.split('|');
if(v.length==1){
v=v[0]
if(v=='LANG')v=lg?'EN':'RU'
}else {
v=v[lg]
if(sf)v=v.toUpperCase()
}
if(v=='')p='';
else if(v=='br')p='
';
else {
s='default';
if(v=='SHIFT'){
v=''
if(sf)s='danger'
}
p=$('');
p.click(function(e){
//e.preventDefault();
var v=$(this);
//alert(v)
if(v.find('i').length)t.keyboard(f,!sf,lg);
else {
v=v.html()
if(v=='RU'||v=='EN')t.keyboard(f,sf,lg?0:1);
else {
if(v=='SPACER')v=' ';
var z=/[\?\!\.]/.test(v),p=/[\,\-\)\:\;]/.test(v)//,f=$('input:focus,textarea:focus');
if(z||p)v+=' '
if(f.length)f.curset(v).keypress().keyup()
if(sf||z)t.keyboard(f,!sf,lg);
}
}
return false;
})
}
h.append(p)
f.returnRange()
})
t.html(h)
}
$.fn.returnRange = function()
{
var o=$(this).get(0)
if ((o.selectionStart)||(o.selectionStart=='0'))
{
o.focus()
o.setSelectionRange(o.selectionStart,o.selectionEnd)
}
}
$.fn.curget = function() {
var e=$(this).get(0)
return (
/* mozilla / dom 3.0 */
('selectionStart' in e && function() {
var l = e.selectionEnd - e.selectionStart;
return { start: e.selectionStart, end: e.selectionEnd, length: l, text: e.value.substr(e.selectionStart, l) };
}) ||
/* exploder */
(document.selection && function() {
e.focus();
var r = document.selection.createRange();
if (r === null) {
return { start: 0, end: e.value.length, length: 0 }
}
var re = e.createTextRange();
var rc = re.duplicate();
re.moveToBookmark(r.getBookmark());
rc.setEndPoint('EndToStart', re);
return { start: rc.text.length, end: rc.text.length + r.text.length, length: r.text.length, text: r.text };
}) ||
/* browser not supported */
function() { return null; }
)();
}
$.fn.curset = function(_text)
{
var o=$(this).get(0)
// Mozilla и другие НОРМАЛЬНЫЕ браузеры
if ((o.selectionStart)||(o.selectionStart=='0'))
{ // определяем, где начало выделения, если оно существует
var p_start=o.selectionStart;
// определяем, где заканчивается выдедение, если оно существует
var p_end=o.selectionEnd;
// вставляем соответствующий текст в указанное место
o.value=o.value.substring(0,p_start)+_text+o.value.substring(p_end,o.value.length);
var cur=p_start+_text.length
o.focus()
o.setSelectionRange(cur,cur)
}
// Исправляем очередной геморрой с Internet Explorer
// единственный НЕ человеческий браузер
if (document.selection)// если объект может иметь выделения
{ // передаем фокус ввода на нужный нам объект
o.focus();
// узнаем выделение, если оно существует
var s=document.selection.createRange();
// вставляет текст в указанное место
s.text=_text;
}
return this;
}
$.fn.sure = function(f,o,c)
{
var t=$(this)
if(t.next().hasClass('sure')) return t.next().find('small:first').click()
var s=$('Yes!No.')
t.attr('disabled', true).after(s);
if(o&&o.type=='alert')o.b.ialert(o.s,o.t)
s.find('small').click(function(){
t.attr('disabled', false)
s.remove()
if(o&&o.type=='alert')o.b.ialert()
if($(this).next().length)f(t);
else if(c)c(t);
})
return false;
}
$.fn.etr = function(o,n){
$(this).keyup(function(e){
if(e.keyCode=='13')o($(this))
else if(e.keyCode=='27')n($(this))
return this;
})
}
})(jQuery, F);
// Math.+
(function() {
function decimalAdjust(type, value, exp) {
if (typeof exp === 'undefined' || +exp === 0) {
return Math[type](value);
}
value = +value;
exp = +exp;
if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0)) {
return NaN;
}
value = value.toString().split('e');
value = Math[type](+(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp)));
value = value.toString().split('e');
return +(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp));
}
if (!Math.round10) {
Math.round10 = function(value, exp) {
return decimalAdjust('round', value, exp);
};
}
if (!Math.floor10) {
Math.floor10 = function(value, exp) {
return decimalAdjust('floor', value, exp);
};
}
if (!Math.ceil10) {
Math.ceil10 = function(value, exp) {
return decimalAdjust('ceil', value, exp);
};
}
})();
var PB='';