'roni-timer' by rsegoly


Report abuse

Created on June 20, 2015 13:18 | Updated about 4 years ago

Link: https://gist.github.com/jywarren/4945996

test

setup: function() {
  // code to run on startup
  $W.timer = {}
  $W.timer.title = prompt('Please provide a title for the spectra you will be capturing. They will also be numbered sequentially.')
  $W.timer.number = 0
  $W.timer.countdown = 1 // seconds until next capture
  // run this every second:
  setInterval(function() {
    $W.timer.countdown -= 1
    $('#readout').html($W.timer.countdown+" seconds until autocapture")
  },1000)
  // run this every hour:
  $W.timer.capture = function() {
    $W.timer.number += 1
    if ($W.calibration_id) {
      // submit the data:
      $.ajax({
        url: "/spectrums",
        type: "POST",
        data: {
          spectrum: {
            title: $W.timer.title+" #"+$W.timer.number,
            notes: "Part of a series of hourly spectrum captures using the API.",
            calibration_id: $W.calibration_id
          },
          dataurl: $W.excerptCanvas(0,0,$W.width,1,$W.ctx).canvas.toDataURL(),
          tags: "periodic,macro",
        }
      })
    }
  }
  $W.timer.capture()
  setInterval($W.timer.capture,1000*60*60)
  $.mobile.changePage("#capture","slide")
},
draw: function() {
  
}