         site = $(pageElement).data('site')
 
         resource = if site? then "remote/#{site}/#{slug}" else slug
-        $.get "/#{resource}.json?random=#{randomBytes(4)}", "", (page) -> 
+        $.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')

        .each refresh

  useLocalStorage = () -> $('#localEditing').is(':checked')
  
  $('.page').each refresh
  
  startPages = pagesInDom()
  setState { pages: startPages, active: startPages[startPages.length-1]}

    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)]
