       data =
         filename: filename
         source: session.getDocument().getValue()
+      saving = true
       location.href = '/editor/save_file?' + $.param(data)
 
   $('#load-button').click ->

# You can use CoffeeScript in this file: http://coffeescript.org/

$ ->
  textEditor = ace.edit('text-editor')
  textEditor.setTheme('ace/theme/clouds')
  textEditor.setShowInvisibles(true)

  )

  window.onbeforeunload = (event) ->
    if !saving && session.getDocument().getValue().length > 0
      return '作成中のプログラムが消えてしまいます。'
    else
      saving = false
      return
