 #   - show the name of the next dashboard
 #   - add controls for manually cycling through dashboards
 class SwitcherControls
-  constructor: (interval=60000, dashboardNames, currentDashboardName) ->
+  constructor: (interval=60000, nextDashboardName) ->
     @currentTime = parseInt(interval, 10)
     @interval = parseInt(interval, 10)
     @$elements = $('#switcher-controls')
-    @currentDashboardName = currentDashboardName
-    @dashboardNames = dashboardNames
+    @nextDashboardName = nextDashboardName
+    @incrementTime = 1000 # refresh every 1000 milliseconds
 
   present: () ->
     @$elements.length

    @$timer = $.timer(@updateTimer, @incrementTime, true)

  addElements: () ->
    @$countdown = $("<span id='countdown'>00:00</span>")
    @$elements.append(@countdown)

  formatTime: (time) ->
    time = time / 10;
    min = parseInt(time / 6000, 10),
    sec = parseInt(time / 100, 10) - (min * 60)
    "#{(if min > 0 then pad(min, 2) else "00")}:#{pad(sec, 2)}"

  pad: -> (number, length) {
    str = "#{number}"
    while str.length < length
      str = "0#{str}"

    # Stop and reset timer
    @$timer.stop().once()

  updateTimer: () =>
    # Update dashboard name
    @$nextDashboardNameContainer.text("Next dashboard: #{@nextDashboardName} in ")
    # Output timer position
    timeString = @formatTime(@currentTime)
    @$countdown.html(timeString)

    # If timer is complete, trigger alert
