<commit_before>class @DatabaseView

  recentlySize = 16
  pagerSize = 8

  $arcanaTable = $("#arcana-table")

  @init: -> new DatabaseView()

  constructor: ->
    CommonView.init()
    CommonView.showLatestInfo()

    pagerSize = (if CommonView.isPhoneDevice() then 8 else 16)
    recentlySize = (if CommonView.isPhoneDevice() then 16 else 32)

    $arcanaTable.children("thead").append(renderTableHeader())

    view = new ArcanasView(pagerSize: pagerSize, recentlySize: recentlySize)
    view.targetArcanas.onValue (as) -> replaceTableArea(as)

    $("#share-query-modal")
      .asEventStream('show.bs.modal')
      .map -> QueryLogs.lastQuery?.encode()
      .map (qs) ->
        path = "db"
        path += "?#{qs}" unless _.isEmpty(qs)
        path
      .doAction ->
        $("#share-url-form").hide() if CommonView.isPhoneDevice()
      .onValue (path) -> view.setTwitterShare(path)

    if CommonView.isPhoneDevice()
      $arcanaTable.swipe (
        swipeLeft: (e) ->
          prevTargetPage()
          e.preventDefault()
        swipeRight: (e) ->
          nextTargetPage()
          e.preventDefault()
      )

    sortTitleStream = $arcanaTable
      .asEventStream('click', 'th.sortable')
      .doAction('.preventDefault')
      .map (e) -> $(e.target)

    sortButtonStream = $arcanaTable
      .asEventStream('click', 'button.sortable')
      .doAction('.stopPropagation')
      .map (e) -> $(e.target).parents('th')

    sortColumnStream = sortTitleStream.merge(sortButtonStream)
      .map (target) -> target.data('colName')
      .filter (col) -> !_.isEmpty(col)

    view.sortColumn.plug sortColumnStream

    view.sortOrderState.onValue (state) -> renderOrderState(state)

  replaceTableArea = (as) ->
    tbody = $arcanaTable.children("tbody")
    tbody.empty()

    _.forEach as, (a) ->
      tr = renderTableArcana(a)
      tbody.append(tr)
    @

  renderTableHeader = ->
    tr = "
      <tr>
        <th class='sortable' data-col-name='name'>名前
          <button class='btn btn-default btn-xs sortable' type='button'>
            <i class='fa fa-sort'></i>
          </button>
        </th>
        <th>職</th>
        <th>★</th>
    "
    unless CommonView.isPhoneDevice()<commit_msg>スワイプが動作しなくなっていたのを修正<commit_after>class @DatabaseView

  recentlySize = 16
  pagerSize = 8

  $arcanaTable = $("#arcana-table")

  @init: -> new DatabaseView()

  constructor: ->
    CommonView.init()
    CommonView.showLatestInfo()

    pagerSize = (if CommonView.isPhoneDevice() then 8 else 16)
    recentlySize = (if CommonView.isPhoneDevice() then 16 else 32)

    $arcanaTable.children("thead").append(renderTableHeader())

    view = new ArcanasView(pagerSize: pagerSize, recentlySize: recentlySize)
    view.targetArcanas.onValue (as) -> replaceTableArea(as)

    $("#share-query-modal")
      .asEventStream('show.bs.modal')
      .map -> QueryLogs.lastQuery?.encode()
      .map (qs) ->
        path = "db"
        path += "?#{qs}" unless _.isEmpty(qs)
        path
      .doAction ->
        $("#share-url-form").hide() if CommonView.isPhoneDevice()
      .onValue (path) -> view.setTwitterShare(path)

    if CommonView.isPhoneDevice()
      $arcanaTable.swipe (
        swipeLeft: (e) ->
          $('.pager-prev').click()
          e.preventDefault()
        swipeRight: (e) ->
          $('.pager-next').click()
          e.preventDefault()
      )

    sortTitleStream = $arcanaTable
      .asEventStream('click', 'th.sortable')
      .doAction('.preventDefault')
      .map (e) -> $(e.target)

    sortButtonStream = $arcanaTable
      .asEventStream('click', 'button.sortable')
      .doAction('.stopPropagation')
      .map (e) -> $(e.target).parents('th')

    sortColumnStream = sortTitleStream.merge(sortButtonStream)
      .map (target) -> target.data('colName')
      .filter (col) -> !_.isEmpty(col)

    view.sortColumn.plug sortColumnStream

    view.sortOrderState.onValue (state) -> renderOrderState(state)

  replaceTableArea = (as) ->
    $arcanaTable.hide()
    tbody = $arcanaTable.children("tbody")
    tbody.empty()

    _.forEach as, (a) ->
      tr = renderTableArcana(a)
      tbody.append(tr)
    $arcanaTable.fadeIn('slow')
    @

  renderTableHeader = ->
    tr = "
      <tr>
        <th class='sortable' data-col-name='name'>名前
          <button class='btn btn-default btn-xs sortable' type='button'>
            <i class='fa fa-sort'></i>
          </button>
        </th>
        <th>職</th>
        <th>★</th>
    "
    unless CommonView.isPhoneDevice()
{'fraction_non_alphanumeric': 0.1546300398759415, 'fraction_numerical': 0.004430660168365086, 'mean_word_length': 2.5523210070810385, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6098922', 'n_tokens_mistral': 1510, 'n_tokens_neox': 1458, 'n_words': 261}