url = window.location.href;
folder_name = $('body').data('folder');
debugging = ($('body').data('debugging') == 'n' ? false : true);
$(document).ready(function () {
var current_time = new Date();
year = current_time.getFullYear();
month = ((current_time.getMonth() + 1) < 10 ? '0' : '') + (current_time.getMonth() + 1);
day = (current_time.getDate() < 10 ? '0' : '') + current_time.getDate();
});
function open_newtab(n) { var o = window.open(n, "_blank"); o.focus() }
function format_number(digits,decimal=0){return $.number(digits,decimal,',',' ')}
function select_firstfield() { $("input").each(function () { if ("" === this.value) return this.select(), !1 }) }
function msg(string, type, class_el) {
var arr_types = {
'error': {
'icon': svgicon('msg-warning'),
'color': 'red'
},
'info': {
'icon': svgicon('msg-information'),
'color': 'blue'
},
'wait': {
'icon': svgicon('msg-waiting'),
'color': 'blue'
},
'done': {
'icon': svgicon('msg-done'),
'color': 'green'
}
};
if($('.msg > div').length == 0) {
d = document.createElement('div');
$(d).appendTo('.msg');
}
$('.msg').show();
$('.msg' + (class_el == null ? '' : '.' + class_el) + ' > div').html(arr_types[type]['icon'] + string).removeClass('color-blue').removeClass('color-red').removeClass('color-green').addClass('color-' + arr_types[type]['color']);
$('input').blur();
$('html,body').animate({
scrollTop: ($((class_el == null ? '.msg' : '.msg.' + class_el)).offset().top - (is_portable == true ? (70 + 10) : 15))
}, 50);
if(type == 'wait') {
cursor('wait');
} else {
cursor('default');
}
}
function svgicon($string) {
arr = {
'msg-warning': '',
'msg-done': '',
'msg-information': '',
'msg-waiting': '',
};
return arr[$string];
}
function cursor(type) {
if(type == 'wait') {
$('html,body').css({ 'cursor': 'wait' });
} else if(type == 'default') {
$('html,body').css({ 'cursor': 'auto' });
}
}