Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,8 @@ body{
border: 1px solid #555;
}
/* Jumbotron end */

/* meetup-event for the home page */
#meetup-event a {
color: white;
}
51 changes: 51 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<h1>Welcome to techcorridor.io</h1>
<p>TechCorridor.io is a developer group in Iowa City and Cedar Rapids, IA. If you’re interested in programming, the intertubes, and whatnot, this is the group for you.</p>
<p><a class="btn btn-primary btn-lg" href="http://www.meetup.com/techcorridorio" role="button">Join us at one of our Meetups!</a></p>
<p id="meetup-event"></p>
</div>
</div>

Expand All @@ -28,3 +29,53 @@ <h2>Twitter</h2>
</div>
</div>
</div>

{% raw %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it.

<script type="text/javascript">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be nice to have this in a separate .js file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved most of the js code to js/meetup-events.js but left the trigger code here.

//assume Mustache is loaded
//assume Meetup is loaded

// Modify from _includes/meetup_cards.html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we refactor that code so it's reusable without copying and pasting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved all the js code to js/meetup-events.js. If you want, I can refactor _includes/meetup_cards.html and _includes/developers_cards.html so they share the same code file.


window.onload = function(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably use $(document).ready(function ...) (or just $(function ...))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot use $(document).ready(function ...) here since jQuery will be imported after this code. Would you mind if I move <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> to <head>?

var configuration = {
"maxEvents": 5,
"url": "https://api.meetup.com/2/events?callback=JSON_CALLBACK&offset=0&format=json&limited_events=False&group_urlname=techcorridorio&page=200&fields=&order=time&desc=false&status=upcoming&sig_id=168857872&sig=e659cc6038d27adf6eae600a44905c69196c77df"
}
var meetup = new Meetup(configuration.url).getEvents(function(data) {
eventPresenter = EventPresenter(data.results[0]);
createEventParagraph(eventPresenter);
});

var createEventParagraph = function (event) {
var template = "Next meetup: <a href='{{event_url}}' target='_blank'>{{name}} ({{formattedDate}})</a>";
Mustache.parse(template); // optional, speeds up future uses
var rendered = Mustache.render(template, event);
$('#meetup-event').html(rendered);
};

var EventPresenter = function(event) {
var formatVenueLink = function(venue) {
var formattedVenue = "http://maps.google.com/?q=" + encodeURI(venue.address_1) + '+' + encodeURI(venue.city);
return formattedVenue
};
var formatDate = function(date) {
// Pretty print the event date
var day = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var months = [
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"
];

return months[date.getMonth()] + ' '
+ date.getDate();
}

event.venueLink = formatVenueLink(event.venue);
event.formattedDate = formatDate(new Date(event.time));
return event;
}
}
</script>
{% endraw %}