<commit_before>$(document).on 'page:change', ->

  container = $('#events-calendar')

  eventUpdate = (event)->
    data =
      start_time: event.start.toISOString()
      end_time:   event.end.toISOString()

    $.ajax "/events/#{event.id}",
      type: 'PATCH'
      dataType: 'json'
      data: { event: data }

  eventCreate = (event)->
    $.ajax "/events",
      type: 'POST'
      dataType: 'json'
      data: { event: event }

      success: (event)->
        container.fullCalendar 'refetchEvents'

  container.fullCalendar
    header:
      left: 'prev,next today'
      center: 'title'
      right: 'agendaDay,agendaWeek,month'

    defaultView: 'agendaWeek'
    eventLimit: true

    editable: true
    selectable: false

    # Agenda options
    allDaySlot: false
    slotEventOverlap: false
    slotDuration: '00:30:00'
    snapDuration: '00:15:00'
    minTime: '06:00'
    maxTime: '20:00'

    # Droppable
    droppable: true

    events:
      url: '/events/calendar.json'

    eventDrop: eventUpdate
    eventResize: eventUpdate

    eventRender: (event, element)->
      element.bind 'dblclick', ->
        window.location.href = "/events/#{event.id}/edit"

    eventReceive: (event)->
      console.log 'rec', arguments

    drop: (date, event) ->
      el = $(event.target)

      trip_id    = el.data('tripId')
      start_time = date.toISOString()
      duration   = moment.duration(el.data('duration')).asMinutes()

      event =
        trip_id: trip_id
        start_time: start_time
        duration: duration

      eventCreate event
<commit_msg>Not used anymore...<commit_after>$(document).on 'page:change', ->

  container = $('#events-calendar')

  eventUpdate = (event)->
    data =
      start_time: event.start.toISOString()
      end_time:   event.end.toISOString()

    $.ajax "/events/#{event.id}",
      type: 'PATCH'
      dataType: 'json'
      data: { event: data }

  eventCreate = (event)->
    $.ajax "/events",
      type: 'POST'
      dataType: 'json'
      data: { event: event }

      success: (event)->
        container.fullCalendar 'refetchEvents'

  container.fullCalendar
    header:
      left: 'prev,next today'
      center: 'title'
      right: 'agendaDay,agendaWeek,month'

    defaultView: 'agendaWeek'
    eventLimit: true

    editable: true
    selectable: false

    # Agenda options
    allDaySlot: false
    slotEventOverlap: false
    slotDuration: '00:30:00'
    snapDuration: '00:15:00'
    minTime: '06:00'
    maxTime: '20:00'

    # Droppable
    droppable: true

    events:
      url: '/events/calendar.json'

    eventDrop: eventUpdate
    eventResize: eventUpdate

    eventRender: (event, element)->
      element.bind 'dblclick', ->
        window.location.href = "/events/#{event.id}/edit"

    drop: (date, event) ->
      el = $(event.target)

      trip_id    = el.data('tripId')
      start_time = date.toISOString()
      duration   = moment.duration(el.data('duration')).asMinutes()

      event =
        trip_id: trip_id
        start_time: start_time
        duration: duration

      eventCreate event

{'fraction_non_alphanumeric': 0.1332470892626132, 'fraction_numerical': 0.0129366106080207, 'mean_word_length': 2.429046563192905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5758310', 'n_tokens_mistral': 1031, 'n_tokens_neox': 974, 'n_words': 213}