diff --git a/static/js/index.js b/static/js/index.js index ca0f320..dba393c 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -183,7 +183,42 @@ function LoadRecentPhotos() .fail(function(jx) { if (jx.responseText != '') console.log(jx.responseText); }); } +function startCountdown(unixTimestamp) { + function padZero(num) { + return num < 10 ? '0' + num : num; + } + function getWord(num, words) { + if (num % 10 === 1 && num % 100 !== 11) return words[0]; + if (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20)) return words[1]; + return words[2]; + } + + function updateTimer() { + const now = Math.floor(Date.now() / 1000); + const diff = unixTimestamp - now; + + if (diff <= 0) { + clearInterval(interval); + document.getElementById('countdown').textContent = "00 дней 00 часов 00 минут 00 секунд"; + return; + } + + const days = Math.floor(diff / 86400); + const hours = Math.floor((diff % 86400) / 3600); + const minutes = Math.floor((diff % 3600) / 60); + const seconds = diff % 60; + + document.getElementById('countdown').textContent = + `${padZero(days)} ${getWord(days, ['день', 'дня', 'дней'])} ` + + `${padZero(hours)} ${getWord(hours, ['час', 'часа', 'часов'])} ` + + `${padZero(minutes)} ${getWord(minutes, ['минута', 'минуты', 'минут'])} ` + + `${padZero(seconds)} ${getWord(seconds, ['секунда', 'секунды', 'секунд'])}`; + } + + updateTimer(); // сразу обновляем отображение + const interval = setInterval(updateTimer, 1000); +} function LoadPubPhotos() { diff --git a/static/js/photo.js b/static/js/photo.js index f38a81c..fd93de2 100644 --- a/static/js/photo.js +++ b/static/js/photo.js @@ -118,7 +118,7 @@ $(document).ready(function() if (vote != 0 && vote != 1 || $(this).is('.locked')) return false; var pid = $(this).closest('.vote').attr('pid'); - + var cid = $(this).closest('.vote').attr('cid'); var savedClass1 = $('.vote[pid="' + pid + '"] .konk_btn[vote="1"]').attr('class'); var savedClass0 = $('.vote[pid="' + pid + '"] .konk_btn[vote="0"]').attr('class'); @@ -131,7 +131,7 @@ $(document).ready(function() { $(this).closest('.p20p').removeAttr('class').css('padding', '6px 6px 5px'); - $.getJSON('/api/photo/vote', { action: 'vote-konk', pid: pid, vote: vote }, function (data) + $.getJSON('/api/photo/vote', { action: 'vote-konk', pid: pid, vote: vote, cid: cid }, function (data) { if (data && !data.errors) { diff --git a/views/pages/Main.php b/views/pages/Main.php index 93cc57f..5dd97ee 100644 --- a/views/pages/Main.php +++ b/views/pages/Main.php @@ -128,44 +128,7 @@ LIMIT 10;'); background-image: url('data:image/svg+xml;utf8,🎁🎈🎀🎊🎉'); } - +
Тематика: ' . $theme['title'] . '
Лучшие фотографии по мнению сообщества ' . NGALLERY['root']['title'] . ' будут отмечены

- Участвовать! + Участвовать! Голосовать за претендентов '; }