function get_select_days() {
  path = location.pathname.split('/');
  ss_path = path[2];

  if ( ss_path == 'ss' ) {
    server = path[1];
    ymd = path[3] +"-"+ path[4] +"-"+ path[5]
    url = '/api/v1/select_day?server=' + server +"&day=" + ymd

    $.ajax({
      url: url,
      type: "GET",
      timeout: 20000,
      success: function(data) {
        template  = '<tr><td><div>SERVER</div></td>';
        template += '<td><div class="text-nowrap fixed">DATE</div></td>';
        template += '<td class="STAT"><div class="text-nowrap fixed">NAME</div></td>';
        template += '<td><div class="text-nowrap fixed">BODY</div></td>'


        $.each(data, function(index, value){
          var j = value;

          switch(j.server) {
            case 's':
              template = template.replace(/SERVER/, '<span class="badge badge-danger">S</span>');
              break;
            case 'b':
              template = template.replace(/SERVER/, '<span class="badge badge-primary">B</span>');
              break;
            case 'v':
              template = template.replace(/SERVER/, '<span class="badge badge-warning">V</span>');
              break;
            case 'g':
              template = template.replace(/SERVER/, '<span class="badge badge-secondary">G</span>');
              break;
            default:
              template = template.replace(/SERVER/, '<span class="badge badge-default">'+j.server+'</span>');
          }

          template2 = template.replace(/NAME/, j.name);
          template2 = template2.replace(/DATE/, j.date);
          template2 = template2.replace(/BODY/, j.body);

          $("#select_days tbody").append(template2);
        });
        $("#stream_text").text('');
      },
        error: function() {
          alert("error");
          $('#stream_text').text('');
      }
    });
  };
};


window.onload = function(){
  $("#stream_text").text("表示中...");
  $("#select_days tbody tr").remove();
  get_select_days();
};
