       beforeSend: (xhr) ->
         $.rails.CSRFProtection xhr
 
+  @getCurrentPageJson: ->
+    pathname = window.location.pathname.replace(/\/+$/, '')
+
+    $.get "#{pathname}.json#{window.location.search}"
+
   @humanDate: (date, time = false) ->
     if date.year() is moment().year()
       date.format("M/D#{if time then ' h:mm A' else ''}")

Function::define = (name, methods) ->
  Object.defineProperty @::, name, methods

jQuery.fn.outerHTML = ->
  return '' unless @length

  return @[0].outerHTML if @[0].outerHTML

  $('<div>').append(@[0].clone()).remove().html()

String::dasherize = ->
  @replace /_/g, '-'

Array::compact = (strings = true) ->
  @forEach (element, index) =>
    @splice(index, 1) if element is undefined or (strings and element is '')

  @

Array::toSentence = ->
  switch @length
    when 0 then ''
