function x (a, b) {
let i = 0;
while (a>b){
a = Math.round(a/b);
i++;
};
return i;
}
let choice = new Set([1,2,3,4]);
let choiceArr = [...choice];
let currentMonth = 1;
let object = {
[choiceArr[0]] : currentMonth,
[choiceArr.at(-1)] : currentMonth
}
prev.addEventListener('click', ()=>{
// правильно current
if (curentMonth == 0) curentYear -= 1
curentMonth = (12 + curentMonth - 1) % 12
createCalendar(calendar, curentYear, curentMonth);
months.innerHTML = monthsName[curentMonth];
years.innerHTML = curentYear;
})
function createTable(el) {
for (let i = 0, row; i < el.length; i++) {
if (i % 7 === 0) {
row = document.createElement('tr');
thead.appendChild(row);
}
const cell = document.createElement('th');
cell.innerHTML = el[i];
row.appendChild(cell);
}
}
const colors = {
'3': 'red',
'2': 'green',
'1': 'blue',
'0': 'black',
};
const setColor= input => {
const { value } = input;
if (colors.hasOwnProperty(value)) {
input.style.backgroundColor = colors[value];
}
}
const onInput = e => {
setColor(e.target);
}
document.querySelectorAll('input')
.forEach(elem => {
elem.addEventListener('input', onInput);
setColor(elem);
});
Разрешить доступ к почтовому ящику с помощью почтовых клиентов
С сервера imap.yandex.ru по протоколу IMAP
<body>
<input type="text">
<script>
let inp = document.querySelector('input');
inp.oninput = function(e) {
const val = inp.value.replace(/[^\d\.]/g, '');
const num = parseFloat(val);
const str = (num!==num?'0':num.toString())+(e.data=='.'?'.':'');
inp.value = str + ' рублей';
if(inp.selectionStart>str.length){
inp.focus();
inp.selectionStart=str.length;
inp.selectionEnd=str.length;
}
};
</script>
</body>
- document.querySelector('.calculate').addEventListener('click', function () {
+ document.querySelector('form').addEventListener('input', function () {
<div class="mainMenu">
<button data-scroll-to="calendar">Раз</button>
<button data-scroll-to="rooms">Два</button>
<button data-scroll-to="maps">Три</button>
<button data-scroll-to="contact">Четыре</button>
</div>
...
<div data-block="calendar">...</div>
<div data-block="rooms">...</div>
<div data-block="maps">...</div>
<div data-block="contact">...</div>
function scrollTo(block) {
document.querySelector(`[data-block="${block}"]`).scrollIntoView({
block: 'center',
behavior: 'smooth',
});
}
document.querySelector('.mainMenu').addEventListener('click', e => {
const block = e.target.dataset.scrollTo;
if (block) {
scrollTo(block);
}
});
// или
document.querySelectorAll('[data-scroll-to]').forEach(function(n) {
n.addEventListener('click', this);
}, e => scrollTo(e.target.dataset.scrollTo));
const startDateRender = new Date(dateStart).toISOString().substring(0, 10)
const endDateRender = new Date(dateEnd).toISOString().substring(0, 10)