const results = Object.values(arr.reduce((acc, c) => {
const prefix = c.id.split('.')[0];
acc[prefix] = [...acc[prefix] ?? [], c];
return acc;
}, {})
);
/* [
[{"id":"0"},{"id":"0.0"},{"id":"0.1"},{"id":"0.2"},{"id":"0.3"}],
[{"id":"1"},{"id":"1.0"},{"id":"1.1"}],
[{"id":"2"},{"id":"2.0"},{"id":"2.1"},{"id":"2.2"}],
] */
console.log(file);
, а console.log(file.fileList[0]);
.normalize={(file) => file.fileList[0]}
в Форм.Итем.import filePath from 'assets/PDFs/file.pdf';
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 июля'
<div data-filter="service">
<div class="sign">Streaming service</div>
<div class="item">Netflix</div>
<div class="item">HBO Max</div>
<div class="item">Hulu</div>
</div>
<div data-filter="genre">
<div class="sign">Movie genre</div>
<div class="item">Comedy</div>
<div class="item">Action</div>
<div class="item">Horror</div>
<div class="item">Drama</div>
<div class="item">Fantasy</div>
</div>
<li class="card" data-service="Netflix" data-genre="Comedy">
const cardSelector = '.card';
const hiddenCardClass = 'hidden';
const filterSelector = '[data-filter]';
const filterItemSelector = `${filterSelector} .item`;
const activeFilterItemClass = 'item_active';
document.querySelector('.filters').addEventListener('click', e => {
const item = e.target.closest(filterItemSelector);
if (!item) {
return;
}
item.closest(filterSelector).querySelectorAll(filterItemSelector).forEach(n => {
n.classList[n === item ? 'toggle' : 'remove'](activeFilterItemClass);
});
const values = Array.from(
e.currentTarget.querySelectorAll(`.${activeFilterItemClass}`),
n => [ n.closest(filterSelector).dataset.filter, n.innerText ]
);
document.querySelectorAll(cardSelector).forEach(n => {
n.classList.toggle(hiddenCardClass, values.some(m => n.dataset[m[0]] !== m[1]));
});
});
return { ...user, isFollowed: !this.isFollowed };
drawText(text) {
// If text is empty, not draw
if (text == "") return;
// Initialize text positions
let posX = TEXT_POS_X;
let posY = TEXT_POS_Y;
for (let i = 0; i < text.length; i++) {
// If letter eq new line, then change pos
if (text[i] == "\n") {
posX = TEXT_POS_X;
posY += GLYPH_H;
continue;
}
// If letter eq space, then change x pos
if (text[i] == " ") {
posX += SPACE_SIZE;
continue;
}
const [canvas, ctx] = createCanvas(GLYPH_W, GLYPH_H);
const meta = this.glyphs[text[i]];
// If glyph not found
if (meta == undefined) {
console.log(meta);
this.text_error = "Unknown glyph. See glyph_meta.json";
return;
}
// Clear error
this.text_error = "";
// Drawing letter in empty canvas
ctx.drawImage(
this.resources.fontColored,
meta[0] * GLYPH_W,
meta[1] * GLYPH_H,
GLYPH_W,
GLYPH_H,
0,
0,
GLYPH_W,
GLYPH_H
);
const trimmedCanvas = trim(canvas);
// Drawing letter
this.ctx.drawImage(trimmedCanvas, posX, posY);
posX += trimmedCanvas.width + GLYPH_MARGIN;
}
log(`Drawing text: ${text}`);
}
function createCanvas(width, height) {
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
return [canvas, canvas.getContext("2d")];
}
document.querySelector('.todo-app__list').addEventListener('click', e => {
const li = e.target.closest('.todo-app__list-item');
if (li) {
console.log(li.dataset.id);
}
});
function getHeight(height) {
return document.getElementsByTagName('html')[0].scrollHeight;
}
let height = 'your_value';
if (!getHeight(height)) {
setTimeout(function() {
getHeight(height);
}, 100)
}
color: #fff
и текст будет отображен с нужным цветом, но без обводки) $('.search').on('input', function() {
const search = $(this).val().trim().toLowerCase();
$('.metro-line__item')
.hide()
.filter((i, n) => $('.metro__name', n).text().toLowerCase().includes(search))
.show();
$('.metro-line')
.show()
.not(':has(.metro-line__item:visible)')
.hide();
});
.hidden {
display: none;
}
document.querySelector('.search').addEventListener('input', e => {
const search = e.target.value.trim().toLowerCase();
document.querySelectorAll('.metro-line__item').forEach(n => {
const name = n.querySelector('.metro__name').textContent.toLowerCase();
n.classList.toggle('hidden', !name.includes(search));
});
document.querySelectorAll('.metro-line').forEach(n => {
n.classList.toggle('hidden', !n.querySelector('.metro-line__item:not(.hidden)'));
});
});