   mapped.sort (a,b)->
     a.start - b.start
 
-round100 = (input) ->
+round1000 = (input) ->
   Math.round(input * 100)/100
 
 loadRegions = (regions) ->

wavesurfer.setMarker = (time, text) ->
  time ||= wavesurfer.getCurrentTime()
  text ||= ''
  wavesurfer.addRegion(start: round100(time), drag: true, resize: false, data: { type: 'segment_item', note: text }, color: 'rgba(0,0,0,0.5)')

regionsArray = ->
  mapped = Object.keys(wavesurfer.regions.list).map((id) ->
    region = wavesurfer.regions.list[id]
    {
      region_id: id
      start: round100(region.start)
      end: round100(region.end)
      data: region.data
      texts: []
      drag: (if region.data.type == 'segment_item' then true else false)

editAnnotation = (region) ->
  form = document.forms.edit
  form.classList.remove 'hide'
  form.elements.start.value = round1000(region.start)
  form.elements.end.value = round1000(region.end)
  form.elements.note.value = region.data.note or ''
  if region.data.type == 'segment'
    form.elements.note.setAttribute('disabled', 'disabled')
