<link rel="stylesheet" type="text/css" media="screen" href="https://marines.sakura.ne.jp/script/tablesorter/theme/style.css" charset="Shift_JIS" />
<style type="text/css">
  tbody tr th {
    padding: 0 5px;
  }
  tbody tr td.number {
    text-align: center;
  }
  tbody tr td.mark {
    text-align: center;
  }
  tbody tr td.text {
    text-align: left;
  }
</style>
<script type="text/javascript" src="https://marines.sakura.ne.jp/script/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="https://marines.sakura.ne.jp/script/jquery.json2table.js"></script>
<script type="text/javascript">
  var musics;
  var table;
  var level_min = 1;
  var level_max = 12;
  var level_delta = 1;
  var notes_min = 0;
  var notes_max = 1499;
  var notes_delta = 100;

  $(document).ready(function() {
    $.getJSON('https://library.maplia.jp/json/musics_sevenscode.json', function(data) {
      musics = data;
      table = $('#table_musics');
      // レベルフィルタ
      select_level = $('#select_level');
      select_level.append($('<option/>', {
        value: -1, text: 'すべて'
      }));
      for (var i = level_min; i <= level_max; i += level_delta) {
        select_level.append($('<option/>', {
          value: i, text: i + (level_delta == 1 ? '' : '~' + (i + level_delta - 1))
        }));
      }
      // ノート数フィルタ
      select_notes = $('#select_notes');
      select_notes.append($('<option/>', {
        value: -1, text: 'すべて'
      }));
      for (var i = notes_min; i <= notes_max; i += notes_delta) {
        select_notes.append($('<option/>', {
          value: i, text: i + '~' + (i + notes_delta - 1)
        }));
      }
      createMusicTable();
      filterMusicTable();
    });
  });

  function createMusicTable() {
    var table_data = {};
    table_data.thead_column_classes = [
      'style_th', 'style_th', 'style_th', 'style_th', 'style_th'
    ];
    table_data.tbody_column_classes = [
      'style_th', 'text', 'mark', 'number', 'number'
    ];
    table_data.thead = [];
    table_data.tbody = [];
    table_data.thead[0] = {
      values: ['#', 'タイトル', '難易度', 'レベル', 'ノート数']
    };

    $.each(musics, function(i, music) {
      if (music.music_deleted) {
        return true;
      }

      const charts = {
        's_nor': music.simple_normal, 's_hrd': music.simple_hard,
        's_mas': music.simple_master, 's_cha': music.simple_challenge,
        'c_nor': music.chaos_normal,  'c_hrd': music.chaos_hard,
        'c_mas': music.chaos_master,  'c_cha': music.chaos_challenge
      };
      const full_title = music.title
        + (typeof music.subtitle === "undefined" ? '' : ' <small>' + music.subtitle + '</small>');

      $.each(charts, function(key, chart) {
        if (typeof chart === 'undefined') {
          return true;
        }
        if (chart.level) {
          const number = (key.indexOf('_cha') == -1 ? music.number : music.challenge_stage);
          table_data.tbody[table_data.tbody.length] = {
            id: music.id + '_' + key,
            class_name: 'chart_7c_' + key,
            values: [
              number, full_title, key.toUpperCase().replace('_', '-'), chart.level, chart.notes
            ]
          };
        }
      });
    });

    table.json2table(table_data);
    table.tablesorter({sortList: [[3, 1]]});
  }

  function filterMusicTable() {
    const mode = parseInt($(':radio[name="mode"]:checked').val());
    const diff = parseInt($(':radio[name="diff"]:checked').val());
    const level = parseInt($('select[name="level"]').val());
    const notes = parseInt($('select[name="notes"]').val());
    let count = 0;

    $('#table_musics tbody tr').each(function (i, item) {
      const item_level = parseInt($(item).find('td')[2].innerText);
      const item_notes = parseInt($(item).find('td')[3].innerText);

      $(item).show();
      // 譜面タイプフィルタ
      if (item.id.indexOf('_s_') > -1 && ![0, 1].includes(mode)) {
        $(item).hide(); return true;
      }
      if (item.id.indexOf('_c_') > -1 && ![0, 2].includes(mode)) {
        $(item).hide(); return true;
      }
      // 難易度フィルタ
      if (item.id.indexOf('_nor') > -1 && ![0, 1, 5].includes(diff)) {
        $(item).hide(); return true;
      }
      if (item.id.indexOf('_hrd') > -1 && ![0, 2, 5].includes(diff)) {
        $(item).hide(); return true;
      }
      if (item.id.indexOf('_mas') > -1 && ![0, 3, 5].includes(diff)) {
        $(item).hide(); return true;
      }
      if (item.id.indexOf('_cha') > -1 && ![0, 4].includes(diff)) {
        $(item).hide(); return true;
      }
      // レベルフィルタ
      if ((level != -1) && (item_level < level || (item_level >= level + level_delta))) {
        $(item).hide(); return true;
      }
      // ノート数フィルタ
      if ((notes != -1) && (item_notes < notes || (item_notes >= notes + notes_delta))) {
        $(item).hide(); return true;
      }
      count++;
    });
    if (count <= 0) {
      $('#table_rows').text('フィルター条件に該当する譜面はありません');
    } else {
      $('#table_rows').text(count + '譜面が該当しました');
    }
  }
</script>
<div>
  <p>
    譜面タイプフィルター: 
    <label><input type="radio" name="mode" value="0" onchange="filterMusicTable()" checked="checked"> 全譜面</label>
    <label><input type="radio" name="mode" value="1" onchange="filterMusicTable()"> シンプル</label>
    <label><input type="radio" name="mode" value="2" onchange="filterMusicTable()"> カオス</label>
  <br/>
    難易度フィルター: 
    <label><input type="radio" name="diff" value="0" onchange="filterMusicTable()"> 全譜面</label>
    <label><input type="radio" name="diff" value="1" onchange="filterMusicTable()"> NORMAL</label>
    <label><input type="radio" name="diff" value="2" onchange="filterMusicTable()"> HARD</label>
    <label><input type="radio" name="diff" value="3" onchange="filterMusicTable()"> MASTER</label>
    <label><input type="radio" name="diff" value="4" onchange="filterMusicTable()"> CHALLENGE</label>
    <label><input type="radio" name="diff" value="5" onchange="filterMusicTable()" checked="checked"> CHALLENGE以外</label>
  </p>
  <p>
    レベルフィルター: <select id="select_level" name="level" onchange="filterMusicTable()"></select>
    / 
    ノート数フィルター: <select id="select_notes" name="notes" onchange="filterMusicTable()"></select>
  </p>
  <p id="table_rows"></p>
  <table id="table_musics" class="tablesorter style_table" cellspacing="1" border="0"></table>
</div>

トップ   編集 凍結解除 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2020-11-15 (日) 16:37:04 (1740d)