<link rel="stylesheet" type="text/css" href="https://gsvlabs-confluence-files.s3-us-west-2.amazonaws.com/stylesheets/EWC/eventsDashboardStylesheet.css" />

<script type="text/javascript" src="https://gsvlabs-confluence-files.s3-us-west-2.amazonaws.com/js/ewc/eventsDashboardScript.js"></script>

<style>
.wiki-content .ev-cards-outer-container {
    background-image: url("https://gsvlabs-confluence-files.s3-us-west-2.amazonaws.com/images/EWC+2020/gradient-vertical.jpg");
    background-size: cover;
    background-repeat: no-repeat;
}
#announcements-wrapper > span.conf-macro {
	height: 100%;
}

#additional-filters-button {
	width: 280px;
}

.zran-event {
	display: none;
}

@media only screen and (max-width: 480px) {
  .events-search-main {
    flex-direction: column;
    align-items: center;
    height: 75px;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding-bottom: 0px;
    overflow: hidden;
  }
  .wiki-content .ev-search-container {
    padding-bottom: 45px;
  }
}
</style>

<script>
// New Version of Format Date (Asynchronous)
async function formatDate2(d) {
  const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  var hh = d.getHours(); 
  var m = d.getMinutes();
  var s = d.getSeconds();
  var dd = "am";
  var h = hh;
  if (h >= 12) {
    h = hh-12;
    dd = "pm";
  }
  if (h == 0) {
    h = 12;
  }
  m = m<10?"0"+m:m;
  s = s<10?"0"+s:s;

  var strTime = h+":"+m+" "+dd
  return strTime + " on " + monthNames[d.getMonth()] + " " + d.getDate();
  // return dayNames[d.getDay()] + ", " + monthNames[d.getMonth()] + " " + d.getDate() + " " + d.getFullYear() + ", " + strTime;
}
</script>






<div class="announcementcard fade">
	<div class="imgalign"> 
		<img class="announcement-image" src="/download/attachments/81517767/[entry.image.asAttachment]"></img>
 	</div>
	<div class="text-encompasser">
		<div class="change-slide-buttons-container">
			<div class="change-slide-button" onclick="plusSlides(-1)"><img src="/download/attachments/81517767/chev-left.png?api=v2" /></div>
			<div class="change-slide-button" onclick="plusSlides(1)"><img src="/download/attachments/81517767/chev-right.png?api=v2" /></div>
		</div>
		<div class="text-container ev-banner-title">
			<p class="card-title">[entry.title] </p>
		</div>
		<div class="text-container">
			<font class="card-subtitle">[entry.subtitle] </font>
		</div>
		<div class="text-container">
			<font class="card-description">[entry.description] </font>
		</div>
		<div class="announcement-links-container">
			<a class="buttonHref" href="[entry.cardLink]" rel="nofollow" target="_blank" onclick="handleEventCardClick(this);" data-cardtype="announcement" data-cardurl="[entry.cardLink]" data-entryid="[entry.id]" data-cardtitle="[entry.title]">
				[entry.cardButtonText]
			</a>
		</div>
	</div>
</div>




<div class="filtersContainer events-search-main">
    <div id="events-search-container">
		<img src="/download/attachments/81517767/searchicon.png?api=v2" />
		<input id="events-searchbar" type="text" autocomplete="off" placeholder="SEARCH FOR A SPECIFIC EVENT" />
	</div>

    <div class="countryFilterContainer">  
		<div id="country-placeholder">Country</div>
        <ul id="countryFilter">
        </ul>
    </div>

	<div class="dateFilterContainer">
        <div class="dateFilter">
			<p class="dateInputContainer"><input type="text" placeholder="Start Date" id="startdate"></p>      <span>↔</span>      <p class="dateInputContainer"><input type="text" placeholder="End Date" id="enddate"></p>
		</div>
    </div>

	<div class="resetFilterContainer">
    	<a id="resetFilter">Clear All Filters</a>
	</div>
</div>

<div id="additional-filters-button" style="display: none;">
	<img src="/download/attachments/81517767/addfilters.png?api=v2" />
	<span>Additional Filters</span>
</div>




<h2 class="ev-cards-section-title">Search Results</h2>





<div class="ev-cards-outer-container">
	<div id="ev-cards-main-view">



<h2 class="ev-cards-section-title">My Events</h2>




<div class="eventcard" onclick="handleEventCardClick(this);" data-cardtype="upcomingevents" data-cardurl="/pages/viewpage.action?pageId=[entry.createdPage]" data-entryid="[entry.id]" data-cardtitle="[entry.name]">
	<a class="eventcardlink" href="/pages/viewpage.action?pageId=[entry.createdPage]" id="myevents-[entry.createdPage]">
	    <div class="img-container">
    	    <img src="https://passport-media.gsvlabsportal.com/EWC/Flags/[entry.countryCode].jpg"></img>
    	</div>
		<div class="text-container">
			<div class="top">
        		<div class="dates"><p class="formattedDate">[entry.startDate.formatDate(MMMM dd)]</p></div>
    		</div>
    		<div class="bottom">
        		<div class="title">[entry.name]</div>
        		<div class="dates"><p class="formattedDatetime"></p></div>
				<div class="attendees">[entry.RSVPCount] Participants</div>
    		</div>
		</div>
	</a>
</div>

<script>
	/* Set Date and Time in User's Timezone*/
	var UTCdate = "[entry.startDate.convertDate(MM/dd/YYYY HH:mm zzz, UTC)]";
	var localDate = new Date(UTCdate).toLocaleString();
	localDate = new Date(localDate);

	formatDate2(localDate).then(datetimeStr => {
		datetimeStr = datetimeStr.split(" on ");
		var timeStr = datetimeStr[0];
		var dateStr = datetimeStr[1];
		$('#myevents-[entry.createdPage] .formattedDatetime').html(timeStr);
		$('#myevents-[entry.createdPage] .formattedDate').html(dateStr);
	});

	/* Set RSVP Count */
	var RSVPCount = [entry.RSVPCount];
	formatRSVPCount(RSVPCount).then(RSVPCount => {
		$('#myevents-[entry.createdPage] .attendees').html(RSVPCount);
	});	

	/* Set Card URL to Event Name */
	var cardUrl = getEventCardUrl("[entry.pageName]");
	$('#myevents-[entry.createdPage]')[0].href = cardUrl;
	$('#myevents-[entry.createdPage]')[0].parentElement.dataset.cardurl = cardUrl; 

	/* Set Zran class name on Zran Event Cards */
	if ("[entry.countryCode]" == "ZRAN") {
		$('#myevents-[entry.createdPage]')[0].parentElement.classList.add("zran-event");
	}
	
	if (AJS.params.remoteUser && AJS.params.remoteUser.length > 0) {
		$("#my-events-scrolly")[0].style.display = "flex";
	}
</script>






<h2 class="ev-cards-section-title">Upcoming Events</h2>




<div class="eventcard" onclick="handleEventCardClick(this);" data-cardtype="upcomingevents" data-cardurl="/pages/viewpage.action?pageId=[entry.createdPage]" data-entryid="[entry.id]" data-cardtitle="[entry.name]" data-startdate="[entry.startDate.convertDate(MM/dd/YYYY HH:mm zzz, UTC)]">
	<a class="eventcardlink" href="/pages/viewpage.action?pageId=[entry.createdPage]" id="[entry.createdPage]">
	    <div class="img-container">
    	    <img src="https://passport-media.gsvlabsportal.com/EWC/Flags/[entry.countryCode].jpg"></img>
    	</div>
		<div class="text-container">
			<div class="top">
        		<div class="dates"><p class="formattedDate">[entry.startDate.formatDate(MMMM dd)]</p></div>
    		</div>
    		<div class="bottom">
        		<div class="title">[entry.name]</div>
        		<div class="dates"><p class="formattedDatetime"></p></div>
				<div class="attendees">[entry.RSVPCount] Participants</div>
    		</div>
		</div>
	</a>
</div>

<script>
	/* Set Date and Time in User's Timezone*/
	var UTCdate = "[entry.startDate.convertDate(MM/dd/YYYY HH:mm zzz, UTC)]";
	var localDate = new Date(UTCdate).toLocaleString();
	localDate = new Date(localDate);

	formatDate2(localDate).then(datetimeStr => {
		datetimeStr = datetimeStr.split(" on ");
		var timeStr = datetimeStr[0];
		var dateStr = datetimeStr[1];
		$('#[entry.createdPage] .formattedDatetime').html(timeStr);
		$('#[entry.createdPage] .formattedDate').html(dateStr);
	});

	/* Set RSVP Count */
	var RSVPCount = [entry.RSVPCount];
	formatRSVPCount(RSVPCount).then(RSVPCount => {
		$('#[entry.createdPage] .attendees').html(RSVPCount);
	});  	

	/* Set Card URL to Event Name */
	var cardUrl = getEventCardUrl("[entry.pageName]");
	$('#[entry.createdPage]')[0].href = cardUrl;
	$('#[entry.createdPage]')[0].parentElement.dataset.cardurl = cardUrl; 

	/* Set Zran class name on Zran Event Cards */
	if ("[entry.countryCode]" == "ZRAN") {
		$('#[entry.createdPage]')[0].parentElement.classList.add("zran-event");
	}
</script>






<h2 class="ev-cards-section-title">My Watchlist</h2>



<div class="conf-macro output-block fullSite" data-hasbody="true" data-macro-name="confiform-cleanview"></div>




</div>



<h2 class="ev-cards-section-title">Past Events</h2>




<div class="eventcard" onclick="handleEventCardClick(this);" data-cardtype="pastevents" data-cardurl="/pages/viewpage.action?pageId=[entry.createdPage]" data-entryid="[entry.id]" data-cardtitle="[entry.name]">
	<a class="eventcardlink" href="/pages/viewpage.action?pageId=[entry.createdPage]" id="[entry.createdPage]">
	    <div class="img-container">
    	    <img src="https://passport-media.gsvlabsportal.com/EWC/Flags/[entry.countryCode].jpg"></img>
    	</div>
		<div class="text-container">
			<div class="top">
        		<div class="dates"><p class="formattedDate">[entry.startDate.formatDate(MMMM dd)]</p></div>
    		</div>
    		<div class="bottom">
        		<div class="title">[entry.name]</div>
        		<div class="dates"><p class="formattedDatetime"></p></div>
				<div class="attendees">[entry.RSVPCount] Participants</div>
    		</div>
		</div>
	</a>
</div>

<script>
	/* Set Date and Time in User's Timezone*/
	var UTCdate = "[entry.startDate.convertDate(MM/dd/YYYY HH:mm zzz, UTC)]";
	var localDate = new Date(UTCdate).toLocaleString();
	localDate = new Date(localDate);

	formatDate2(localDate).then(datetimeStr => {
		datetimeStr = datetimeStr.split(" on ");
		var timeStr = datetimeStr[0];
		var dateStr = datetimeStr[1];
		$('#[entry.createdPage] .formattedDatetime').html(timeStr);
		$('#[entry.createdPage] .formattedDate').html(dateStr);
	});

	/* Set RSVP Count */
	var RSVPCount = [entry.RSVPCount];
	formatRSVPCount(RSVPCount).then(RSVPCount => {
		$('#[entry.createdPage] .attendees').html(RSVPCount);
	});  	

	/* Set Card URL to Event Name */
	var cardUrl = getEventCardUrl("[entry.pageName]");
	$('#[entry.createdPage]')[0].href = cardUrl;
	$('#[entry.createdPage]')[0].parentElement.dataset.cardurl = cardUrl; 

	/* Set Zran class name on Zran Event Cards */
	if ("[entry.countryCode]" == "ZRAN") {
		$('#[entry.createdPage]')[0].parentElement.classList.add("zran-event");
	}
</script>






<h2 class="ev-cards-section-title" style="margin-bottom: 60px;">All Events</h2>



<div class="eventcard" onclick="handleEventCardClick(this);" data-cardtype="allevents" data-cardurl="/pages/viewpage.action?pageId=[entry.createdPage]" data-entryid="[entry.id]" data-cardtitle="[entry.name]">
	<a class="eventcardlink" href="/pages/viewpage.action?pageId=[entry.createdPage]" id="all-events-[entry.createdPage]">
	    <div class="img-container">
    	    <img src="https://passport-media.gsvlabsportal.com/EWC/Flags/[entry.countryCode].jpg"></img>
    	</div>
		<div class="text-container">
			<div class="top">
        		<div class="dates"><p class="formattedDate">[entry.startDate.formatDate(MMMM dd)]</p></div>
    		</div>
    		<div class="bottom">
        		<div class="title">[entry.name]</div>
        		<div class="dates"><p class="formattedDatetime"></p></div>
				<div class="attendees">[entry.RSVPCount] Participants</div>
    		</div>
		</div>
	</a>
</div>

<script>
	/* Set Date and Time in User's Timezone*/
	var UTCdate = "[entry.startDate.convertDate(MM/dd/YYYY HH:mm zzz, UTC)]";
	var localDate = new Date(UTCdate).toLocaleString();
	localDate = new Date(localDate);

	formatDate2(localDate).then(datetimeStr => {
		datetimeStr = datetimeStr.split(" on ");
		var timeStr = datetimeStr[0];
		var dateStr = datetimeStr[1];
		$('#all-events-[entry.createdPage] .formattedDatetime').html(timeStr);
		$('#all-events-[entry.createdPage] .formattedDate').html(dateStr);
	});

	/* Set RSVP Count */
	var RSVPCount = [entry.RSVPCount];
	formatRSVPCount(RSVPCount).then(RSVPCount => {
		$('#all-events-[entry.createdPage] .attendees').html(RSVPCount);
	});

	/* Set Card URL to Event Name */
	var cardUrl = getEventCardUrl("[entry.pageName]");
	$('#all-events-[entry.createdPage]')[0].href = cardUrl;
	$('#all-events-[entry.createdPage]')[0].parentElement.dataset.cardurl = cardUrl; 

	/* Set Zran class name on Zran Event Cards */
	if ("[entry.countryCode]" == "ZRAN") {
		$('#all-events-[entry.createdPage]')[0].parentElement.classList.add("zran-event");
	}
</script>






<h2 class="ev-cards-section-title" style="margin-bottom: 60px;">Unpublished Events</h2>



<div class="eventcard" data-cardtype="allevents" data-cardurl="/pages/viewpage.action?pageId=[entry.createdPage]" data-entryid="[entry.id]" data-cardtitle="[entry.name]">
	<a class="eventcardlink" href="/pages/viewpage.action?pageId=[entry.createdPage]" id="unpublished-events-[entry.createdPage]">
	    <div class="img-container">
    	    <img src="https://passport-media.gsvlabsportal.com/EWC/Flags/[entry.countryCode].jpg"></img>
    	</div>
		<div class="text-container">
			<div class="top">
        		<div class="dates"><p class="formattedDate">[entry.startDate.formatDate(MMMM dd)]</p></div>
    		</div>
    		<div class="bottom">
        		<div class="title">[entry.name]</div>
        		<div class="dates"><p class="formattedDatetime"></p></div>
				<div class="attendees">[entry.RSVPCount] Participants</div>
    		</div>
		</div>
	</a>
</div>

<script>
	/* Set Date and Time in User's Timezone*/
	var UTCdate = "[entry.startDate.convertDate(MM/dd/YYYY HH:mm zzz, UTC)]";
	var localDate = new Date(UTCdate).toLocaleString();
	localDate = new Date(localDate);

	formatDate2(localDate).then(datetimeStr => {
		datetimeStr = datetimeStr.split(" on ");
		var timeStr = datetimeStr[0];
		var dateStr = datetimeStr[1];
		$('#unpublished-events-[entry.createdPage] .formattedDatetime').html(timeStr);
		$('#unpublished-events-[entry.createdPage] .formattedDate').html(dateStr);
	});

	/* Set RSVP Count */
	var RSVPCount = [entry.RSVPCount];
	formatRSVPCount(RSVPCount).then(RSVPCount => {
		$('#unpublished-events-[entry.createdPage] .attendees').html(RSVPCount);
	}); 

	/* Set Card URL to Event Name */
	var cardUrl = getEventCardUrl("[entry.pageName]");
	$('#unpublished-events-[entry.createdPage]')[0].href = cardUrl;
	$('#unpublished-events-[entry.createdPage]')[0].parentElement.dataset.cardurl = cardUrl; 

	/* Set Zran class name on Zran Event Cards */
	if ("[entry.countryCode]" == "ZRAN") {
		$('#unpublished-events-[entry.createdPage]')[0].parentElement.classList.add("zran-event");
	}
</script>






	</div>
</div>


<script>
const replaceDates = () => {
  let upcomingEventsSection = document.getElementById("scroll-section-1");
  let upcomingEventsCards = Array.from(upcomingEventsSection.getElementsByClassName("eventcard"));

  for (let i = 0; i < upcomingEventsCards.length; i++) {
    let card = upcomingEventsCards[i];
    let UTCdate = parseInt(card.dataset.startdate);
    console.log("Start Date:", UTCdate);

    let localDateStr = new Date(UTCdate).toLocaleString();
    console.log("localDateStr:", localDateStr);
    let localDate = new Date(localDateStr);
    console.log("localDate:", localDate);

    formatDate2(localDate).then(datetimeStr => {
      console.log("datetimeStr:", datetimeStr);
      datetimeStr = datetimeStr.split(" on ");
      let timeStr = datetimeStr[0];
      let dateStr = datetimeStr[1];

      card.getElementsByClassName("formattedDatetime")[0].innerText = timeStr;
      card.getElementsByClassName("formattedDate")[0].innerText = dateStr;
    });
  };
}

window.addEventListener('load', () => {
	replaceDates();
});
</script>