const sortArr = (obj, arr) => {
return people.reduce((acc, item, i) => {
acc.push(obj.find(item => item.id === arr[i]));
return acc;
}, []);
}
let data = 'MULTIPOLYGON(((-61.2811499892424 -51.8650394644694, -61.2811499892424 -51.8650394644694)),((-59.6938009153582 -52.2130104476997, ( -59.6929605766079 -52.2129007110094,-59.6938009153582 -52.2130104476997),((-51.3119402806134,-59.5789385998322 -51.3125898252842)))';
data = data.replace(/\(*\)*/gm, '');
console.log(data);
// navigation active links
let menu = document.querySelector('.header__nav');
let links = menu.querySelectorAll('.nav__list-link');
window.addEventListener('scroll', function() {
let pos = window.pageYOffset;
for (let i = links.length - 1; i >= 0; i--) {
let link = links[i];
let target = document.querySelector(link.hash);
if ((pos + window.innerHeight / 2) > target.offsetTop) {
if (menu.querySelector('.menu__link-active')) {
menu.querySelector('.menu__link-active').classList.remove('menu__link-active');
}
link.classList.add('menu__link-active');
break;
} else if (pos < target.offsetTop) {
if (menu.querySelector('.menu__link-active')) {
menu.querySelector('.menu__link-active').classList.remove('menu__link-active');
}
}
}
});
document.addEventListener('click', function(e) {
let link = e.target;
if (link.classList.contains('nav__list-link')) {
e.preventDefault();
scrollToTarget(link.hash);
}
});
if (location.hash !== '') {
scrollToTarget(location.hash);
}
function scrollToTarget(id) {
let target = document.querySelector(id);
if (target !== null) {
let pos = target.offsetTop - document.querySelector('header').offsetHeight;
window.scrollTo({
top: pos,
behavior: 'smooth'
});
}
}
let like = document.querySelectorAll('.card__button-like')
like.addEventListener ('click', likeActive);
like.forEach( item => { item.addEventListener('click', likeActive ) } )