         region_code: $(this).val()
       }
     ).done (results) ->
-      i = 0 # each with indexを使うと意図したとおりに動かなかったので制御変数を使うことにした
+      i = 0
+        # each with indexを使うと意図したとおりに動かなかったので
+        # 制御変数を使うことにした
       $.each results, ->
         option = $('<option>').val(this.round).text(this.name)
         if i == 0

        else
          $('#game_round').append(option)
        i += 1

Number::ordinal = ->
  return 'th' if 11 <= this % 100 <= 13
  switch this % 10
    when 1 then 'st'
    when 2 then 'nd'
    when 3 then 'rd'
    else        'th'

Number::ordinalize = ->
  this + this.ordinal()

################################################################################

class GameDetailAttributes

  constructor: (args) ->
    console.log 'create GameDetail'
    return unless args.nth or args.attributes
    @nth = args.nth ? 0
    @attributes = args.attributes
    @prefix = 'game_game_detail' +
      parseInt(@nth).ordinalize() + 's' +
      '_attributes_'
    @regexs = (///^#{@prefix}\d_#{i}$/// for i in @attributes)
    console.log @nth
    console.log @attributes
    console.log @prefix
    console.log @regexs

  # public methods
  switch: (event) ->
    console.log 'switch method runs'
    console.log event.target.id
    console.log @nth
    console.log @regexs
    return if @nth = 0
    for regex, i in @regexs
      if regex.test(event.target.id)
        i = event.target.id.match(/_\d+_/)[0].replace(/_/g, '')
        if $('#' + @prefix + i + '_' + @attributes[i])[0].checked
          $('.' + @attributes[i] + '_' + i).toggleClass('hidden')
        else
          $('.' + @attributes[i] + '_' + i).toggleClass('hidden')
          $('#' + @prefix + i + '_my_' + @attributes[i]).val('')
          $('#' + @prefix + i + '_opponent_' + @attributes[i]).val('')

################################################################################

$ ->
  # write/rewrite for a label
  replay_label = (counter, element) ->
