// JavaScript Document if (typeof $ === 'function') { $(document).ready(function() { "use strict"; $('footer').css('display', 'none'); fix_footer(); //clown var clown = $('.clown'); if (clown && typeof(clown) !== 'undefined') { setTimeout(function() { $('.clown').fadeOut(2000); }, 3000); } get_server_time(); setInterval(function () { get_server_time(); }, 1000); setTimeout(function() { go_up_show(); go_down_show(); }, 350); $(window).scroll(function() { fix_footer(); go_up_show(); go_down_show(); }); $(window).resize(function() { fix_footer(); go_up_show(); go_down_show(); }); $('.go-up').click(function() { $('html, body').animate({'scrollTop': 0}, 'fast'); }); $('.go-down').click(function() { $('html, body').animate({'scrollTop': $(document).height()}, 'fast'); }); $('.td-xml').click(function() { var idx = $(this).index() + 1; // rows $('.tr-xml div:not(.empty-val-xml)').removeClass('select-row-xml'); $(this).parent().find('.td-xml:not(.empty-val-xml)').addClass('select-row-xml'); // cols $('.tr-xml .th-xml, .tr-xml .td-xml:not(.empty-val-xml)').removeClass('select-col-xml'); $('.tr-xml .th-xml:nth-child('+ idx + '), .tr-xml .td-xml:nth-child('+ idx + '):not(.empty-val-xml)').addClass('select-col-xml'); }); $('.th-xml').click(function() { var idx = $(this).index() + 1; // cols $('.tr-xml .th-xml, .tr-xml .td-xml:not(.empty-val-xml)').removeClass('select-col-xml'); $('.tr-xml .th-xml:nth-child('+ idx + '), .tr-xml .td-xml:nth-child('+ idx + '):not(.empty-val-xml)').addClass('select-col-xml'); }); $(':radio').click(function() { if ($(this).is(':checked')) { $(this).parent('label').css('color', '#F00'); } $(':radio').not(':checked').parent('label').css('color', ''); }); $(':checkbox').click(function() { if ($(this).is(':checked')) { $(this).parent('label').css('color', '#F00'); } $(':checkbox').not(':checked').parent('label').css('color', ''); }); }); } function fix_footer() { "use strict"; var f = $('footer'); if (f !== 'undefined' && f) { if ($(window).height() >= $(document).height()) { if (f.css('position') !== 'fixed') { f.css('position', 'fixed'); f.css('bottom', '0px'); f.css('left', '0px'); } } else { if (f.css('position') !== 'static') { f.css('position', 'static'); } } f.css('display', 'block'); } } function go_up_show() { "use strict"; if ($(document).scrollTop() >= 100) { $('.go-up:hidden').stop().fadeIn('fast'); } else { $('.go-up:visible').stop().fadeOut('fast'); } } function go_down_show() { "use strict"; if ($(document).height() - $(window).height() - $(document).scrollTop() >= 100) { $('.go-down:hidden').stop().fadeIn('fast'); } else { $('.go-down:visible').stop().fadeOut('fast'); } } function str_ipos(haystack, needle, offset) { "use strict"; if (typeof(haystack) === 'string' && haystack && typeof(needle) === 'string' && needle ) { haystack = haystack.toLowerCase(); needle = needle.toLowerCase(); var index = 0; if (isNaN(offset)) { offset = 0; } if ((index = haystack.indexOf(needle, offset)) > -1) { return index; } } return false; } function get_server_time() { "use strict"; var elm = document.getElementById('watch'); if (typeof(elm) !== 'undefined' && elm) { // var d = new Date(); d.setHours(d.getHours() + 3, d.getMinutes() + d.getTimezoneOffset()); elm.innerHTML = d.toDateString() + ' ' + d.toTimeString().substr(0, 8) + ' (MSK)'; // /*if (typeof $ === 'function') { $.ajax({ method: 'GET', url: 'server_time.php', cache: false, dataType: 'html', success: function(data) { elm.innerHTML = data; } }); }*/ // } } function range_change(dest_id, _this) { "use strict"; var elm = document.getElementById(dest_id); if (typeof(elm) !== 'undefined' && elm) { elm.innerHTML = _this.value; } } function vote_item_del(parent_id, item_id, db_item_id) { "use strict"; var prnt = document.getElementById(parent_id); prnt.removeChild(document.getElementById(item_id)); var items_id_del = document.getElementById('items_id_del'); if (typeof(items_id_del) !== 'undefined' && items_id_del) { if (items_id_del.value) { items_id_del.value = items_id_del.value + ','; } items_id_del.value = items_id_del.value + db_item_id; } } var vote_item_add_num = 1; function vote_item_add(parent_id) { "use strict"; var prnt = document.getElementById(parent_id); var elm = document.createElement('table'); elm.className = 'vote-item'; elm.id = 'vote_item_add_' + vote_item_add_num; elm.innerHTML = '
' + v + ' (ваше мнение учтено)
'; } else { s = 'Ваше мнение учтено
'; } _this.onmouseover = null; _this.onmouseout = null; _this.style.cursor = 'default'; _this.src = 'images/like_gray.png'; } else { s = 'Ошибка! Обратитесь в техподдержку.
'; } elm.innerHTML = s; } }, complete: function() { $('#overlay').fadeOut(); } }); }); } function bribe_inc(_this, item_id, hide_res) { "use strict"; $('#overlay').fadeIn(function() { $.ajax({ method: 'GET', url: 'bribe_inc.php?id=' + item_id, cache: false, dataType: 'html', success: function(data) { var elm = document.getElementById('bribe_res_' + item_id); if (typeof(elm) !== 'undefined' && elm) { var s = ''; if (data === 'ok') { if (!hide_res) { var v = parseInt(elm.innerHTML); if (isNaN(v)) { v = 0; } v++; s = '' + v + ' (в знак благодарности номер Вашего счета включен в Наш благотворительный фонд навечно!)
'; } else { s = 'В знак благодарности номер Вашего счета включен в Наш благотворительный фонд навечно!
'; } _this.onmouseover = null; _this.onmouseout = null; _this.style.cursor = 'default'; _this.src = 'images/bribe_gray.png'; } else { s = 'Ошибка! Деньги украли по дороге!
'; } elm.innerHTML = s; } }, complete: function() { $('#overlay').fadeOut(); } }); }); } function upload_file_result_local(_form, item_id) { "use strict"; $('#overlay').fadeIn(function() { document.body.style.cursor = 'wait'; var fd = new FormData(_form); $.ajax({ type: 'POST', url: 'ajax_upload_file.php', cache: false, contentType: false, processData: false, data: fd ? fd : _form.serialize(), success: function(data) { var elm = document.getElementById('file_result_' + item_id); if (typeof(elm) !== 'undefined' && elm) { if (str_ipos(data, '---') === 0) { alert(data.substr(3)); } else { elm.value = data; } } }, error: function() { alert('Не удалось загрузить файл на сервер'); }, complete: function() { document.body.style.cursor = 'default'; $('#overlay').fadeOut(); } }); }); } function get_guess() { "use strict"; var r = Math.random(); if (r <= 0.2) { $('#guess_link').html('Упс... нас кажется бдят! Тырки попозже...Название: | ||
Ссылка: |