var window_width = parseFloat($(window).width()), window_height = parseFloat($(window).height()); $(document).ready(function () { $('#root').hide(); var url = 'ajax.php', type = 'POST'; root = $('#root').attr('href'); $(document).on('click', '#ok', function () { $('#biskvitki').remove(); $.ajax({ type: 'POST', url: root + 'home/setcookies', data: { set_cookies: 1 } }); }); $(window).scroll(function () { if ($(this).scrollTop() > 370) $('#back_to_top').fadeIn(); else $('#back_to_top').fadeOut(); }); $('#back_to_top').click(function () { $('body,html').animate({ scrollTop: 0 }, 800); return false; }); $(document).on('click', '.hiks,.djam', function () { close_djam(); }); /** * * @description Опресняване на страницата * @returns {undefined} */ function refresh(url) { if (url) { window.location.href = url; } else { window.location.href = window.location.href; } } // $(document).on('keyup input click', 'table#login_forma input', function(key) { // var name = $('table#login_forma input[name=name]').val().length, // pass = $('table#login_forma input[name=password]').val().length; // if (name > 6 && pass > 6) { // $('table#login_forma button').attr('disabled', false); // if (key.keyCode == 13) { // login(type, url); // } // } else { // $('table#login_forma button').attr('disabled', true); // } // }); // $(document).on('click', 'table#login_forma button', function() { // login(type, url); // }); //Рефрешване на капчата $('.refresh').click(function () { var d = new Date(); $('img.captcha').attr('src', root + 'home/captchaimage/' + '?' + d.getTime()); }); $('#in').click(function () { login_djam('#3a1d03'); }); }); //function login_djam(color) { // djam('\n\ //\n\ // \n\ // \n\ //\n\ //\n\ // \n\ // \n\ //\n\ //\n\ // \n\ // \n\ //\n\ //
Име:
Парола:
затвори
', color); //} /** * * @description Логин * @param {string} type * @param {string} url * @returns {null} */ //function login(type, url) { // $.ajax({ // type: type, // url: url, // data: { // login: 1, // name: $('table#login_forma input[name=name]').val(), // pass: $('table#login_forma input[name=password]').val() // } // }).done(function(data) { // if (data) { // window.location.href = window.location.href; // } else { // close_djam(); // } // }); // return null; //} /** * * @description Псевдо alert() * @param {sting} text * @param {string} color * @returns {null} */ function djam(text, color) { $('body').append('
' + text + '
'); $('.djam1').css({ 'top': (window_height / 2) - (parseFloat($('.djam1').height()) / 2), 'left': (window_width / 2) - (parseFloat($('.djam1').width()) / 2), 'border-color': color, 'color': color }); $('.djam').animate({ 'opacity': .6 }, function () { $('.djam1').show(); }); return null; } /** * * @description Затваряне на псевдо alert() * @returns {null} */ function close_djam() { $('.djam1').hide(); $('.djam').animate({ 'opacity': 0 }, function () { $('.djam,.djam1').remove(); }); return null; } /** * * @description Взимане на $_GET от URL * @returns {array} * */ //function getUrlVars() { // var vars = {}; // window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, // function(m, key, value) { // vars[key] = value; // }); // return vars; //} /** * * @description Смяна на цвета * @param {string} selector * @param {string} color * @returns {null} */ function chColor(selector, color) { $(selector).css({ color: color }); return null; } /** * * @description Модел за имейл * @param {string} param * @returns {RegExp} */ function models(param) { if (param === 'email') return /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; else if (param === 'url') return /https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,}/gi; else if (param === 'nonum') return /[0-9.,]/g; else if (param === 'num') return /[^0-9.,]/g; } /** * * @description Пращане на бисквитка * @param {string} c_name * @param {string} value * @param {integer} exdays * @returns {null} */ function setCookie(c_name, value, exdays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value = escape(value) + ((exdays == null) ? '' : '; expires=' + exdate.toUTCString()); document.cookie = c_name + "=" + c_value; return null; } /** * * @description Вземане на бисквитка * @param {string} c_name * @returns {unresolved} */ function getCookie(c_name) { var i, x, y, ARRcookies = document.cookie.split(";"); for (i = 0; i < ARRcookies.length; i++) { x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("=")); y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1); x = x.replace(/^\s+|\s+$/g, ""); if (x == c_name) { return unescape(y); } } } /** * * @description Отваряне на чакалня * @param {string} dot * @returns {unresolved} */ function open_wait() { $('body').append('
wait'); $('.wait').css({ 'top': (window_height / 2) - (parseFloat($('.wait').height()) / 2), 'left': (window_width / 2) - (parseFloat($('.wait').width()) / 2) }); } /** * * @description Затваряне на чакалня * @returns {unresolved} */ function close_wait() { $('.wait_').remove(); $('.wait').remove(); } /** * * @description Отваряне на нов прозорец * @param {string} url * @returns {null} */ function openWin(url) { window.open(url); return null; } /** * * @description Отваряне на нов прозорец с по-малки размери * @example openWinMini({url: 'http://hankrum.info', width: 800, height: 500}); * @see default - url: 'http://hankrum.info', width: 1000, height: 700 * @param {object} params * @returns {null} */ function openWinMini(params) { var object; if (params === undefined) object = {}; else object = params; if (parseInt(object.width) === 0 || object.width === undefined) object.width = 1000; if (parseInt(object.height) === 0 || object.height === undefined) object.height = 700; if (String(object.url) === null || object.url === undefined) object.url = 'http://hankrum.info'; var size = 'width = ' + object.width + ', ' + 'height = ' + object.height; window.open(object.url, object.name, size); return null; } /** * * @description Затваряне на нов прозорец * @returns {null} */ function closeIt() { window.close(); return null; }