<script>
document.addEventListener("DOMContentLoaded", function() {
(function () {
const timeBlocks = document.querySelectorAll('div[class*="uc-time-block"]');
//ПРоверяем, если ли 4 этих блока на странице
if(timeBlocks.length==4){
function checkTime(){
const timeZone = +3; // Разница во времени мск
const day = new Date();
const utc = day.getTime() + (day.getTimezoneOffset() * 60000);
const DateOffset = new Date(utc + (3600000*timeZone));
const hour = DateOffset.getHours();
showBlockByTime(hour);
};
//ПОказываем блоки по времени
function showBlockByTime(tm){
if (tm >= 7 && tm < 12) {
if (!timeBlocks[0].classList.contains('show-time')) {
hideBlock();
showBlock(timeBlocks[0])
};
};
if (tm >= 12 && tm < 19) {
if (!timeBlocks[1].classList.contains('show-time')) {
hideBlock();
showBlock(timeBlocks[1])
};
};
if (tm >= 19 && tm < 24) {
if (!timeBlocks[2].classList.contains('show-time')) {
hideBlock();
showBlock(timeBlocks[2])
};
};
if (tm >= 0 && tm < 7) {
if (!timeBlocks[3].classList.contains('show-time')) {
hideBlock();
showBlock(timeBlocks[3])
};
};
};
function hideBlock(){
for (let timeBlock of timeBlocks) {
timeBlock.classList.remove('show-time');
};
};
function showBlock(em){
em.classList.add('show-time');
};
checkTime();
setInterval(function() {
checkTime();
}, 10000)
};
})();
});
</script>
<style>
div[class*="uc-time-block"]{
opacity: 0;
pointer-events: none;
z-index: -50;
position: fixed;
}
div[class*="uc-time-block"].show-time{
opacity: 1;
pointer-events: all;
position: static;
}
</style>