 
         event['title'] = event['name']
 
-        event['className'] = if new Date(event['end']) > today
+        event['current'] = new Date(event['end']) > today
+
+        event['className'] = if event['current']
           "current"
         else
           "old"

processEventList = (data) ->
  $list = $('#all-events')

  # TODO: Make this work per year
  year = 2016
  prefix = year + "/"

  $list.html('')

  $allConfs = $('<div></div>')

  for label, conf of data[year]
    confID = prefix + slugify label

    location = if conf.location
      """
      <h3 class="location">
        <a href="https://maps.google.com/maps?q=#{ conf.location }" target="_blank">
          #{ conf.location }
        </a>
      </h3>
      """

    description = if conf.description
      """
      <div class="description">#{ conf.description }</div>
      """

    $conf = $("""
      <div class="conference">
        <a class="top" href="#quicklinks">Back to top</a>
        <div class="vevent">
          <h2 class="event summary" id="#{ confID }">
            <a href="##{ confID }" title="Link to this conference directly">
              #{ conf.name }
            </a>
          </h2>
          <div class="conference-info">
            #{ location || '' }
            <h3 class="date">
              <abbr class="dtstart" title="#{ conf.start }">#{ conf.start }</abbr>
              -
              <abbr class="dtend" title="#{ conf.end }">#{ conf.end }</abbr>
            </h3>
            #{ description || '' }
          </div>
        </div>
      </div>
      """)

    if conf.talks
      conf.talks.forEach (talk) ->
        talkID = confID + '--' + slugify talk.title

        speaker = if talk.speaker
          """
            <h4 class="speaker">Speaker: #{ talk.speaker }</h4>
          """

        location = if talk.location
          """
            <h4 class="location">Location: #{ talk.location }</h4>
          """

        $talk = $("""
          <div class="vevent talk">
            <h3 id="#{ talkID }" class="summary">
              <a href="##{ talkID }">#{ talk.title }</a>
            </h3>
            #{ speaker || '' }
            #{ location || '' }
            <h4 class="time">
              <abbr class="dtstart" title="#{ talk.start }">#{ talk.start }</abbr>
              -
              <abbr class="dtend" title="#{ talk.end }">#{ talk.end }</abbr>
            </h4>
            <div class="description">#{ talk.description }</div>
          </div>
          """)

        $conf.append($talk)

    $allConfs.append($conf)

  $list.html($allConfs)

processCalendar = (data) ->
  $widget = $("#calendar-widget")

  processEventList data


---
---
today = new Date()
currentYear = today.getFullYear()
hashInfo = []
calendarData = {}
prefix = ''

getHash = ->
  if document.location.hash != ''
    hashInfo = document.location.hash.slice(1).split('/')
  else
    hashInfo = []

scrollTo = (hash) ->
  setTimeout(->
    el = document.getElementById(hash.slice(1))

    if el
      parent = if el.nodeName == 'H2'
        el.parentElement.parentElement
      else
        el.parentElement

      parent.scrollIntoView({behavior: 'smooth', block: 'start'})
  , 0)

slugify = (name) ->
  # TODO: Enhance slugification
  name.toLowerCase().replace(/[^\w]/g, '-')

humanizeDate = (date, type) ->
  return date unless date

  if date.match ' '
    dateParts = date.split ' '
    dateTime = dateParts[0] + 'T' + dateParts[1]

    if type == 'start'
      format = '%a %e %b %Y %l:%M%P'
    else 
      format = '%l:%M%P ' + dateParts[2]
  else
    dateTime = date
    format = '%A %e %B'
    format += ' %Y' unless +date.slice(0,4) == currentYear

  new Date(dateTime).toLocaleFormat(format)

makeQuickLinks = (allConfs) ->
  $lis = $('h2.event>a', allConfs).clone().map((el) ->
    @['title'] = ''
    $('<li>').append(@)[0]
  )

  $ul = $('<ul>').append($lis)

  $("""
    <div id="#{prefix}quicklinks" class="quicklinks">
      <h2>Quicklinks</h2>
    </div>
    """).append($ul)

processAllEvents = (events) ->
  formatted = []

  for year of events
