         document.getElementById('draghint').classList.remove 'hidden'
     reader.readAsArrayBuffer file
 
-addEventListener 'drop', (event) ->
+window.addEventListener 'drop', (event) ->
   event.preventDefault()
   document.getElementById('draghint').classList.remove 'hover'
   if event.dataTransfer.files.length > 0


player = null

stop = ->
  player.stop()
  localForage.setItem (md5 player.game), player.core.serialize()
  player.core.unload_game()
  player.core.deinit()
  player = null

addEventListener 'beforeunload', ->
  stop() if player

load = (file) ->

  # add URI support
  false

window.addEventListener 'dragover', (event) ->
  event.preventDefault()
  document.getElementById('draghint').classList.add 'hover'
  false

window.addEventListener 'dragleave', (event) ->
  event.preventDefault()
  document.getElementById('draghint').classList.remove 'hover'
  false

window.addEventListener 'click', (event) ->
  document.getElementById('chooser').click() if not player

document.getElementById('chooser').addEventListener 'change', ->
