const start = window.scrollTop
window.addEventListener('scroll', () => {
if (Math.abs(window.scrollTop - start) > 100) {
// Убираешь класс
}
}
const str = "<Sum> [stat]player_ammo_restored = 440360\n<Sum> [stat]player_climb_assists = 18256\n<Sum> [stat]player_climb_coops = 9874\n<Sum> [stat]player_damage = 519358590\n<Sum> [mode]PVE [stat]player_deaths = 23551\n<Sum>"
const getMatch = (el, regexp) => el.match(regexp)[0].trim()
const ddo = (str) => str.split(/<Sum>/).reduce((acc, el) => {
if (!el) return acc
const key = getMatch(el, /.*(?=\=)/)
const value = +getMatch(el, /(?<=\=).*/)
acc[key] = value
return acc
} ,{})
}
console.log(ddo(str))
const items = [
{
id: 1,
name: 'провод',
url: 'provod',
tags: ['провода', 'проводов']
},
{
id: 2,
name: 'робот',
url: 'robot',
tags: ['роботы', 'роботов']
},
]
const element = document.querySelector('ТУТ') // здесь пишешь css-селектор элемента который хочешь изменить
element.innerHTML = element.textContent
.split(/\s/)
.map(word => {
const matchedItem = items.find(item => [item.name, ...item.tags].includes(word))
return matchedItem ? `<a href='${matchedItem.url}'>${word}</a>` : word
})
.join(' ')
const inputEl = document.querySelector('input')
const btnMinus = document.querySelector('.btn-minus')
const btnPlus = document.querySelector('.btn-plus')
const changeInputValue = num => {
const newValue = inputEl.value + num
inputEl.value = newValue
inputEl.setAttribute('value', newValue)
}
btnMinus.addEventListener('click', () => {
changeInputValue(-1)
})
btnPlus.addEventListener('click', () => {
changeInputValue(1)
})
const priceEl = document.querySelector('.price')
const resultEl = document.querySelector('.result');
const callback = mutationList => {
for (const mutation of mutationsList) {
if (mutation.attributeName === 'value') {
resultEl.textContent = priceEl.textContent * inputEl.value
}
}
};
const observer = new MutationObserver(callback);
observer.observe(inputEl, { attributes: true });
.menu {
display: none;
}
.menu.active {
dispay: block
}
const navigation = document.querySelector('.main-navigation')
const handleNavigationClick = e => {
if (!e.target.classList.contains('scrollToLink') {
return
}
*Удалить класс showen с менюхи*
}
navigation.addEventListener('click', handleNavigationClick)
var jsonDate = (new Date()).toJSON();
var backToDate = new Date(jsonDate);
if (/\D/g.test(mes.text)) {
mes.send('Недопустимые символы');
return;
}