From a33dd0bedcfdcdbca61905c4ea3b882d0a6fe4e4 Mon Sep 17 00:00:00 2001 From: qwers451 Date: Sat, 18 Jan 2025 12:46:12 +0300 Subject: [PATCH] Updates --- ...875d825f899a98d.svg => 0863e5bc26221680f1e2.svg | 0 ...52e6ba4af54bc22.svg => 2127921da899ac475bac.svg | 0 ...c4a523e8fc42e59.svg => 6c7bf05444b9793fdf6e.svg | 0 ...8eb885c525f5e00.svg => 8a65f75d3d836c291cc9.svg | 0 ...e944a43e4c0b404.svg => a7ffe37dcb927ba0c46c.svg | 0 ...758840ae814ecde.svg => ae1a976ddb506239e9f0.svg | 0 ...2edc2f6eadb96b7.svg => bed8c136e13907f5eefb.svg | 0 ...bcb1d637fdb38e5.svg => df0c965524717a3fd8e9.svg | 0 index.html | 2 +- main.css | 14 +++++++------- main.js | 2 +- 11 files changed, 9 insertions(+), 9 deletions(-) rename fc3e6875d825f899a98d.svg => 0863e5bc26221680f1e2.svg (100%) rename a6a2f52e6ba4af54bc22.svg => 2127921da899ac475bac.svg (100%) rename 8667ac4a523e8fc42e59.svg => 6c7bf05444b9793fdf6e.svg (100%) rename 888d78eb885c525f5e00.svg => 8a65f75d3d836c291cc9.svg (100%) rename 75438e944a43e4c0b404.svg => a7ffe37dcb927ba0c46c.svg (100%) rename a086f758840ae814ecde.svg => ae1a976ddb506239e9f0.svg (100%) rename d86bb2edc2f6eadb96b7.svg => bed8c136e13907f5eefb.svg (100%) rename 49570bcb1d637fdb38e5.svg => df0c965524717a3fd8e9.svg (100%) diff --git a/fc3e6875d825f899a98d.svg b/0863e5bc26221680f1e2.svg similarity index 100% rename from fc3e6875d825f899a98d.svg rename to 0863e5bc26221680f1e2.svg diff --git a/a6a2f52e6ba4af54bc22.svg b/2127921da899ac475bac.svg similarity index 100% rename from a6a2f52e6ba4af54bc22.svg rename to 2127921da899ac475bac.svg diff --git a/8667ac4a523e8fc42e59.svg b/6c7bf05444b9793fdf6e.svg similarity index 100% rename from 8667ac4a523e8fc42e59.svg rename to 6c7bf05444b9793fdf6e.svg diff --git a/888d78eb885c525f5e00.svg b/8a65f75d3d836c291cc9.svg similarity index 100% rename from 888d78eb885c525f5e00.svg rename to 8a65f75d3d836c291cc9.svg diff --git a/75438e944a43e4c0b404.svg b/a7ffe37dcb927ba0c46c.svg similarity index 100% rename from 75438e944a43e4c0b404.svg rename to a7ffe37dcb927ba0c46c.svg diff --git a/a086f758840ae814ecde.svg b/ae1a976ddb506239e9f0.svg similarity index 100% rename from a086f758840ae814ecde.svg rename to ae1a976ddb506239e9f0.svg diff --git a/d86bb2edc2f6eadb96b7.svg b/bed8c136e13907f5eefb.svg similarity index 100% rename from d86bb2edc2f6eadb96b7.svg rename to bed8c136e13907f5eefb.svg diff --git a/49570bcb1d637fdb38e5.svg b/df0c965524717a3fd8e9.svg similarity index 100% rename from 49570bcb1d637fdb38e5.svg rename to df0c965524717a3fd8e9.svg diff --git a/index.html b/index.html index 576e980..c4daa0f 100644 --- a/index.html +++ b/index.html @@ -1 +1 @@ -Mesto

    \ No newline at end of file +Mesto

      \ No newline at end of file diff --git a/main.css b/main.css index 113da9d..7cdf929 100644 --- a/main.css +++ b/main.css @@ -9,12 +9,12 @@ .footer__copyright{color:#545454;font-size:18px;line-height:22px;margin:0}@media screen and (max-width:568px){.footer__copyright{font-size:14px;line-height:17px}} .footer{flex-shrink:0;font-family:Inter,Arial,sans-serif;padding:30px 0 60px}@media screen and (max-width:568px){.footer{padding:30px 0 36px}} .profile__description{font-size:18px;grid-area:description;line-height:22px;margin:0}@media screen and (max-width:568px){.profile__description{font-size:14px;line-height:17px}}@media screen and (max-width:480px){.profile__description{margin:7px 0 0;width:100%}} -.profile__add-button{background:transparent url(d86bb2edc2f6eadb96b7.svg) 50% no-repeat;background-size:22px;border:2px solid #fff;border-radius:2px;cursor:pointer;height:50px;margin-left:auto;transition:.3s;width:150px}.profile__add-button:hover{opacity:.6}@media screen and (max-width:740px){.profile__add-button{height:50px;width:50px}}@media screen and (max-width:480px){.profile__add-button{width:100%}} -.profile__edit-button{align-self:center;background:transparent url(8667ac4a523e8fc42e59.svg) 50% no-repeat;background-size:10px 10px;border:1px solid #fff;cursor:pointer;grid-area:button;height:24px;margin:0;padding:0;transition:.3s;width:24px}.profile__edit-button:hover{opacity:.6}@media screen and (max-width:480px){.profile__edit-button{background-size:8px 8px;height:18px;width:18px}} +.profile__add-button{background:transparent url(bed8c136e13907f5eefb.svg) 50% no-repeat;background-size:22px;border:2px solid #fff;border-radius:2px;cursor:pointer;height:50px;margin-left:auto;transition:.3s;width:150px}.profile__add-button:hover{opacity:.6}@media screen and (max-width:740px){.profile__add-button{height:50px;width:50px}}@media screen and (max-width:480px){.profile__add-button{width:100%}} +.profile__edit-button{align-self:center;background:transparent url(6c7bf05444b9793fdf6e.svg) 50% no-repeat;background-size:10px 10px;border:1px solid #fff;cursor:pointer;grid-area:button;height:24px;margin:0;padding:0;transition:.3s;width:24px}.profile__edit-button:hover{opacity:.6}@media screen and (max-width:480px){.profile__edit-button{background-size:8px 8px;height:18px;width:18px}} .profile__info{display:grid;grid-template-areas:"title button" "description description";grid-template-columns:minmax(auto,295px) auto;grid-gap:9px 17px}@media screen and (max-width:740px){.profile__info{grid-template-columns:minmax(auto,228px) auto;grid-gap:9px 5px}}@media screen and (max-width:568px){.profile__info{grid-template-columns:minmax(auto,195px) auto}}@media screen and (max-width:480px){.profile__info{display:flex;flex-wrap:wrap;justify-content:center;margin:26px 0 33px;width:100%}} .profile__title{font-size:42px;font-weight:500;grid-area:title;line-height:48px;margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media screen and (max-width:740px){.profile__title{font-size:32px;line-height:38px}}@media screen and (max-width:568px){.profile__title{font-size:27px;line-height:33px}}@media screen and (max-width:480px){.profile__title{min-width:201px}} .profile__image{background-color:#000;background-position:50%;background-size:cover;border-radius:50%;height:120px;margin:0 29px 0 0;overflow:hidden;position:relative;width:120px}.profile__image:hover{cursor:pointer}@media screen and (max-width:740px){.profile__image{margin:0 10px 0 0}}@media screen and (max-width:480px){.profile__image{margin-right:0}} -.profile__icon{background:transparent url(a086f758840ae814ecde.svg) 50% no-repeat;border-radius:50%;height:100%;opacity:0;transition:opacity .3s ease;width:100%;z-index:1}.profile__image:hover .profile__icon{opacity:1} +.profile__icon{background:transparent url(ae1a976ddb506239e9f0.svg) 50% no-repeat;border-radius:50%;height:100%;opacity:0;transition:opacity .3s ease;width:100%;z-index:1}.profile__image:hover .profile__icon{opacity:1} .profile__overlay{background-color:transparent;border-radius:50%;display:flex;height:calc(100% + 2px);left:-1px;position:absolute;top:-1px;transition:background-color .3s ease;width:calc(100% + 2px)}.profile__image:hover .profile__overlay{background-color:rgba(0,0,0,.8)} .profile{align-items:center;color:#fff;display:flex;font-family:Inter,Arial,sans-serif;padding:36px 0}@media screen and (max-width:480px){.profile{flex-direction:column;padding:43px 0;text-align:center}} .places__list{display:grid;grid-template-columns:repeat(auto-fit,282px);justify-content:center;grid-gap:20px 18px;list-style-type:none;margin:0;padding:0} @@ -24,15 +24,15 @@ .card__image{height:282px;-o-object-fit:cover;object-fit:cover;width:100%}.card__image:hover{cursor:pointer} .card__like-container{align-items:center;display:flex;flex-direction:column} .card__like-count{color:#000;font-family:Inter;font-size:13px;font-style:normal;font-weight:400;line-height:16px;margin:3px 0 0} -.card__like-button{background:transparent url(49570bcb1d637fdb38e5.svg) no-repeat;background-size:21px 18px;border:none;cursor:pointer;height:18px;margin:0;padding:0;transition:.3s;width:21px}.card__like-button:hover{opacity:.6} -.card__like-button_is-active{background:transparent url(75438e944a43e4c0b404.svg) no-repeat} -.card__delete-button{background:transparent url(a6a2f52e6ba4af54bc22.svg) 50% no-repeat;background-size:22px 22px;border:none;cursor:pointer;height:22px;margin:0;padding:0;position:absolute;right:15px;top:18px;transition:.3s;width:22px}.card__delete-button:hover{opacity:.6} +.card__like-button{background:transparent url(df0c965524717a3fd8e9.svg) no-repeat;background-size:21px 18px;border:none;cursor:pointer;height:18px;margin:0;padding:0;transition:.3s;width:21px}.card__like-button:hover{opacity:.6} +.card__like-button_is-active{background:transparent url(a7ffe37dcb927ba0c46c.svg) no-repeat} +.card__delete-button{background:transparent url(2127921da899ac475bac.svg) 50% no-repeat;background-size:22px 22px;border:none;cursor:pointer;height:22px;margin:0;padding:0;position:absolute;right:15px;top:18px;transition:.3s;width:22px}.card__delete-button:hover{opacity:.6} .card__delete-button_diactivate{display:none} .card__title{font-size:24px;line-height:29px;margin:0;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} .card{border-radius:10px;font-family:Inter,Arial,sans-serif;overflow:hidden;position:relative} .popup__content{background-color:#fff;border-radius:10px;box-sizing:border-box;max-width:430px;padding:34px 36px;position:relative;width:100%}@media screen and (max-width:568px){.popup__content{margin-top:40px;max-width:calc(100% - 80px);padding:30px 20px;width:100%}} .popup__content_content_image{background:transparent;background-size:cover;border-radius:0;display:flex;height:auto;max-height:75vh;max-width:75vw;padding:0;width:auto} -.popup__close{background:transparent url(888d78eb885c525f5e00.svg) 50% no-repeat;background-size:35px 35px;border:none;cursor:pointer;height:35px;margin:0;padding:0;position:absolute;right:-34px;top:-36px;transform:rotate(90deg);transition:visibility 0s,opacity .3s;width:35px}.popup__close:hover{opacity:.6} +.popup__close{background:transparent url(8a65f75d3d836c291cc9.svg) 50% no-repeat;background-size:35px 35px;border:none;cursor:pointer;height:35px;margin:0;padding:0;position:absolute;right:-34px;top:-36px;transform:rotate(90deg);transition:visibility 0s,opacity .3s;width:35px}.popup__close:hover{opacity:.6} .popup__title{font-size:24px;line-height:30px;margin:0}@media screen and (max-width:568px){.popup__title{font-size:18px;line-height:22px}} .popup__form{margin-top:27px} .popup__input{border:0;border-bottom:1px solid rgba(0,0,0,.2);box-sizing:border-box;font-size:14px;height:47px;line-height:18px;outline:none;padding:10px 0 0;width:100%}@media screen and (max-width:568px){.popup__title{font-size:12px;line-height:15px}} diff --git a/main.js b/main.js index 990b0df..d2bb4d6 100644 --- a/main.js +++ b/main.js @@ -1 +1 @@ -(()=>{"use strict";const e=document.querySelector("#card-template").content,t=(t,r,o,n)=>{const a=e.querySelector(".places__item").cloneNode(!0),s=a.querySelector(".card__image"),c=a.querySelector(".card__title"),l=a.querySelector(".card__like-count");return c.textContent=r,s.src=t,s.alt=r,l.textContent=o,a.id=n,a},r=(e,t,r)=>{t.validity.valid?((e,t,r,o)=>{const n=e.querySelector(`.${t.name}-error`);t.classList.remove(r),n.classList.remove(o),n.textContent=""})(e,t,r.inputErrorClass,r.errorClass):((e,t,r,o,n)=>{const a=e.querySelector(`.${t.name}-error`);t.classList.add(r),a.classList.add(n),a.textContent=o})(e,t,r.inputErrorClass,t.validationMessage,r.errorClass)},o=(e,t)=>{const o=Array.from(e.querySelectorAll(t.inputSelector)),a=e.querySelector(t.submitButtonSelector);n(o,a,t.inactiveButtonClass),o.forEach((o=>{r(e,o,t)}))},n=(e,t,r)=>{(e=>e.some((e=>!e.validity.valid)))(e)?t.classList.add(r):t.classList.remove(r)};function a(e){"Escape"===e.key&&p(document.querySelector(".popup_is-opened"))}let s=!1;function c(e){s=e.target===e.currentTarget}function l(e){e.target!==e.currentTarget&&(s=!1)}function u(e){e.target===e.currentTarget&&(e.target.style.cursor="pointer")}function i(e){e.target===e.currentTarget&&(e.target.style.cursor="default")}function d(e){function t(){p(e),e.querySelector(".popup__close").removeEventListener("click",t),e.removeEventListener("click",r),e.removeEventListener("mousedown",c),e.removeEventListener("mouseup",l),e.removeEventListener("mouseover",u),e.removeEventListener("mouseout",i),document.removeEventListener("keydown",a)}function r(e){s&&e.target===e.currentTarget&&t()}e.classList.add("popup_is-opened"),e.querySelector(".popup__close").addEventListener("click",t),e.addEventListener("click",r),e.addEventListener("mousedown",c),e.addEventListener("mouseup",l),e.addEventListener("mouseover",u),e.addEventListener("mouseout",i),document.addEventListener("keydown",a)}function p(e){e.classList.remove("popup_is-opened")}const _={baseUrl:"https://nomoreparties.co/v1/apf-cohort-202",headers:{authorization:"552fa201-4f17-4a86-bad1-b606f4eb72fe","Content-Type":"application/json"}},m=document.querySelector(".profile__title"),v=document.querySelector(".profile__description"),y=document.querySelector(".profile__image"),h=document.querySelector(".places__list"),f=document.querySelector(".popup_type_edit"),S=document.querySelector(".popup_type_new-card"),g=document.querySelector(".popup_type_image"),b=document.querySelector(".popup_type_avatar"),q=g.querySelector(".popup__image"),L=g.querySelector(".popup__caption"),k=document.querySelector(".profile__edit-button"),E=document.querySelector(".profile__add-button"),C=f.querySelector(".popup__form"),x=C.querySelector(".popup__button"),$=C.querySelector(".popup__input_type_name"),j=C.querySelector(".popup__input_type_description");$.value=m.textContent,j.value=v.textContent;const P=S.querySelector(".popup__form"),T=P.querySelector(".popup__button"),U=P.querySelector(".popup__input_type_card-name"),A=P.querySelector(".popup__input_type_url"),w=b.querySelector(".popup__form"),B=w.querySelector(".popup__button"),D=w.querySelector(".popup__input_type_url");let N;h.addEventListener("click",(e=>{if(e.target.classList.contains("card__image"))q.src="",q.src=e.target.src,L.textContent=e.target.alt,d(g);else if(e.target.classList.contains("card__like-button")){e.target.disabled=!0;const t=e.target.closest(".places__item");let r;r=e.target.classList.contains("card__like-button_is-active")?"DELETE":"PUT",((e,t)=>fetch(`${_.baseUrl}/cards/likes/${e}`,{method:t,headers:_.headers}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`))))(t.id,r).then((r=>{const o=(n=t,a=r.likes.length,n.querySelector(".card__like-count").textContent=a,n);var n,a;t.replaceWith(o),e.target.classList.toggle("card__like-button_is-active")})).catch((e=>{console.log(e)})).finally((()=>{e.target.disabled=!1}))}else if(e.target.classList.contains("card__delete-button")){e.target.disabled=!0;const r=e.target.closest(".places__item");(t=r.id,fetch(`${_.baseUrl}/cards/${t}`,{method:"DELETE",headers:_.headers}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)))).then((e=>{r.remove()})).catch((e=>{console.log(e)}))}var t})),Promise.all([fetch(`${_.baseUrl}/users/me`,{headers:_.headers}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`))),fetch(`${_.baseUrl}/cards`,{headers:_.headers}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)))]).then((e=>{let[r,o]=e;m.textContent=r.name,v.textContent=r.about,y.style.backgroundImage=`url(${r.avatar})`,N=r._id,o.forEach((e=>{const r=e.link,o=e.name,n=e.likes.length,a=e._id,s=t(r,o,n,a);e.likes.some((e=>e._id===N))&&s.querySelector(".card__like-button").classList.add("card__like-button_is-active"),e.owner._id!==N&&s.querySelector(".card__delete-button").classList.add("card__delete-button_diactivate"),h.append(s)}))})).catch((e=>{console.log(e)})),y.addEventListener("click",(e=>{D.value=y.style.backgroundImage.slice(5,-2),o(w,O),d(b)})),b.addEventListener("submit",(function(e){e.preventDefault(),B.textContent="Сохранение...";var t;(t={avatar:D.value},fetch(`${_.baseUrl}/users/me/avatar`,{method:"PATCH",headers:_.headers,body:JSON.stringify(t)}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)))).then((e=>{y.style.backgroundImage=`url(${e.avatar})`})).catch((e=>{console.log(e)})).finally((()=>{p(b),B.textContent="Сохранить"}))})),k.addEventListener("click",(e=>{$.value=m.textContent,j.value=v.textContent,o(C,O),d(f)})),C.addEventListener("submit",(function(e){e.preventDefault(),x.textContent="Сохранение...";var t;(t={name:$.value,about:j.value},fetch(`${_.baseUrl}/users/me`,{method:"PATCH",headers:_.headers,body:JSON.stringify(t)}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)))).then((e=>{m.textContent=e.name,v.textContent=e.about})).catch((e=>{console.log(e)})).finally((()=>{p(f),x.textContent="Сохранить"}))})),E.addEventListener("click",(()=>{A.value="",U.value="",o(P,O),d(S)})),P.addEventListener("submit",(function(e){e.preventDefault(),T.textContent="Создание...";var r;(r={name:U.value,link:A.value},fetch(`${_.baseUrl}/cards`,{method:"POST",headers:_.headers,body:JSON.stringify(r)}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)))).then((e=>{const r=e.link,o=e.name,n=e.likes.length,a=e._id,s=t(r,o,n,a);h.prepend(s)})).catch((e=>{console.log(e)})).finally((()=>{p(S),T.textContent="Создать"}))}));const O={formSelector:".popup__form",inputSelector:".popup__input",submitButtonSelector:".popup__button",inactiveButtonClass:"popup__button_disabled",inputErrorClass:"popup__input_type_error",errorClass:"popup__error_visible"};(e=>{Array.from(document.querySelectorAll(e.formSelector)).forEach((t=>{((e,t)=>{const o=Array.from(e.querySelectorAll(t.inputSelector)),a=e.querySelector(t.submitButtonSelector);o.forEach((s=>{s.addEventListener("input",(()=>{r(e,s,t),n(o,a,t.inactiveButtonClass)}))}))})(t,e)}))})(O)})(); \ No newline at end of file +(()=>{"use strict";const e=document.querySelector("#card-template").content,t=(t,r,o,n)=>{const s=e.querySelector(".places__item").cloneNode(!0),a=s.querySelector(".card__image"),c=s.querySelector(".card__title"),l=s.querySelector(".card__like-count");return c.textContent=r,a.src=t,a.alt=r,l.textContent=o,s.id=n,s},r=(e,t,r,o,n)=>{const s=e.querySelector(`.${t.name}-error`);t.classList.add(r),s.classList.add(n),s.textContent=o},o=(e,t,r,o)=>{const n=e.querySelector(`.${t.name}-error`);t.classList.remove(r),n.classList.remove(o),n.textContent=""},n=(e,t,n)=>{const s=t.validity.valid?"":t.validationMessage;"url"===t.type?t.validity.valid&&(e=>{try{const t=new URL(e),r=t.hostname.split(".");return("http:"===t.protocol||"https:"===t.protocol)&&r.length>1&&r[r.length-1].length>=2}catch(e){return!1}})(t.value)?o(e,t,n.inputErrorClass,n.errorClass):r(e,t,n.inputErrorClass,s||"Некорректный URL",n.errorClass):t.validity.valid?o(e,t,n.inputErrorClass,n.errorClass):r(e,t,n.inputErrorClass,s,n.errorClass)},s=(e,t)=>{const r=Array.from(e.querySelectorAll(t.inputSelector)),o=e.querySelector(t.submitButtonSelector);a(r,o,t.inactiveButtonClass),r.forEach((r=>{n(e,r,t)}))},a=(e,t,r)=>{(e=>e.some((e=>!e.validity.valid)))(e)?t.classList.add(r):t.classList.remove(r)};function c(e){"Escape"===e.key&&m(document.querySelector(".popup_is-opened"))}let l=!1;function u(e){l=e.target===e.currentTarget}function i(e){e.target!==e.currentTarget&&(l=!1)}function d(e){e.target===e.currentTarget&&(e.target.style.cursor="pointer")}function p(e){e.target===e.currentTarget&&(e.target.style.cursor="default")}function _(e){function t(){m(e),e.querySelector(".popup__close").removeEventListener("click",t),e.removeEventListener("click",r),e.removeEventListener("mousedown",u),e.removeEventListener("mouseup",i),e.removeEventListener("mouseover",d),e.removeEventListener("mouseout",p),document.removeEventListener("keydown",c)}function r(e){l&&e.target===e.currentTarget&&t()}e.classList.add("popup_is-opened"),e.querySelector(".popup__close").addEventListener("click",t),e.addEventListener("click",r),e.addEventListener("mousedown",u),e.addEventListener("mouseup",i),e.addEventListener("mouseover",d),e.addEventListener("mouseout",p),document.addEventListener("keydown",c)}function m(e){e.classList.remove("popup_is-opened")}const v={baseUrl:"https://nomoreparties.co/v1/apf-cohort-202",headers:{authorization:"552fa201-4f17-4a86-bad1-b606f4eb72fe","Content-Type":"application/json"}},y=document.querySelector(".profile__title"),h=document.querySelector(".profile__description"),f=document.querySelector(".profile__image"),g=document.querySelector(".places__list"),S=document.querySelector(".popup_type_edit"),b=document.querySelector(".popup_type_new-card"),q=document.querySelector(".popup_type_image"),L=document.querySelector(".popup_type_avatar"),E=q.querySelector(".popup__image"),k=q.querySelector(".popup__caption"),C=document.querySelector(".profile__edit-button"),x=document.querySelector(".profile__add-button"),$=S.querySelector(".popup__form"),j=$.querySelector(".popup__button"),P=$.querySelector(".popup__input_type_name"),T=$.querySelector(".popup__input_type_description");P.value=y.textContent,T.value=h.textContent;const U=b.querySelector(".popup__form"),A=U.querySelector(".popup__button"),w=U.querySelector(".popup__input_type_card-name"),B=U.querySelector(".popup__input_type_url"),D=L.querySelector(".popup__form"),N=D.querySelector(".popup__button"),O=D.querySelector(".popup__input_type_url");let I;g.addEventListener("click",(e=>{if(e.target.classList.contains("card__image"))E.src="",E.src=e.target.src,k.textContent=e.target.alt,_(q);else if(e.target.classList.contains("card__like-button")){e.target.disabled=!0;const t=e.target.closest(".places__item");let r;r=e.target.classList.contains("card__like-button_is-active")?"DELETE":"PUT",((e,t)=>fetch(`${v.baseUrl}/cards/likes/${e}`,{method:t,headers:v.headers}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`))))(t.id,r).then((r=>{const o=(n=t,s=r.likes.length,n.querySelector(".card__like-count").textContent=s,n);var n,s;t.replaceWith(o),e.target.classList.toggle("card__like-button_is-active")})).catch((e=>{console.log(e)})).finally((()=>{e.target.disabled=!1}))}else if(e.target.classList.contains("card__delete-button")){e.target.disabled=!0;const r=e.target.closest(".places__item");(t=r.id,fetch(`${v.baseUrl}/cards/${t}`,{method:"DELETE",headers:v.headers}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)))).then((e=>{r.remove()})).catch((e=>{console.log(e)}))}var t})),Promise.all([fetch(`${v.baseUrl}/users/me`,{headers:v.headers}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`))),fetch(`${v.baseUrl}/cards`,{headers:v.headers}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)))]).then((e=>{let[r,o]=e;y.textContent=r.name,h.textContent=r.about,f.style.backgroundImage=`url(${r.avatar})`,I=r._id,o.forEach((e=>{const r=e.link,o=e.name,n=e.likes.length,s=e._id,a=t(r,o,n,s);e.likes.some((e=>e._id===I))&&a.querySelector(".card__like-button").classList.add("card__like-button_is-active"),e.owner._id!==I&&a.querySelector(".card__delete-button").classList.add("card__delete-button_diactivate"),g.append(a)}))})).catch((e=>{console.log(e)})),f.addEventListener("click",(e=>{O.value=f.style.backgroundImage.slice(5,-2),s(D,J),_(L)})),L.addEventListener("submit",(function(e){e.preventDefault(),N.textContent="Сохранение...";var t;(t={avatar:O.value},fetch(`${v.baseUrl}/users/me/avatar`,{method:"PATCH",headers:v.headers,body:JSON.stringify(t)}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)))).then((e=>{f.style.backgroundImage=`url(${e.avatar})`,m(L)})).catch((e=>{console.log(e)})).finally((()=>{N.textContent="Сохранить"}))})),C.addEventListener("click",(e=>{P.value=y.textContent,T.value=h.textContent,s($,J),_(S)})),$.addEventListener("submit",(function(e){e.preventDefault(),j.textContent="Сохранение...";var t;(t={name:P.value,about:T.value},fetch(`${v.baseUrl}/users/me`,{method:"PATCH",headers:v.headers,body:JSON.stringify(t)}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)))).then((e=>{y.textContent=e.name,h.textContent=e.about,m(S)})).catch((e=>{console.log(e)})).finally((()=>{j.textContent="Сохранить"}))})),x.addEventListener("click",(()=>{B.value="",w.value="",s(U,J),_(b)})),U.addEventListener("submit",(function(e){e.preventDefault(),A.textContent="Сохранение...";var r;(r={name:w.value,link:B.value},fetch(`${v.baseUrl}/cards`,{method:"POST",headers:v.headers,body:JSON.stringify(r)}).then((e=>e.ok?e.json():Promise.reject(`Ошибка: ${e.status}`)))).then((e=>{const r=e.link,o=e.name,n=e.likes.length,s=e._id,a=t(r,o,n,s);g.prepend(a),m(b)})).catch((e=>{console.log(e)})).finally((()=>{A.textContent="Сохранить"}))}));const J={formSelector:".popup__form",inputSelector:".popup__input",submitButtonSelector:".popup__button",inactiveButtonClass:"popup__button_disabled",inputErrorClass:"popup__input_type_error",errorClass:"popup__error_visible"};(e=>{Array.from(document.querySelectorAll(e.formSelector)).forEach((t=>{((e,t)=>{const r=Array.from(e.querySelectorAll(t.inputSelector)),o=e.querySelector(t.submitButtonSelector);r.forEach((s=>{s.addEventListener("input",(()=>{n(e,s,t),a(r,o,t.inactiveButtonClass)}))}))})(t,e)}))})(J)})(); \ No newline at end of file