       region.play()
     return
   wavesurfer.on 'region-click', editAnnotation
-  #wavesurfer.on('region-dblclick', splitRegion);
   wavesurfer.on 'region-updated', saveRegions
   wavesurfer.on 'region-removed', saveRegions
   wavesurfer.on 'region-in', showNote


defaultRegionParams = { texts: [], drag: false, resize: false }

splitRegion(time) = ->
  time ||= wavesurfer.getCurrentTime()
  # Assume that time is always within a region, since we initialize a region over full audio at start
  splitCandidate = getRegions(time)[0]
  wavesurfer.addRegion { start: splitCandidate.start, end: round100(time), drag: false, resize: false, data: { type: 'segment' }, color: randomColor(0.3) }
  wavesurfer.addRegion { start: round100(time), end: splitCandidate.end, drag: false, resize: false, data: { type: 'segment' }, color: randomColor(0.3) }
  wavesurfer.regions.list[splitCandidate.region_id].remove()
  saveRegions()

getRegions = (time) ->
  region for region in regionsArray() when (region.start <= time && time < region.end)

saveRegions = ->
  localStorage.regions = JSON.stringify(regionsArray())
  return


  deleteRegion()

window.GLOBAL_ACTIONS['split-region'] = ->
  wavesurfer.splitRegion()
  saveRegions()

window.GLOBAL_ACTIONS['mark-word'] = ->
  wavesurfer.setMarker()
  saveRegions()

window.GLOBAL_ACTIONS['export'] = ->
  window.open 'data:application/json;charset=utf-8,' + encodeURIComponent(localStorage.regions)
