{"id":10,"date":"2021-06-23T21:40:44","date_gmt":"2021-06-23T21:40:44","guid":{"rendered":"https:\/\/misbf.2fishco.design\/?page_id=10"},"modified":"2023-04-14T12:01:13","modified_gmt":"2023-04-14T16:01:13","slug":"our-events","status":"publish","type":"page","link":"https:\/\/misbf.org\/es\/our-events\/","title":{"rendered":"Eventos"},"content":{"rendered":"<section class=\"wp-block-uagb-section uagb-section__wrap uagb-section__background-image uagb-block-a18136bb\"><div class=\"uagb-section__overlay\"><\/div><div class=\"uagb-section__inner-wrap\">\n<h1 class=\"has-text-align-center has-white-color has-text-color wp-block-heading\"><strong>Pr\u00f3ximos Eventos<\/strong><\/h1>\n<\/div><\/section>\n\n\n\n<section class=\"wp-block-uagb-section uagb-section__wrap uagb-section__background-undefined uagb-block-bafd7d15\"><div class=\"uagb-section__overlay\"><\/div><div class=\"uagb-section__inner-wrap\">\n<style>\n@keyframes loading {\n0% {\ncolor: #087a92;\n}\n50% {\ncolor: white;\n}\n100% {\ncolor: #087a92;\n}\n}\n\n.loading {\nanimation-name: loading;\nanimation-duration: 2s;\nanimation-iteration-count: infinite;\nanimation-timing-function: linear;\nmargin-bottom: 100px;\n}\n\n.article-container {\ndisplay: flex;\nborder: 1px solid black;\nposition: relative;\nmargin-bottom: 40px;\n}\n\n.event-image {\nwidth: 40%;\nbackground-size: cover;\nbackground-position: center center;\nz-index:1;\n}\n\n#future-events .content-container, #past-events .content-container {\ndisplay: flex;\nwidth:60%;\nflex-direction: column;\nposition: relative;\npadding: 40px;\n}\n\n.content-container < a < button {\npadding: 16px 32px;\nborder-radius: 30px;\n}\n\n.see-all-button {\npadding: 16px 32px;\nborder-radius: 30px;\ntext-align: center;\n}\n\n@media screen and (max-width: 1100px) {\n.article-container {\ndisplay: flex;\nflex-direction: column;\n}\n#future-events .event-image, #past-events .event-image {\nwidth: 100%;\nheight: 400px;\n}\n#future-events .content-container, #past-events .content-container {\nwidth: auto;\npadding: 40px;\nmin-height: 320px;\n}\n}\n<\/style>\n\n\n\n<div id=\"future-events\">\n<p class=\"loading\">Cargando<\/p>\n<\/div>\n\n\n\n<script>\nvar posts;\n\nwindow.addEventListener('DOMContentLoaded', (event) => {\nrenderEventsPosts();\n})\n\nfunction renderPosts(posts) {\nlet sorted_posts = sortPostsByDate(posts);\ndisplayUpcomingEvents(sorted_posts.upcoming);\ndisplayPastEvents(sorted_posts.previous, sorted_posts.upcoming.length + 1);\nconsole.log(sorted_posts);\n}\n\nfunction displayPastEvents(posts, start_index) {\nlet container = document.getElementById('past-events');\nposts.forEach(post => {\nlet article_container = document.createElement('article');\nlet content_container = document.createElement('div');\nlet title_link = document.createElement('a');\nlet title = document.createElement('h3');\nlet date = document.createElement('p');\nlet excerpt = document.createElement('p');\nlet image = document.createElement('div');\nlet learn_more_link = document.createElement('a');\nlet learn_more = document.createElement('button');\nlet rsvp_link = document.createElement('a');\nlet rsvp = document.createElement('button');\n\narticle_container.classList.add('article-container');\ncontent_container.classList.add('content-container');\nimage.classList.add('event-image');\n\ntitle.innerHTML = post.title.rendered;\ndate.innerHTML = 'Date: ' + post.acf.date;\nexcerpt.innerHTML = post.excerpt.rendered;\nif (post.acf.thumbnail) {\nimage.style.backgroundImage = 'url(' + post.acf.thumbnail + ')';\n} else if (post.uagb_featured_image_src.full[0]) {\nimage.style.backgroundImage = 'url(' + post.uagb_featured_image_src.full[0] + ')';\n} else {\nimage.style.background = 'grey';\n}\n\n\ntitle_link.appendChild(title);\ntitle_link.href = post.link;\nrsvp.innerHTML = 'RSVP';\nrsvp_link.href = post.acf.rsvp_link;\nrsvp_link.setAttribute('target', '_blank');\nrsvp_link.appendChild(rsvp);\n\nlearn_more.innerHTML = 'Learn More';\nlearn_more_link.href = post.link;\nlearn_more_link.classList.add('arrow_right');\nlearn_more_link.setAttribute('target', '_blank');\nlearn_more_link.appendChild(learn_more);\n\ncontent_container.appendChild(title_link);\ncontent_container.appendChild(excerpt);\nif (post.acf.date) {\ncontent_container.appendChild(date);\n}\ncontent_container.appendChild(learn_more_link);\narticle_container.appendChild(image);\narticle_container.appendChild(content_container);\ncontainer.appendChild(article_container);\n})\nlet loading = document.querySelector('.loading');\nloading.style.display = 'none';\nlet see_all_button_wrapper = document.createElement('a');\nlet see_all_button = document.createElement('button');\nsee_all_button_wrapper.appendChild(see_all_button);\nsee_all_button_wrapper.setAttribute('target', '_blank');\nsee_all_button_wrapper.href = 'https:\/\/misbf.org\/past-events\/' + '?start_query_index=' + start_index;\nsee_all_button.innerHTML = 'See All Past Events';\nsee_all_button.classList.add('see-all-button');\ncontainer.appendChild(see_all_button_wrapper);\n}\n\nfunction displayUpcomingEvents(posts) {\nlet container = document.getElementById('future-events');\nif (posts.length === 0) {\nlet no_posts_container = document.createElement('p');\nno_posts_container.innerHTML = 'There are no upcoming events currently scheduled.';\ncontainer.appendChild(no_posts_container);\nreturn;\n}\nposts.forEach(post => {\nlet article_container = document.createElement('article');\nlet content_container = document.createElement('div');\nlet title_link = document.createElement('a');\nlet title = document.createElement('h3');\nlet date = document.createElement('p');\nlet excerpt = document.createElement('p');\nlet image = document.createElement('div');\nlet learn_more_link = document.createElement('a');\nlet learn_more = document.createElement('button');\nlet rsvp_link = document.createElement('a');\nlet rsvp = document.createElement('button');\n\narticle_container.classList.add('article-container');\ncontent_container.classList.add('content-container');\nimage.classList.add('event-image');\n\ntitle.innerHTML = post.title.rendered;\ndate.innerHTML = 'Date: ' + post.acf.date;\nexcerpt.innerHTML = post.excerpt.rendered;\nif (post.acf.thumbnail) {\nimage.style.backgroundImage = 'url(' + post.acf.thumbnail + ')';\n} else if (post.uagb_featured_image_src.full[0]) {\nimage.style.backgroundImage = 'url(' + post.uagb_featured_image_src.full[0] + ')';\n} else {\nimage.style.background = 'grey';\n}\nrsvp.innerHTML = 'RSVP';\ntitle_link.appendChild(title);\ntitle_link.href = post.link;\n\nrsvp_link.setAttribute('target', '_blank');\nrsvp_link.href = post.acf.rsvp_link;\nrsvp_link.appendChild(rsvp);\n\nlearn_more.innerHTML = 'Learn More';\nlearn_more_link.href = post.link;\nlearn_more_link.setAttribute('target', '_blank');\nlearn_more_link.appendChild(learn_more);\n\ncontent_container.appendChild(title_link);\nif (post.acf.date) {\ncontent_container.appendChild(date);\n}\ncontent_container.appendChild(excerpt);\n\ncontent_container.appendChild(learn_more_link);\narticle_container.appendChild(image);\narticle_container.appendChild(content_container);\ncontainer.appendChild(article_container);\n})\nlet loading = document.querySelector('.loading');\nloading.style.display = 'none';\n}\n\nfunction sortPostsByDate(posts) {\nlet upcoming_posts = [];\nlet previous_posts = [];\nposts.forEach(post => {\nlet post_date = post.acf.date;\nlet current_date = new Date();\nlet post_year = post_date.slice(6,10);\nlet post_month = post_date.slice(0,2);\nlet post_day = post_date.slice(3,5);\nif (post_month - 1 < 0) {\npost_month = 0;\n}\nlet post_date_obj = new Date(post_year, post_month - 1, post_day);\npost.post_date_obj = post_date_obj;\nif (datesAreOnSameDay(post_date_obj, current_date)) {\nupcoming_posts.push(post);\n} else if (post_date_obj < current_date) {\nprevious_posts.push(post);\n} else {\nupcoming_posts.push(post);\n}\nupcoming_posts.sort((a,b)=>a.post_date_obj.getTime()-b.post_date_obj.getTime());\nprevious_posts.sort((a,b)=>a.post_date_obj.getTime()-b.post_date_obj.getTime());\nprevious_posts.reverse();\n})\nreturn return_obj = {\nupcoming: upcoming_posts,\nprevious: previous_posts\n}\n}\n\nconst datesAreOnSameDay = (first, second) =>\n    first.getFullYear() === second.getFullYear() &&\n    first.getMonth() === second.getMonth() &&\n    first.getDate() === second.getDate();\n\nasync function renderEventsPosts() {\nposts = await getEventsPosts();\nrenderPosts(posts);\n}\n\nasync function getEventsPosts() {\nlet window_url = window.location.href;\nlet lang = window_url.slice(18,20);\n    let url = 'https:\/\/misbf.org\/wp-json\/wp\/v2\/misbf_events';\nif (lang === \"es\") {\nurl = 'https:\/\/misbf.org\/es\/wp-json\/wp\/v2\/misbf_events';\n}  \n    try {\n        let res = await fetch(url);\n        return await res.json();\n    } catch (error) {\n        console.log(error);\n    }\n}\n<\/script>\n<\/div><\/section>\n\n\n\n<section class=\"wp-block-uagb-section uagb-section__wrap uagb-section__background-color uagb-block-c44cda12\"><div class=\"uagb-section__overlay\"><\/div><div class=\"uagb-section__inner-wrap\">\n<h2 class=\"has-text-align-center wp-block-heading\">Eventos pasados y seminarios web<\/h2>\n\n\n\n<div id=\"past-events\" style=\"flex-direction:column;align-items:center\">\n<\/div>\n<\/div><\/section>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"class_list":["post-10","page","type-page","status-publish","hentry"],"acf":[],"aioseo_notices":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"trp-custom-language-flag":false,"xl":false,"xxl":false,"xxxl":false,"xxxxl":false,"xxxxxl":false,"post-thumbnail":false,"getwid_base-cropped":false,"getwid_base-large":false},"uagb_author_info":{"display_name":"admin","author_link":"https:\/\/misbf.org\/es\/blog\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":null,"_links":{"self":[{"href":"https:\/\/misbf.org\/es\/wp-json\/wp\/v2\/pages\/10","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/misbf.org\/es\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/misbf.org\/es\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/misbf.org\/es\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/misbf.org\/es\/wp-json\/wp\/v2\/comments?post=10"}],"version-history":[{"count":7,"href":"https:\/\/misbf.org\/es\/wp-json\/wp\/v2\/pages\/10\/revisions"}],"predecessor-version":[{"id":30910,"href":"https:\/\/misbf.org\/es\/wp-json\/wp\/v2\/pages\/10\/revisions\/30910"}],"wp:attachment":[{"href":"https:\/\/misbf.org\/es\/wp-json\/wp\/v2\/media?parent=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}