const format = (date) => {
const formatted = date.toLocaleString('ru-RU', {
weekday: 'long',
day: 'numeric',
month: 'long',
});
return `${formatted[0].toUpperCase()}${formatted.slice(1)}`;
};
const today = Date.now();
const day = 24 * 60 * 60 * 1000;
const tomorrow = format(new Date(today + day));
const dayAfterTomorrow = format(new Date(today + day * 2));
console.log(tomorrow); // 'Вторник, 6 июля'
console.log(dayAfterTomorrow); // 'Среда, 7 июля'
const formatter = new Intl.DateTimeFormat('ru-RU', {
weekday: 'long',
day: 'numeric',
month: 'long',
});
const format = (date) => {
const formatted = formatter.format(date);
return `${formatted[0].toUpperCase()}${formatted.slice(1)}`;
};
const today = Date.now();
const day = 24 * 60 * 60 * 1000;
const tomorrow = format(new Date(today + day));
const dayAfterTomorrow = format(new Date(today + day * 2));
console.log(tomorrow); // 'Вторник, 6 июля'
console.log(dayAfterTomorrow); // 'Среда, 7 июля'
document.querySelectorAll('ul li a').forEach((link, index) => {
link.addEventListener('click', () => {
console.log('Index is', index);
});
});
document.querySelectorAll('a').forEach(link => {
link.addEventListener('click', event => {
const parent = event.target.closest('li');
if (parent !== null) {
const items = [...parent.parentElement.children];
const index = items.indexOf(parent);
console.log('Index is', index);
}
});
});
react-router-dom
, то заменить BrowserRouter
на HashRouter
. /(ShowMaker|Chapionships|Markerwons|Lee-Broks|All-Mars)\s(\d{4})\s((((([5-9]|10)(\.\d)?)|(11(\.[0-5])?))\sUK)|(((3[5-9]|4[0-4])(\.\d)?|45)\sRU))/
(() => {
const expression = /(ShowMaker|Chapionships|Markerwons|Lee-Broks|All-Mars)\s(\d{4})\s((((([5-9]|10)(\.\d)?)|(11(\.[0-5])?))\sUK)|(((3[5-9]|4[0-4])(\.\d)?|45)\sRU))/;
const brands = ['ShowMaker', 'Chapionships', 'Markerwons', 'Lee-Broks', 'All-Mars'];
const round = (number) => Math.round(number * 10) / 10;
for (const brand of brands) {
console.group(brand);
console.group('UK');
console.time();
for (let size = 5; size <= 11.5; size += 0.1) {
const variant = `${brand} 0000 ${round(size)} UK`;
console.assert(expression.test(variant), variant);
}
console.timeEnd();
console.groupEnd();
console.group('RU');
console.time();
for (let size = 35; size <= 45; size += 0.1) {
const variant = `${brand} 0000 ${round(size)} RU`;
console.assert(expression.test(variant), variant);
}
console.timeEnd();
console.groupEnd();
console.groupEnd();
}
})();
- res.writeHead(200, { 'Content-Type': 'text/plain' });
+ res.writeHead(200, {
+ 'Content-Type': 'text/plain',
+ 'Access-Control-Allow-Origin': '*'
+ });
input.addEventListener('input', event => {
const element = event.target;
const currentValue = element.value;
const preparedValue = currentValue.replace(/\D/g, '');
const start = element.selectionStart;
const end = element.selectionEnd;
if (preparedValue !== currentValue) {
element.value = preparedValue;
element.dispatchEvent(new Event('change', { bubbles: true }));
if (event.inputType === 'insertText') {
const offset = event.data.length;
element.setSelectionRange(start - offset, end - offset);
}
}
});
<div className={`${category} ${accessories}`}>
<div className={clsx(category, accessories)}>