Как правило, все плагины работают от обратного - у них есть возможность передать массив только с неактивными датами.
config.enable
.дата => массив.includes(дата.toLocaleDateString())
:disbaledDates.customPredictor
.beforeShowDay
. $grouped = [];
foreach ($arr as $n) {
$grouped[$n['category_id']][] = $n['text'];
}
foreach ($grouped as $key => $values) {
echo "
<fieldset>
<legend>$key</legend>".
implode('', array_map(fn($n) => "<div>$n</div>", $values))."
</fieldset>";
}
const result = arr.filter(n => arr2.includes(n.strategy));
const result = arr2.flatMap(function(n) {
return this[n] ?? [];
}, arr.reduce((acc, n) => ((acc[n.strategy] ??= []).push(n), acc), {}));
const result = arr.filter(((values, n) => values.has(n.strategy)).bind(null, new Set(arr2)));
const result = [];
for (const n of arr) {
for (const m of arr2) {
if (m === n.strategy) {
result.push(n);
break;
}
}
}
{9}
пусть будет {4,9}
, например. Или {6,9}
. Или... Сами решайте, сколько их должно быть, вам виднее.a-z
, а a-f
. const baseURL = 'https://iss.moex.com//iss/history/engines/stock/markets/index/securities/RGBITR.json';
const params = new URLSearchParams([
[ 'sort_order', 'desc' ],
[ 'iss.meta', 'off' ],
[ 'iss.only', 'history' ],
[ 'history.columns', 'TRADEDATE,CLOSE' ],
]);
fetch(`${baseURL}?${params}`)
.then(r => r.json())
.then(r => {
new Chart(document.querySelector('#chart'), {
type: 'line',
data: {
labels: r.history.data.map(n => n[0]),
datasets: [ {
label: 'hello, world!!',
data: r.history.data.map(n => n[1]),
} ],
},
});
});
fetch(`${baseURL}?${params}`)
.then(r => r.json())
.then(({ history: { data } }) => {
chart.data.labels = data.map(n => n[0]);
chart.data.datasets[0].data = data.map(n => n[1]);
chart.update();
});
const chart = new Chart(document.querySelector('#chart'), {
type: 'line',
data: {
labels: [],
datasets: [ {
label: 'hello, world!!',
data: [],
} ],
},
});
<slot name="placeholder"></slot>
<template #placeholder>
<option value="" disabled>давай, выбирай</option>
</template>
document.addEventListener('click', e => {
const number = e.target.closest('[data-number]')?.dataset.number;
if (number) {
document.querySelectorAll(`[data-number="${number}"]`).forEach(n => n.remove());
}
});
const lists = document.querySelectorAll('.list');
lists.forEach(n => n.addEventListener('click', onClick));
function onClick(e) {
const i = Array.prototype.indexOf.call(this.children, e.target.closest('li'));
if (i !== -1) {
lists.forEach(n => n.removeChild(n.children[i]));
}
}
watch: {
alias: {
immediate: true,
handler: 'getArticles',
},
},
function haveSameValues(arr1, arr2) {
if (arr1.length !== arr2.length) {
return false;
}
const count = new Map;
arr1.forEach(n => count.set(n, -~count.get(n)));
arr2.forEach(n => count.set(n, ~-count.get(n)));
for (const n of count.values()) if (n) {
return false;
}
return true;
}
haveSameValues(
[ 'hello, world!!', 0, 0, 0, 1, 1, false, false ],
[ false, false, 1, 1, 0, 0, 0, 'hello, world!!' ]
) // true
haveSameValues(
[ 1, 2, 3 ],
[ 3, 2, 2 ]
) // false
haveSameValues(
[],
[]
) // true
const arr = Array.from(
new Set(Array.from(document.querySelectorAll('.shop_name'), n => n.innerText)),
n => ({ name: n })
);
const arr = Object.values(Array.prototype.reduce.call(
document.getElementsByClassName('shop_name'),
(acc, { textContent: name }) => (acc[name] ??= { name }, acc),
{}
));
function onClick({ currentTarget: t }) {
const className = t.dataset.activeClass;
document.querySelector(`.${className}`)?.classList.remove(className);
t.classList.add(className);
}
Vue.directive('active-class', {
bind(el, binding) {
el.dataset.activeClass = binding.value;
el.addEventListener('click', onClick);
},
update(el, binding) {
el.dataset.activeClass = binding.value;
},
unbind(el) {
delete el.dataset.activeClass;
el.removeEventListener('click', onClick);
},
});
<div v-active-class="'buy-voucher__amount_selected'">
<input v-active-class="'buy-voucher__amount_selected'">
router-view
не забыли добавить?