     clear: ->
       @ctx.clearRect(0, 0, @canvas.width, @canvas.height)
       @addHistory()
-      null
 
     save: ->
       dataURL = @canvas.toDataURL()

      @ctx.stroke()
      @ctx.closePath()

  listPictures = (myCanvas) ->
      $.get '/pictures/list.txt', (result)->
        # console.log result
        ids = result.split(',')
        pictures = $("#pictures")
        pictures.empty()
        ids.forEach (id, i)->
          if parseInt(id, 10) > 0
            pictures.append("<img src=\"/images/#{id}.png\" class=\"pict_thumbnail\" />")
        thumb_pics = $("#pictures .pict_thumbnail")
        thumb_pics.click ->
          image = new Image()
          image.src = $(@).attr('src')
          image.onload = ->
            myCanvas.reload(image)
        thumb_pics.mouseenter ->
          $(@).addClass('pict_thumbnail-over')
        thumb_pics.mouseout ->
          $(@).removeClass('pict_thumbnail-over')
        null

  # ====================================
  img = null
  canvas = $('#draw-area')[0]

  if canvas

    $("#clear-button").click -> myCanvas.clear()
    # undo
    $("#undo-button").click -> myCanvas.showHistory(-1)
    # redo
    $("#redo-button").click -> myCanvas.showHistory(1)
    # 保存
    $("#save-button").click ->
      myCanvas.save()
      listPictures(myCanvas)
    # ダウンロード
    $("#download-button").click -> myCanvas.download()

    listPictures(myCanvas)  # 保存した画像の一覧を表示

    # 参照ボタンで読込処理
    $("#upload").change ->　myCanvas.loadFile(@files[0])

    # ドラッグアンドドロップで読込む
    canvas.ondragover = -> false
    canvas.ondrop = (event) -> myCanvas.ondrop(event)

    null
