var window_width = parseFloat($(window).width()), window_height = parseFloat($(window).height()), root = $('#root').attr('href'); $(document).ready(function () { $(document).on('click', '.close_djam,.close,.djam', function () { close_djam(); }); }); /** * * @description Опресняване на страницата * @returns {undefined} */ function refresh(url) { if (url) { window.location.href = url; } else { window.location.href = window.location.href; } } /** * * @description Псевдо alert() * @param {sting} text * @param {string} color * @returns {undefined} */ function djam(text, color) { $('body').append('
');
$('.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 {undefined}
*/
function openWin(url) {
window.open(url);
}
/**
*
* @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 {undefined}
*/
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);
}
/**
*
* @description Затваряне на нов прозорец
* @returns {undefined}
*/
function closeIt() {
window.close();
}
/**
* Проверява, дали е JSON
* @param {string} str
* @returns {Boolean}
*/
function IsJson(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}