       factory.bind itemElement, item
       beforeElement = itemElement.prev('.item')
       before = getItem(beforeElement)
-      putAction pageElement, {item: item, id: item.id, type: "add", after: before?.id} 
+      putAction pageElement, {item: item, id: item.id, type: "add", after: before?.id}
 
     initDragging = ->
       storyElement = pageElement.find('.story')

        site = $(pageElement).data('site')

        resource = if site? then "remote/#{site}/#{slug}" else slug
        $.get "/#{resource}.json?random=#{randomBytes(4)}", "", (page) -> 
          window.dialog.html($('<pre/>').text(JSON.stringify(page, null, 2)))
          window.dialog.dialog( "option", "title", "Source for: "+slug );
          window.dialog.dialog('open')

    if History.enabled
      url = ("/view/#{page}" for page in state.pages).join('') # + "##{state.active}"
      History.pushState state, state.active, url

  setActive = (page) ->
    if History.enabled
      state = History.getState().data
      state.active = page
      setState state

  showState = (state) ->
    # show and refresh correct pages
    oldPages = pagesInDom()
    newPages = state.pages
    previousPage = newPages

    return unless newPages

    for name in newPages
      if name in oldPages
        delete oldPages[oldPages.indexOf(name)]
