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

  stop: () ->
    clearInterval(@handle)

class SwitcherControls
  constructor: (interval=60000) ->
    @currentTime = parseInt(interval, 10)
    @interval = parseInt(interval, 10)
    @$elements = $('.switcher-controls')

  present: () ->
    @$elements.length

    if @dashboardNames.length == 0
      return

    # Take the dashboard name from that last part of the path
    pathParts = window.location.pathname.split('/')
    @curName = pathParts[pathParts.length - 1]
    @curPos = @dashboardNames.indexOf(@curName)

    # instantiate switcher controls for countdown and manual switching
    @switcherControls = new SwitcherControls(interval, @dashboardNames, @curName)
    @switcherControls.start() if @switcherControls.present()

    # If not found, default to first
    if @curPos == -1
