Skip to content
This repository was archived by the owner on Jun 19, 2020. It is now read-only.

Commit 04e0c34

Browse files
jjhalejoehale-mfj
authored andcommitted
Meetup client side js pull
1 parent bb047b9 commit 04e0c34

File tree

8 files changed

+230
-9
lines changed

8 files changed

+230
-9
lines changed

Diff for: LICENSE

+4
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22+
23+
24+
---
25+
Loading svg built using by https://loading.io/

Diff for: README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
4+
# Meetup integration
5+
6+
7+
Based on https://github.com/codefordc/codefordc.github.com/pull/217
8+
9+
Created a signed request at https://secure.meetup.com/meetup_api/console/?path=/:urlname/events

Diff for: _includes/footer.html

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ <h2>Collaborate</h2>
4141
</footer>
4242

4343
<script src="{{ '/js/main.js' | prepend: site.baseurl }}"></script>
44+
{% for js in page.jsarr %}
45+
<script type="text/javascript">
46+
{% include {{ js }} %}
47+
</script>
48+
{% endfor %}
4449
<script>
4550
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
4651
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

Diff for: _includes/icon/loading.svg

+2
Loading

Diff for: _includes/js/meetup.js

+172
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/**
2+
* Created by jjhale on 7/15/18.
3+
*/
4+
5+
6+
/*
7+
Display next meeting information, via Meetup API
8+
API Docs: http://www.meetup.com/meetup_api/docs/2/events/
9+
*/
10+
console.log('starting');
11+
$.ajax({
12+
type: "POST",
13+
dataType: 'jsonp',
14+
url: 'https://api.meetup.com/Code-for-Baltimore/events?photo-host=public&page=20&sig_id=14311654&sig=124bf6af6e8b516a9d3e570b6d0fcd6b8ae5ddaa',
15+
crossDomain : true,
16+
xhrFields: {
17+
withCredentials: true
18+
},
19+
beforeSend: function() {
20+
$('#meetup').addClass('loading'); // Show loader icon
21+
},
22+
complete: function() {
23+
$('#meetup').removeClass('loading'); // Hide loader icon
24+
}
25+
})
26+
.done(function( xhr, textStatus, response, data, responseJSON ) {
27+
console.log('done');
28+
console.log(typeof(xhr));
29+
console.log(xhr.length);
30+
console.log(xhr);
31+
32+
33+
if (xhr.data[0] == undefined) { // If there is no upcoming event posted on Meetup...
34+
console.log('undefined next event');
35+
36+
document.getElementById("meetupDetails").innerHTML = 'TBD (check back soon)'; // Meeting date & place
37+
document.getElementById("meetupRSVP").style.display = 'none'; // RSVP info
38+
document.getElementById("meetupCTA").innerHTML = 'Join Our Meetup'; // Call to Action text
39+
document.getElementById("meetupCTA").href = 'https://www.meetup.com/Code-for-Baltimore/'; // Call to Action link
40+
41+
} else
42+
{
43+
// Otherwise...
44+
console.log('there is a next event');
45+
46+
/*
47+
* Gather the Variables
48+
*/
49+
50+
// Next Event
51+
var nextEvent = xhr.data[0] // First event in the array returned from API
52+
53+
// Permalink
54+
var eventURL = nextEvent.link // URL
55+
56+
// desc
57+
var eventDesc = nextEvent.description;
58+
59+
// Location
60+
if (nextEvent.venue != undefined) {
61+
var eventLocation = nextEvent.venue.name // Location
62+
// Normal
63+
var eventAddress = nextEvent.venue.address_1 // Address
64+
var eventLatitude = nextEvent.venue.lat // Latitutde
65+
var eventLongitude = nextEvent.venue.lon // Longitude
66+
var eventCity = nextEvent.venue.city // Cityx
67+
var eventState = nextEvent.venue.state // State
68+
// Formatted for Gmaps
69+
var gmapAddress = eventAddress.split(' ').join('+')+',' // Address
70+
var gmapLat = '@'+eventLatitude+',' // Latitude
71+
var gmapLon = eventLongitude+',13z' // Longitude
72+
var gmapCity = '+'+eventCity+',' // City
73+
var gmapState = '+'+eventState+'/' // State
74+
// Gmaps Link
75+
var gmapStart = 'https://www.google.com/maps/place/' // Beginning of URL
76+
//var gmapLink = gmapStart+gmapAddress+gmapCity+gmapState+gmapLat+gmapLon; // Complete URL
77+
var gmapLink = gmapStart+gmapAddress+gmapCity+gmapState; // Complete URL
78+
} else {
79+
var eventAddress = 'TBD' // Address
80+
var gmapLink = eventURL // URL
81+
}
82+
83+
// RSVP
84+
var headCount = nextEvent.yes_rsvp_count; // Head Count (total number of 'yes' responses)
85+
86+
var RSVPMessage = headCount + " people will be there — what about you?"
87+
var CTA = "RSVP on Meetup"
88+
89+
// Date & Time
90+
if (nextEvent.time != undefined) {
91+
92+
// Formatting
93+
var m_names = ["January", "February", "March", // Month
94+
"April", "May", "June", "July", "August", "September",
95+
"October", "November", "December"];
96+
var d_names = ["Sunday", "Monday", "Tuesday", // Day
97+
"Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
98+
function formatAMPM(date) { // Time
99+
var hours = date.getHours();
100+
var minutes = date.getMinutes();
101+
var ampm = hours >= 12 ? 'pm' : 'am';
102+
hours = hours % 12;
103+
hours = hours ? hours : 12; // the hour '0' should be '12'
104+
minutes = minutes < 10 ? '0' + minutes : minutes;
105+
var strTime = hours + ':' + minutes + ' ' + ampm;
106+
return strTime;
107+
}
108+
109+
// Now
110+
var now = new Date; // Get Today's Date
111+
var todayMonth = now.getMonth() // Month
112+
var todayNumber = now.getDate() // Number
113+
var todayTime = formatAMPM(now) // Time (formatted)
114+
115+
// Next Event
116+
var date = new Date(nextEvent.time) // Get Next Event's Date
117+
var dateYear = date.getFullYear() // Year
118+
var dateMonth = date.getMonth() // Month
119+
var dateDay = date.getDay() // Day
120+
var dateNumber = date.getDate() // Number
121+
var dateTime = formatAMPM(date) // Time (formatted)
122+
123+
var eventName = nextEvent.name;
124+
125+
// Final Variables
126+
if ( (todayNumber == dateNumber) && (todayMonth == dateMonth) ) {
127+
var prettyDate = 'Today'
128+
} else {
129+
var prettyDate = d_names[dateDay]+', '+m_names[dateMonth]+' '
130+
+dateNumber+ ", " + dateYear ; // Otherwise
131+
}
132+
133+
} else {
134+
var prettyDate = 'TBD';
135+
var dateTime = '--:--';
136+
var eventName = "No upcoming events";
137+
}
138+
139+
/*
140+
* Do Stuff with the Variables
141+
*/
142+
143+
// Event Title
144+
document.getElementById("meetupName").innerHTML = eventName;
145+
146+
147+
// Date & Time
148+
document.getElementById("meetupDate").innerHTML = prettyDate; // Date & Time
149+
document.getElementById("meetupTime").innerHTML = dateTime; // Date & Time
150+
151+
// Location
152+
document.getElementById("meetupLocation").innerHTML = eventLocation + " " +eventAddress; // Location name
153+
document.getElementById("meetupLocation").href = gmapLink; // Location link (gmaps)
154+
155+
// RSVP
156+
document.getElementById("meetupRSVP").innerHTML = RSVPMessage; // RSVP Total + Visitor's Status
157+
158+
// Button
159+
document.getElementById("meetupCTA").innerHTML = CTA; // Call to Action Text
160+
document.getElementById("meetupCTA").href = eventURL; // Call to Action Link
161+
162+
// Description:
163+
document.getElementById("meetupDesc").innerHTML = eventDesc
164+
165+
}
166+
167+
})
168+
169+
.fail( function(xhr, textStatus, errorThrown) {
170+
alert(xhr.responseText);
171+
alert(textStatus);
172+
});

Diff for: _sass/_meetup.scss

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/***************************/
2+
/* meetup section */
3+
/***************************/
4+
5+
6+
.loading #loaderIcon {
7+
display: block;
8+
}
9+
10+
#loaderIcon {
11+
display: none;
12+
height: 3em;
13+
}

Diff for: css/main.scss

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ $on-laptop: 800px;
6464
"layout",
6565
"buttons",
6666
"lists",
67+
"meetup",
6768
"header",
6869
"footer",
6970
"forms",

Diff for: events.md

+24-9
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,31 @@ permalink: "/events/"
44
layout: page
55
type: inNavBar
66
order: 20
7+
jsarr:
8+
- js/meetup.js
79
---
810
# Events
911

10-
{% for event in site.data.events.active %}
11-
## {{ event.name }}
12-
* Date: {{ event.date }}
13-
* Time: {{ event.time }}
14-
* Location: {{ event.location }}
15-
* [RSVP on Meetup]({{event.meetup_url }} )
16-
17-
{{ event.description | markdownify }}
12+
<h2 id="meetupName">next event</h2>
13+
14+
<div id="loaderIcon">
15+
{% include icon/loading.svg %}
16+
</div>
17+
18+
* Date: <span id="meetupDate"></span>
19+
* Time: <span id="meetupTime"></span>
20+
* Location: <a id="meetupLocation" href="" target="_blank"></a>
21+
* <p id="meetupRSVP" class="sm soft"></p>
22+
23+
<a id="meetupCTA" class="btn-secondary" href="" target="_blank"></a>
24+
25+
<div id="meetupDesc"></div>
26+
27+
## Event types
28+
We have two types of meetups:
29+
* **Hack Nights**: project nights where our members work on
30+
select projects to benefit Baltimore communities.
31+
* **Community Nights**: networking events with members of
32+
the community and the group to discuss issues that could be solved with civic tech.
33+
1834

19-
{% endfor %}

0 commit comments

Comments
 (0)