script(src='/javascripts/newexercisevalidation.js')


h1 Edit Exercise<p></p>

form(id="newexercise", method="POST", action="/admin/exercises/" + encodeURIComponent(exercise._id))
  ul
    li
      label(for="name") Exercise Name<br />
      input#name(name="name", value= exercise.name, oldvalue= exercise.name)
      input#_id(name="_id", value= exercise._id, type='hidden')

    li
      label(for="type") Exercise Type<br />

      //- first a little prep 
      - freeweights = ('freeweights'==exercise.type) ? 'selected' : null; 
      - machine = ('machine'==exercise.type) ? 'selected' : null; 
      - bodyweight = ('bodyweight'==exercise.type) ? 'selected' : null; 
      - kettlebells = ('kettelbells'==exercise.type) ? 'selected' : null; 
      - cardio = ('cardio'==exercise.type) ? 'selected' : null; 

      select#type(name="type")
        option(value='notselected') Select One
        option(value='freeweights', selected=freeweights) Free Weights
        option(value='machine', selected=machine) Exercise Machine
        option(value='bodyweight', selected=bodyweight) Bodyweight
        option(value='kettlebells', selected=kettlebells) Kettlebells
        option(value='cardio', selected=cardio) Cardio

    li
      label(for="type") Exercise Description<br />
      input#description(name="description", value= exercise.description)
    li
      label(for="type") Exercise Difficulty<br />
      input#difficulty(name="difficulty", value= exercise.difficulty)
      i = 0
      - for (i ; i < 10; ++i) {
        marray =  "musclearray[" + i + "]"
        li
          label(for="type") Muscle data #{i} 
          input(name= marray, class="musclearray", id= marray, value= exercise.musclearray[i]) 
      - }
   li
      keywordlist = [ 'Free Weights', 'Exercise Machine', 'Bodyweight', 'Kettlebells', 'Cardio']
      label(for="type") Keywords<br />
      select#type(name="keywords", multiple="multiple")
        - for keyword in keywordlist
          option(selected=exercise.keywords.indexOf(keyword) != -1) #{keyword}


    li
      label(for="type") Alternatives<br />
    li
      datafieldlist = ['Reps','Weight','Time','Distance']
      label(for="datafields") Datafields<br />
      select#type(name="datafields", multiple="multiple")
         - for datafield in datafieldlist
          option(selected=exercise.datafields.indexOf(datafield) != -1) #{datafield}
    li
      input(type="submit", value="Save Changes")

p
  a(href="/admin") Admin Index
p
  a(href="/admin/users") Admin Users
p
  a(href="/admin/exercises") Admin Exercises