// Функция проверки вхождения текущего часа в отрезов от from до to (не включительно)
function isHourRange(from, to) {
var now = new Date();
var curHour = now.getHours();
return curHour >= from && curHour < to;
}
if(isHourRange(0, 9)) {
$('.ageWindow').fadeIn(100);
}
var TIME_FROM = 0;
var TIME_TO = 9;
var date = new Date();
var clientLocalHour = date.getHours();
if (clientLocalHour >= TIME_FROM && clientLocalHour < TIME_TO) {
$('.ageWindow').fadeIn(100);
}
function addAge() {
$('.ageWindow').fadeOut(500);
}
var SERVICE_TIMEZONE = 3;
var TIME_FROM = 0;
var TIME_TO = 9;
var date = new Date();
var clientLocalHour = date.getHours();
var timezoneOffset = date.getTimezoneOffset() / 60;
var serviceComputedHour = clientLocalHour + timezoneOffset + SERVICE_TIMEZONE;
if (serviceComputedHour >= TIME_FROM && serviceComputedHour < TIME_TO) {
$('.ageWindow').fadeIn(100);
}
function addAge() {
$('.ageWindow').fadeOut(500);
}
document.addEventListener('click', ({ target: t }) => {
if (t.classList.contains('box')) {
for (const n of document.querySelectorAll('.box')) {
n.style.background = n === t ? 'red' : 'black';
}
}
});
fetch('https://jsonplaceholder.typicode.com/albums')
.then(r => r.json())
.then(r => {
const keys = [ 'userId', 'id', 'title' ];
// собираем разметку
document.body.insertAdjacentHTML('beforeend', `
<div class="wrapper">${r.map(n => `
<div class="item">${keys.map(k => `
<div>${k}: ${n[k]}</div>`).join('')}
</div>`).join('')}
</div>
`);
// или, создаём элементы напрямую
function createElement(tag, className, children) {
const el = document.createElement(tag);
el.className = className;
el.append(...children);
return el;
}
document.body.append(
createElement('div', 'wrapper', r.map(n =>
createElement('div', 'item', keys.map(k =>
createElement('div', '', [ `${k}: ${n[k]}` ])
))
))
);
});
.wrapper {
border: 3px solid black;
padding: 10px;
margin: 10px;
}
.item {
border: 1px solid silver;
padding: 5px;
margin: 5px;
}
Прошел обучение Way Up "Веб-верстальщик, начало".
Только вот не знаю что дальше- стоит ли выбрать их платные курсы и какой именно ?
Хочу стать профессиональным верстальщиком